/* ----- FONTS & VARIABLES ----- */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&family=Playfair+Display:wght@700&display=swap');

:root {
    --primary-color: #ff6f61;
    --background-color: #f9f9f9;
    --text-color: #333333;
    --card-background: #ffffff;
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Poppins', sans-serif;
}

/* ----- GENERAL & BASE STYLES ----- */

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

body { 
    font-family: var(--font-body); 
    background-color: var(--background-color); 
    color: var(--text-color); 
    line-height: 1.6; 
    overflow-x: hidden;
}

main { 
    width: 90%; 
    max-width: 1100px; 
    margin: 40px auto 0; 
}

/* ----- HEADER & DESKTOP NAVIGATION ----- */

.site-header {
    background-color: var(--card-background);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1600;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    height: 70px;
}

.logo a {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    flex-shrink: 0; 
}

.main-nav {
    flex-grow: 1;
}

.main-nav ul {
    list-style: none;
    display: flex;
    justify-content: flex-end; 
    gap: 25px;
    align-items: center;
}

.main-nav a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    padding: 5px 0;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.main-nav a:hover, 
.main-nav a.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.login-button {
    background-color: var(--primary-color);
    color: white !important;
    padding: 8px 15px !important;
    border-radius: 5px;
    border-bottom: none !important;
}

.login-button:hover {
    color: white !important;
    border-bottom: none !important;
}

/* Desktop-only user dropdown menu */
.user-menu {
    position: relative;
}

.user-menu .welcome-user {
    cursor: default;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 110%;
    right: 0;
    background-color: var(--card-background);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-radius: 8px;
    padding: 10px;
    z-index: 10;
    width: 150px;
}

.dropdown-menu a {
    display: block;
    padding: 8px 12px;
    border-bottom: none;
    border-radius: 5px;
}

.dropdown-menu a:hover {
    background-color: #f1f1f1;
    border-bottom: none;
}

/* This rule shows the dropdown on hover */
.user-menu:hover .dropdown-menu {
    display: block;
}

/* Hides mobile-specific elements on desktop */
.menu-toggle,
.mobile-only,
.close-menu-container {
    display: none;
}

/* ----- MAIN CONTENT & SECTIONS ----- */

.hero-section { 
    text-align: center; 
    padding: 80px 20px; 
    background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('https://images.unsplash.com/photo-1504674900247-0877df9cc836?w=1200') no-repeat center center/cover; 
    color: white; 
    border-radius: 10px; 
}

.hero-content h1 { 
    font-family: var(--font-heading); 
    font-size: 3.5rem; 
    margin-bottom: 15px; 
}

.hero-content p { 
    font-size: 1.2rem; 
    max-width: 600px; 
    margin: 0 auto 30px; 
}

.cta-button { 
    background-color: var(--primary-color); 
    color: white; 
    text-decoration: none; 
    padding: 15px 30px; 
    border-radius: 8px; 
    font-weight: 600; 
    transition: background-color 0.3s ease; 
}

.cta-button:hover { 
    background-color: #e65a4d; 
}

.inspiration-section, .tool-section, .results-section { 
    padding: 60px 0; 
}

.inspiration-section h2, .tool-section h2, .results-section h2 { 
    text-align: center; 
    font-family: var(--font-heading); 
    margin-bottom: 30px; 
    font-size: 2.5rem; 
}

.inspiration-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
    gap: 25px; 
}

.inspiration-card { 
    position: relative; 
    border-radius: 8px; 
    overflow: hidden; 
    cursor: pointer;
}

.inspiration-card img { 
    width: 100%; 
    height: 350px; 
    object-fit: cover; 
    display: block; 
}

.inspiration-card h3 { 
    position: absolute; 
    bottom: 20px; 
    left: 20px; 
    color: white; 
    font-family: var(--font-heading); 
    font-size: 1.8rem; 
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7); 
}

/* Styles for the two-column recipe finder tool */
.search-section-advanced { 
    display: grid; 
    grid-template-columns: 2fr 1fr; 
    gap: 30px; 
    background-color: var(--card-background); 
    padding: 30px; 
    border-radius: 8px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); 
}

