:root {
    /* Nordic Clean Theme - Light (Default) */
    --primary-color: #2d6a4f;
    /* Forest Green */
    --primary-hover: #1b4332;
    --accent-color: #d8f3dc;
    --bg-color: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-color: #212529;
    --text-muted: #6c757d;
    --border-color: #e9ecef;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --radius-md: 8px;
    --radius-lg: 16px;
}

[data-theme="dark"] {
    /* Nordic Clean Theme - Dark */
    --primary-color: #40916c;
    /* Lighter Forest Green for contrast */
    --primary-hover: #52b788;
    --accent-color: #1b4332;
    --bg-color: #121212;
    --bg-secondary: #1e1e1e;
    --text-color: #e9ecef;
    --text-muted: #adb5bd;
    --border-color: #343a40;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-secondary);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header & Nav */
header {
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    /* High enough to be above overlay but below modals */
}

.nav-wrapper {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    /* Allow wrapping for mobile menu */
}

/* Grouping container for right-side Mobile items (toggle + burger) */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    letter-spacing: -0.5px;
    margin-right: auto;
    /* Push everything else to the right */
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--primary-color);
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    padding: 5px;
    display: flex;
    align-items: center;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
}

.menu-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--bg-secondary);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-color);
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s;
}

.menu-close-btn:hover {
    background: var(--border-color);
    transform: rotate(90deg);
}

/* API & Utility Classes */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

/* Recipe Grid */
.hero {
    padding: 4rem 0;
    text-align: center;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    padding: 2rem 0;
}

.card {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-4px);
}

.card-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: var(--border-color);
    /* Placeholder */
}

.card-content {
    padding: 1.5rem;
}

.card-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.card-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
    margin-bottom: 1rem;
}

.tag {
    background: var(--accent-color);
    color: var(--primary-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }

    /* In mobile, we keep the order: Logo ... NavActions (Toggle+Burger) ... NavLinks (New Line) */

    .nav-links {
        display: none;
        /* Hidden by default */
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        padding-top: 1rem;
        border-top: 1px solid var(--border-color);
        margin-top: 1rem;
        order: 3;
        /* Force to bottom */
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links a {
        width: 100%;
        padding: 0.5rem 0;
    }

    /* Ensure the actions stay on the right */
    .nav-actions {
        margin-left: auto;
        /* Push to right if logo is on left */
    }

    .grid {
        grid-template-columns: 1fr;
        /* 1 col on mobile */
    }
}

/* Desktop Adjustment - we want Links LEFT of Actions */
@media (min-width: 769px) {
    .nav-actions {
        order: 2;
    }

    .nav-links {
        order: 1;
        margin-right: 1.5rem;
        /* Small gap between links and toggle */
    }
}

/* Single Recipe Responsive */
@media (max-width: 768px) {
    .recipe-body {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    .recipe-hero-image {
        height: 250px !important;
    }

    .recipe-content h1 {
        font-size: 2rem !important;
    }
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--bg-color);
    min-width: 260px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    top: 100%;
    right: 0;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: calc(100vh - 100px);
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.dropdown-content::-webkit-scrollbar {
    width: 4px;
}

.dropdown-content::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

.menu-slider {
    display: flex;
    width: 200%;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.menu-view {
    width: 50%;
    flex-shrink: 0;
    padding: 0.5rem 0;
}

.menu-slider.slide-admin {
    transform: translateX(-50%);
}

.dropdown-content.active {
    display: block;
    animation: dropdown-fade-in 0.2s ease-out;
}

@keyframes dropdown-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-content .menu-label {
    padding: 12px 16px 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.05em;
}

.dropdown-content .menu-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 8px 0;
}

.dropdown-content a {
    color: var(--text-color);
    padding: 10px 16px;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.dropdown-content a:hover {
    background-color: var(--bg-secondary);
    color: var(--primary-color);
}

/* Desktop Hover - Restricted to min-width 769px to prevent mobile flickering */
@media (min-width: 769px) {
    .dropdown:hover .dropdown-content {
        display: block;
    }
}

/* Mobile Dropdown adjustment - Modal Style */
@media (max-width: 768px) {
    .dropdown {
        position: static;
    }

    .dropdown-content {
        position: fixed;
        top: 0;
        right: -110%;
        /* Ensure it's fully off-screen */
        width: 85%;
        max-width: 320px;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
        border-left: 1px solid var(--border-color);
        box-shadow: none;
        transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.4s;
        display: block !important;
        visibility: hidden;
        z-index: 11000;
        padding-top: env(safe-area-inset-top, 0);
        margin-top: 0;
        /* Reset desktop margin */
        background-color: var(--bg-color);
        /* Ensure solid background */
        backdrop-filter: none !important;
        /* Explicitly disable any blur on the menu itself */
        filter: none !important;
    }

    .dropdown-content.active {
        right: 0;
        visibility: visible;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
        animation: none;
        /* Disable desktop animation */
    }

    /* Mobile Overlay */
    .menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 500;
        /* High, but lower than header (1000) */
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .menu-overlay.active {
        display: block;
        opacity: 1;
    }

    .dropdown-content .menu-view {
        padding: 1.5rem 0.5rem;
    }

    .dropdown-content a {
        padding: 14px 20px;
        font-size: 1rem;
        border-radius: 12px;
        margin: 2px 8px;
    }
}

/* Modal Styles */
.modal {
    display: none;
    /* Hidden by default */
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow: auto;
    transition: all 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--bg-color);
    margin: auto;
    padding: 3rem;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    animation: modal-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.close-modal {
    color: var(--text-muted);
    position: absolute;
    right: 2rem;
    top: 2rem;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    color: var(--text-color);
    background: var(--border-color);
    transform: rotate(90deg);
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    background: var(--bg-secondary);
    padding: 6px;
    border-radius: 12px;
    margin-bottom: 2.5rem;
}

.auth-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 0.8rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.95rem;
    transition: all 0.3s ease;
    border-radius: 8px;
    text-align: center;
}

.auth-tab.active {
    background: var(--bg-color);
    color: var(--primary-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.auth-tab:hover:not(.active) {
    color: var(--text-color);
}

/* Forms */
.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
    animation: fade-in 0.3s ease-out;
}

.auth-form h2 {
    margin-bottom: 2rem;
    font-size: 1.8rem;
    text-align: center;
    color: var(--text-color);
    letter-spacing: -0.5px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.6rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid transparent;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    background: var(--bg-secondary);
    color: var(--text-color);
    transition: all 0.2s ease;
}

.form-group input:focus {
    outline: none;
    background: var(--bg-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--accent-color);
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    gap: 1rem;
}

.form-actions a {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-decoration: none;
    transition: color 0.2s;
}

.form-actions a:hover {
    color: var(--primary-color);
}

.form-actions button[type="submit"],
.auth-form button[type="submit"] {
    background: var(--primary-color);
    color: white;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-grow: 1;
    font-size: 1rem;
    letter-spacing: 0.5px;
}

.form-actions button[type="submit"]:hover,
.auth-form button[type="submit"]:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Recaptcha Container */
.g-recaptcha {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-color);
    color: var(--text-color);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-left: 4px solid var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    pointer-events: auto;
    animation: toast-slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.3s ease;
}

.toast.success {
    border-left-color: #2d6a4f;
}

.toast.error {
    border-left-color: #e63946;
}

.toast.info {
    border-left-color: #457b9d;
}

.toast.fade-out {
    opacity: 0;
    transform: translateX(20px);
}

@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}