* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: #667eea;
    text-decoration: none;
    z-index: 1001;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-links a:hover {
    color: #667eea;
}

.nav-links a.active {
    color: #667eea;
    font-weight: 600;
}

.hamburger {
    display: none;
    cursor: pointer;
    z-index: 1001;
}

.hamburger div {
    width: 25px;
    height: 3px;
    background-color: #333;
    margin: 5px 0;
    transition: all 0.3s ease;
}

/* Hero Section */
.hero {
    padding: 120px 0 80px;
    text-align: center;
    color: white;
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.hero p {
    font-size: 1.3rem;
    margin-bottom: 2rem;
    opacity: 0.9;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Search Section */
.search-section {
    background: white;
    padding: 60px 0;
    margin: 0 20px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    position: relative;
    top: -40px;
}

/* Search page specific styling */
body.search-page {
    background: #f8f9fa;
}

body.search-page .search-section {
    top: 0;
    margin: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.search-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.search-title {
    text-align: center;
    font-size: 2.2rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 2rem;
}

/* Main Search Container */
.main-search-container {
    position: relative;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid #e1e5e9;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.search-input-wrapper:focus-within {
    border-color: #667eea;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.2);
}

.main-search-input {
    flex: 1;
    padding: 18px 20px;
    border: none;
    outline: none;
    font-size: 1.1rem;
    background: transparent;
    color: #333;
}

.main-search-input::placeholder {
    color: #999;
}

.search-submit-btn {
    padding: 18px 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    border-radius: 10px;
    margin-top: 1rem;
    align-self: center;
}

.search-submit-btn:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

/* Suggestions Container */
.suggestions-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e1e5e9;
    border-top: none;
    border-radius: 0 0 15px 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.suggestions-list {
    padding: 0;
}

.suggestion-item {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.highlighted {
    background-color: #f8f9fa;
}

.suggestion-item.ingredient {
    background-color: #e8f5e8;
    border-left: 4px solid #28a745;
}

.suggestion-item.ingredient:hover,
.suggestion-item.ingredient.highlighted {
    background-color: #d4edda;
}

.suggestion-item.nutrition {
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
}

.suggestion-item.nutrition:hover,
.suggestion-item.nutrition.highlighted {
    background-color: #ffeaa7;
}

.suggestion-item.recipe {
    background-color: #d1ecf1;
    border-left: 4px solid #17a2b8;
}

.suggestion-item.recipe:hover,
.suggestion-item.recipe.highlighted {
    background-color: #bee5eb;
}

.suggestion-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.8rem;
    color: white;
}

.suggestion-item.ingredient .suggestion-icon {
    background-color: #28a745;
}

.suggestion-item.nutrition .suggestion-icon {
    background-color: #ffc107;
    color: #333;
}

.suggestion-item.recipe .suggestion-icon {
    background-color: #17a2b8;
}

.suggestion-text {
    flex: 1;
    font-size: 0.95rem;
    color: #333;
}

.suggestion-description {
    font-size: 0.8rem;
    color: #666;
    margin-top: 2px;
}

/* Active Filters */
.active-filters {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 2rem;
}

.active-filters h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.75rem;
}

.active-filters-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #667eea;
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.filter-tag.ingredient {
    background: #28a745;
}

.filter-tag.nutrition {
    background: #ffc107;
    color: #333;
}

.filter-tag.recipe {
    background: #17a2b8;
}

.filter-remove {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
    margin-left: 0.25rem;
    font-size: 0.9rem;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.filter-remove:hover {
    opacity: 1;
}

.clear-filters-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clear-filters-btn:hover {
    background: #c82333;
}

/* Legacy form styles (for hidden form) */
.search-form {
    display: none;
}

.search-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.search-group {
    display: flex;
    flex-direction: column;
}

.search-group label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #555;
}

.search-group input,
.search-group select {
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    width: 100%;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.search-group input:focus,
.search-group select:focus {
    outline: none;
    border-color: #667eea;
}

.search-group.full-width {
    grid-column: 1 / -1;
}

.search-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

.btn {
    padding: 14px 32px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #e1e5e9;
}

.btn-secondary:hover {
    background: #e9ecef;
}

/* Features Section */
.features {
    padding: 80px 0;
    background: white;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.feature-card {
    text-align: center;
    padding: 2rem;
    border-radius: 15px;
    background: #f8f9fa;
    transition: transform 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-5px);
}

.feature-icon {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #333;
}

.feature-card p {
    color: #666;
    line-height: 1.6;
}

/* Results Section */
.results {
    padding: 60px 0;
    background: #f8f9fa;
}

.results-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.results-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: #333;
}

.results-count {
    color: #666;
    font-size: 1rem;
}

.recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.recipe-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.recipe-card:hover {
    transform: translateY(-5px);
}

.recipe-image {
    width: 100%;
    height: 200px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
}

.recipe-image img {
    height: 100%;
}

.recipe-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.recipe-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.recipe-ingredients {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.recipe-nutrition {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #666;
}

.nutrition-item {
    display: flex;
    justify-content: space-between;
}

.recipe-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #667eea;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: auto;
    transition: color 0.2s ease;
    padding-top: 1rem;
}

.recipe-link:hover {
    color: #5a6fd8;
    text-decoration: underline;
}

.recipe-link i {
    font-size: 0.8rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination button {
    padding: 8px 12px;
    border: 1px solid #e1e5e9;
    background: white;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 36px;
    min-width: 36px;
    touch-action: manipulation;
}

.pagination button:hover {
    background: #667eea;
    color: white;
}

.pagination button.active {
    background: #667eea;
    color: white;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Footer */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 2rem 0;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    /* Header */
    .hamburger {
        display: block;
    }

    .nav-links {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 2.5rem;
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
    }

    .nav-links.nav-active {
        transform: translateX(0%);
    }

    .nav-links a {
        font-size: 1.5rem;
    }

    .nav-toggle .line1 {
        transform: rotate(-45deg) translate(-5px, 6px);
    }
    .nav-toggle .line2 {
        opacity: 0;
    }
    .nav-toggle .line3 {
        transform: rotate(45deg) translate(-5px, -6px);
    }

    /* Hero Section */
    .hero {
        padding: 100px 0 60px;
    }

    .hero h1 {
        font-size: 2.5rem;
        line-height: 1.2;
    }

    .hero p {
        font-size: 1.1rem;
        padding: 0 10px;
    }

    /* Search Section */
    .search-section {
        margin: 0 10px;
        padding: 40px 0;
        border-radius: 15px;
    }

    .search-container {
        padding: 0 15px;
    }

    .search-title {
        font-size: 1.8rem;
        margin-bottom: 1.5rem;
    }

    .main-search-input {
        padding: 16px 18px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .search-submit-btn {
        padding: 16px 20px;
        font-size: 1rem;
    }

    .suggestion-item {
        padding: 10px 16px;
    }

    .suggestion-text {
        font-size: 0.9rem;
    }

    .suggestion-description {
        font-size: 0.75rem;
    }

    .active-filters {
        padding: 0.75rem;
    }

    .active-filters h3 {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    .filter-tag {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }

    .clear-filters-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .search-form {
        gap: 1rem;
    }

    .search-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .search-group input,
    .search-group select {
        padding: 12px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 8px;
    }

    .search-buttons {
        flex-direction: column;
        gap: 0.75rem;
        margin-top: 1.5rem;
    }

    .btn {
        padding: 14px 24px;
        font-size: 16px;
        width: 100%;
        text-align: center;
    }

    /* Features Section */
    .features {
        padding: 60px 0;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        margin-top: 2rem;
    }

    .feature-card {
        padding: 1.5rem;
    }

    .feature-icon {
        font-size: 2.5rem;
    }

    .feature-card h3 {
        font-size: 1.3rem;
    }

    /* Results Section */
    .results {
        padding: 40px 0;
    }

    .results-container {
        padding: 0 15px;
    }

    .results-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .results-title {
        font-size: 1.5rem;
    }

    .recipes-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .recipe-card {
        margin: 0 auto;
        max-width: 350px;
        width: 100%;
    }

    .recipe-content {
        padding: 1rem;
    }

    .recipe-title {
        font-size: 1.1rem;
    }

    .recipe-nutrition {
        grid-template-columns: 1fr;
        gap: 0.3rem;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    .pagination button {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    /* Footer */
    footer {
        padding: 1.5rem 0;
        font-size: 0.9rem;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .hero h1 {
        font-size: 2rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .search-title {
        font-size: 1.5rem;
    }

    .search-section {
        margin: 0 5px;
        padding: 30px 0;
    }

    .search-container {
        padding: 0 10px;
    }

    .main-search-input {
        padding: 14px 16px;
        font-size: 16px;
    }

    .search-submit-btn {
        padding: 14px 18px;
        font-size: 0.9rem;
    }

    .suggestion-item {
        padding: 8px 12px;
    }

    .suggestion-text {
        font-size: 0.85rem;
    }

    .suggestion-description {
        font-size: 0.7rem;
    }

    .active-filters {
        padding: 0.5rem;
    }

    .filter-tag {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .clear-filters-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }

    .nav-links a {
        font-size: 1.2rem;
    }

    .feature-card {
        padding: 1rem;
    }

    .feature-icon {
        font-size: 2rem;
    }

    .feature-card h3 {
        font-size: 1.2rem;
    }

    .recipe-image {
        height: 150px;
        font-size: 2rem;
    }

    .btn {
        padding: 12px 20px;
        font-size: 16px;
        width: 100%;
    }

    .search-group input,
    .search-group select {
        font-size: 16px;
        padding: 14px 12px;
    }

    .search-group label {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }
}

/* Landscape orientation for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        padding: 80px 0 40px;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .search-section {
        padding: 30px 0;
    }
    
    .nav-links {
        gap: 1.5rem;
    }
}

.hidden {
    display: none;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e1e5e9;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #666;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.modal-body {
    padding: 1.5rem;
}

.nutrition-input-group {
    margin-bottom: 1.5rem;
}

.nutrition-input-group:last-child {
    margin-bottom: 0;
}

.nutrition-input-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #555;
}

.nutrition-input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.nutrition-input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.nutrition-input-group span {
    display: inline-block;
    margin-left: 0.5rem;
    color: #666;
    font-weight: 500;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding: 1.5rem;
    border-top: 1px solid #e1e5e9;
}

.modal-footer .btn {
    min-width: 100px;
}

/* Mobile modal styles */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 1rem;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }

    .modal-header h3 {
        font-size: 1.1rem;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }
}