.ingredient-input-area h3 {
    margin-top: 25px;
    margin-bottom: 10px;
}

.autocomplete-container { 
    position: relative; 
    margin-bottom: 20px; 
}

#ingredient-input { 
    width: 100%; 
    padding: 15px; 
    border: 1px solid #ddd; 
    border-radius: 8px; 
    font-size: 1rem; 
}

.autocomplete-items { 
    position: absolute; 
    border: 1px solid #ddd; 
    border-top: none; 
    z-index: 99; 
    top: 100%; 
    left: 0; 
    right: 0; 
    max-height: 250px; 
    overflow-y: auto; 
    background-color: white; 
}

.autocomplete-items div { 
    padding: 10px; 
    cursor: pointer; 
    background-color: #fff; 
    border-bottom: 1px solid #d4d4d4; 
}

.autocomplete-items div:hover { 
    background-color: #e9e9e9; 
}

.popular-ingredients { 
    text-align: left; 
}

.popular-ingredients h4 { 
    margin-bottom: 10px; 
    font-weight: 600; 
}

.popular-btn { 
    background-color: #f0f2f5; 
    color: #4b5563; 
    border: none; 
    padding: 8px 16px; 
    border-radius: 50px; 
    cursor: pointer; 
    font-size: 0.9rem; 
    font-weight: 600; 
    margin-right: 8px; 
    margin-bottom: 8px; 
    transition: all 0.2s ease-in-out; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); 
}

.popular-btn:hover { 
    background-color: #e2e8f0; 
    transform: translateY(-2px); 
    box-shadow: 0 4px 8px rgba(0,0,0,0.1); 
}

/* Right column of the recipe finder tool */
.ingredient-display-area {
    border-left: 1px solid #eee;
    padding-left: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#ingredient-tags { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
    min-height: 50px; 
    margin-bottom: 15px; 
}

.ingredient-tag { 
    background-color: #e0e0e0; 
    padding: 5px 10px; 
    border-radius: 15px; 
    font-size: 0.9rem; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}

.remove-tag-btn { 
    background: none; 
    border: none; 
    font-size: 1rem; 
    cursor: pointer; 
    color: #888; 
}

.ingredient-display-area .filter-section {
    margin-top: 0;
    text-align: left; /* Aligns "Any special diet?" to the left */
}

.ingredient-display-area .filter-options {
    justify-content: flex-start; /* Aligns filter buttons to the left */
}

#must-have-section { 
    margin-top: 20px; 
}

/* Pushes this section to the bottom of the flex container */
.ingredient-display-area #must-have-section {
    margin-top: auto; 
}

#must-have-section h4 { 
    margin-bottom: 10px; 
    font-weight: 600; 
}

#must-have-select { 
    width: 100%; 
    padding: 10px; 
    border: 1px solid #ddd; 
    border-radius: 8px; 
    font-size: 1rem; 
    font-family: var(--font-body); 
    background-color: white; 
}

#search-recipes-btn {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-top: 20px;
}

#search-recipes-btn:hover { 
    background-color: #e65a4d; 
}


/* ----- RECIPE RESULTS ----- */

.filter-section { 
    margin-top: 40px; 
    text-align: center; 
}

.filter-options { 
    display: flex; 
    justify-content: center; 
    flex-wrap: wrap; 
    gap: 10px; 
    margin-top: 15px; 
}

.filter-btn { 
    background-color: #f0f0f0; 
    border: 1px solid #ddd; 
    padding: 8px 15px; 
    border-radius: 20px; 
    cursor: pointer; 
    transition: all 0.3s ease; 
}

.filter-btn.active { 
    background-color: var(--primary-color); 
    color: white; 
    border-color: var(--primary-color); 
}

#recipe-results-container { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 25px; 
    text-align: left; 
}

.recipe-card { 
    background-color: var(--card-background); 
    border-radius: 8px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.08); 
    overflow: hidden; 
    transition: transform 0.3s ease; 
    cursor: pointer; 
    position: relative; 
}

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

.recipe-card img { 
    width: 100%; 
    height: 200px; 
    object-fit: cover; 
}

.recipe-card-content { 
    padding: 20px; 
}

.recipe-card-content h3 { 
    font-family: var(--font-heading); 
    margin-bottom: 10px; 
}

.favorite-btn { 
    position: absolute; 
    top: 15px; 
    right: 15px; 
    background: rgba(255, 255, 255, 0.8); 
    border: none; 
    border-radius: 50%; 
    width: 40px; 
    height: 40px; 
    cursor: pointer; 
    font-size: 1.2rem; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    color: #ccc; 
}

.favorite-btn.saved { 
    color: var(--primary-color); 
}

/* ----- MODALS ----- */

.modal-overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.7); 
    display: none; 
    justify-content: center; 
    align-items: center; 
    z-index: 2000; 
}

.modal-content { 
    background: white; 
    padding: 30px; 
    border-radius: 10px; 
    max-width: 700px; 
    width: 90%; 
    max-height: 85vh; 
    overflow-y: auto; 
    position: relative; 
}

.modal-close-btn { 
    position: absolute; 
    top: 15px; 
    right: 20px; 
    background: none; 
    border: none; 
    font-size: 2rem; 
    cursor: pointer; 
}

#modal-body h2 { 
    font-family: var(--font-heading); 
    margin-bottom: 20px; 
}

#modal-body img { 
    width: 100%; 
    border-radius: 8px; 
    margin-bottom: 20px; 
}

#modal-body ul, #modal-body ol { 
    margin-left: 20px; 
    margin-bottom: 20px; 
}


/* ----- AUTH & FEEDBACK FORMS ----- */

#login-form, #signup-form, #feedback-form { 
    margin-top: 20px; 
    display: flex; 
    flex-direction: column; 
    gap: 15px; 
}

#login-form input, 
#signup-form input, 
#feedback-form input[type="email"], 
#feedback-form textarea { 
    padding: 15px; 
    border: 1px solid #ddd; 
    border-radius: 8px; 
    font-size: 1rem; 
    font-family: var(--font-body); 
}

#login-form button, 
#signup-form button { 
    background-color: var(--primary-color); 
    color: white; 
    border: none; 
    padding: 15px; 
    border-radius: 8px; 
    font-size: 1.1rem; 
    font-weight: 600; 
    cursor: pointer; 
    transition: background-color 0.3s ease; 
}

#login-form button:hover, 
#signup-form button:hover { 
    background-color: #e65a4d; 
}

.auth-switch { 
    text-align: center; 
    margin-top: 20px; 
    font-size: 0.9rem; 
}

.auth-switch a { 
    color: var(--primary-color); 
    font-weight: 600; 
    text-decoration: none; 
}

.error-message { 
    color: #dc3545; 
    display: block; 
    margin-top: -10px; 
    margin-bottom: 5px; 
    font-size: 0.8rem; 
    height: 1em; 
}

#password-criteria { 
    display: flex; 
    flex-direction: column; 
    gap: 5px; 
    margin-top: -5px; 
    font-size: 0.8rem; 
    text-align: left; 
}

#password-criteria small { 
    color: #6c757d; 
    transition: color 0.3s ease; 
}

#password-criteria small.valid { 
    color: #28a745; 
}

#password-criteria small.valid::before { 
    content: '✓ '; 
    font-weight: 600; 
}

#feedback-form { 
    text-align: left; 
}

#feedback-form .form-group { 
    display: flex; 
    flex-direction: column; 
}

#feedback-form label { 
    margin-bottom: 5px; 
    font-weight: 600; 
    font-size: 0.9rem; 
}

#feedback-form .radio-group { 
    display: flex; 
    gap: 20px; 
}

#feedback-form .cta-button { 
    border: none; 
    cursor: pointer; 
    width: 100%; 
    font-size: 1.1rem; 
}


/* ----- FOOTER ----- */

.site-footer-detailed { 
    background-color: var(--card-background); 
    color: var(--text-color); 
    padding: 50px 20px; 
    border-top: 1px solid #e0e0e0; 
}

.footer-container { 
    max-width: 1200px; 
    margin: 0 auto; 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 30px; 
}

.footer-column h3 { 
    font-family: var(--font-heading); 
    color: var(--text-color); 
    font-size: 1.2rem; 
    margin-bottom: 20px; 
    font-weight: 700; 
}

.footer-column ul { 
    list-style: none; 
}

.footer-column li { 
    margin-bottom: 10px; 
}

.footer-column a { 
    text-decoration: none; 
    color: #6c757d; 
    transition: color 0.3s ease; 
}

.footer-column a:hover { 
    color: var(--primary-color); 
}

.footer-bottom { 
    text-align: center; 
    margin-top: 40px; 
    padding-top: 20px; 
    border-top: 1px solid #e0e0e0; 
    font-size: 0.9rem; 
    color: #888; 
}

.attribution-link { 
    margin-top: 8px; 
    font-size: 0.8rem; 
    color: #888; 
}

.attribution-link a { 
    color: #6c757d; 
    font-weight: 600; 
}


/* ----- RESPONSIVE DESIGN ----- */

@media (max-width: 768px) {
    /* General adjustments for tablets and smaller screens */
    .hero-content h1 { font-size: 2.5rem; }
    .inspiration-section h2, .tool-section h2, .results-section h2 { font-size: 2rem; }
    .search-section-advanced { grid-template-columns: 1fr; }
    .ingredient-display-area { border-left: none; padding-left: 0; border-top: 1px solid #eee; padding-top: 20px; }
    #recipe-results-container { grid-template-columns: repeat(2, 1fr); }
    .footer-container { grid-template-columns: 1fr; text-align: center; }

    /* --- Mobile Navigation: Slide-out menu --- */
    /* This section handles the transformation from a desktop nav bar to a mobile slide-out menu.
       It uses a hamburger toggle, a screen overlay, and CSS transforms for the animation. */
    .header-container {
        justify-content: space-between;
    }

    .menu-toggle {
        display: block;
        order: -1; /* Moves hamburger to the far left */
        background: none;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
        color: var(--text-color);
    }

    body.menu-open {
        overflow: hidden; /* Prevents scrolling of the body when menu is open */
    }

    .menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1500;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .main-nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 250px;
        height: 100vh;
        background-color: var(--card-background);
        box-shadow: 4px 0 15px rgba(0,0,0,0.1);
        z-index: 2000;
        padding: 20px;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        overflow-y: auto;
    }

    .main-nav.active {
        transform: translateX(0);
    }
    
    .main-nav ul {
        flex-direction: column;
        height: 100%;
        justify-content: flex-start;
        gap: 0;
    }

    .main-nav li {
        width: 100%;
        text-align: left;
    }

    .main-nav a {
        display: block;
        width: 100%;
        padding: 12px 20px;
        border-bottom: 1px solid #f0f0f0;
        font-size: 1.1rem;
    }
    
    .close-menu-container {
        display: block;
        text-align: right;
        padding-bottom: 10px;
        border-bottom: 1px solid #eee;
        margin-bottom: 10px;
    }

    .close-menu-btn {
        background: none;
        border: none;
        font-size: 2rem;
        cursor: pointer;
        color: var(--text-color);
    }
    
    /* Swaps visibility of desktop/mobile elements */
    .desktop-only { display: none; }
    .mobile-only { display: block; }
    
    .user-header {
        font-size: 1.2rem;
        font-weight: bold;
        color: var(--text-color);
        padding: 20px;
        text-align: left;
        border-bottom: 1px solid #eee;
    }
    
    .logout-link {
        margin-top: auto; /* Pushes logout to the bottom */
    }

    .logout-link a {
        background-color: #fbeeee;
        text-align: center;
        font-weight: bold;
        color: var(--primary-color);
        border-radius: 8px;
        border-bottom: none;
    }

    .main-nav .login-button {
        background-color: transparent;
        color: var(--text-color) !important;
        border-radius: 0;
        text-align: left;
        font-weight: 600;
        font-size: 1.1rem;
        padding: 12px 20px;
    }
}

@media (max-width: 480px) {
    /* Styles for small mobile screens */
    #recipe-results-container {
        grid-template-columns: 1fr;
    }
}