/* General Dark Mode Variables & Base */
:root {
    /* Keep all your dark mode variables here. This is correct. */
    --dark-bg-primary: #1a1a1a;
    --dark-bg-secondary: #222222;
    --dark-card-bg: #282828;
    --dark-border-color: #333;
    --dark-text-primary: #e0e0e0;
    --dark-text-secondary: #b0b0b0;
    --dark-text-muted: #888;
    --dark-accent-green: #58d68d;
    --dark-accent-green-hover: #4ac77c;
    --dark-input-bg: #282828;
    --dark-input-border: #444;
    --dark-input-placeholder: #888;
    --dark-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --dark-card-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    --dark-hover-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);

    /* Additional variables you might have from style.css's :root definitions */
    --dl-color-theme-neutral-dark: #000000; /* Ensure this is properly handled if you have light mode still */
    --dl-color-theme-neutral-light: #FFFFFF; /* Ensure this is properly handled if you have light mode still */
    /* ... all other --dl- variables from your style.css or old footer.html ... */
}

/* ############################################################# */
/* CRITICAL FIX FOR WHITESPACE - COMBINED HTML, BODY, MAIN STYLES */
/* ############################################################# */

html {
    height: 100%; /* Ensure HTML takes full viewport height */
    margin: 0; /* Remove default browser margin */
    padding: 0; /* Remove default browser padding */
    background-color: var(--dark-bg-primary); /* Apply dark background to HTML itself */
    line-height: 1.15; /* From your old default-style-sheet */
    font-family: Inter; /* From your old default-style-sheet */
    font-size: 16px; /* From your old default-style-sheet */
}

body {
    height: 100%; /* Ensure body also takes full viewport height */
    margin: 0; /* Remove default browser margin */
    padding: 0; /* Remove default browser padding */
    display: flex; /* Make body a flex container */
    flex-direction: column; /* Stack children (header, main, footer) vertically */
    min-height: 100vh; /* Ensure body is at least viewport height */
    background-color: var(--dark-bg-primary); /* Apply dark background to body */
    color: var(--dark-text-primary); /* Apply dark text color to body */
    font-family: "Poppins", Arial, sans-serif; /* Your chosen font */
    line-height: 1.6; /* Your chosen line-height */

    /* Remove any conflicting 'color' or 'fill' properties from old stylesheets that might be copied here */
    /* e.g., if you see 'color: var(--dl-color-theme-neutral-dark);' remove it */
    font-weight: 400; /* From your old default-style-sheet */
    font-style: normal; /* From your old default-style-sheet */
    text-transform: none; /* From your old default-style-sheet */
    letter-spacing: normal; /* From your old default-style-sheet */
    fill: var(--dark-text-primary); /* Ensure fill is also dark for SVG icons that inherit body color */
    -webkit-font-smoothing: antialiased; /* From your old default-style-sheet */
    -moz-osx-font-smoothing: grayscale; /* From your computed styles */
}

/* This applies to all elements, from your old default-style-sheet */
* {
    box-sizing: border-box;
    border-width: 0;
    border-style: solid;
}

main {
    flex-grow: 1; /* This makes the <main> element expand to fill any available space */
    display: flex; /* Make main a flex container too */
    flex-direction: column; /* Stack its children vertically */
    background-color: var(--dark-bg-primary); /* Add this line */
}

h1, h2, h3, h4 {
    color: var(--dark-text-primary);
}

a {
    color: var(--dark-accent-green);
}

a:hover {
    color: var(--dark-accent-green-hover);
}

/* Styles specific to the AI Meal Plan Page Content */

.ai-search-section {
    padding: 40px 20px;
    text-align: center;
    background-color: var(--dark-bg-primary);
    border-bottom: 1px solid var(--dark-border-color);
}

.ai-search-section p {
    font-size: 0.95em;
    color: var(--dark-text-secondary);
    margin-bottom: 8px;
}

.ai-search-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    max-width: 600px;
    margin: 0 auto;
}

.ai-search-bar input {
    flex-grow: 1;
    padding: 12px 16px;
    font-size: 16px;
    border-radius: 8px;
    background-color: var(--dark-input-bg);
    color: var(--dark-text-primary);
    border: 1px solid var(--dark-input-border);
    outline: none;
    box-shadow: var(--dark-card-shadow);
}

.ai-search-bar input::placeholder {
    color: var(--dark-input-placeholder);
}

.ai-search-bar input:focus {
    border-color: var(--dark-accent-green);
    box-shadow: 0 0 0 3px rgba(88, 214, 141, 0.4);
}

.ai-search-bar button {
    padding: 12px 24px;
    font-size: 16px;
    background-color: var(--dark-accent-green);
    color: var(--dark-bg-primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: var(--dark-card-shadow);
    transition: background-color 0.3s;
}

.ai-search-bar button:hover {
    background-color: var(--dark-accent-green-hover);
    box-shadow: var(--dark-hover-shadow);
}

#ai-search-output {
    margin-top: 20px;
    font-size: 1.1em;
    color: var(--dark-text-secondary);
}

/* Meal Plan Carousel Section */
.item-carousel-section {
    position: relative; /* CRITICAL: Needed for absolute positioning of external buttons */
    width: 90%;
    margin: 40px auto;
    padding: 30px 20px; /* ORIGINAL: Padding of the outer carousel box */
    border: 2px solid var(--dark-border-color); /* ORIGINAL: Border of the outer carousel box */
    border-radius: 16px; /* ORIGINAL: Border radius of the outer carousel box */
    background-color: var(--dark-bg-secondary); /* ORIGINAL: Background color of the outer carousel box */
    box-shadow: var(--dark-shadow); /* ORIGINAL: Shadow of the outer carousel box */
    /* The display: flex, flex-direction, align-items properties added previously are NOT needed here
       because the buttons are positioned absolutely and the generic-carousel-section is a block element. */
}

button.scroll-button {
    position: absolute;
    top: 50%; /* Center vertically relative to item-carousel-section */
    transform: translateY(-50%);
    z-index: 10;
    font-size: 24px;
    padding: 12px 16px;
    background-color: var(--dark-accent-green);
    color: var(--dark-bg-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--dark-card-shadow);
    transition: background-color 0.3s;
}

button.scroll-button.left {
    left: -30px; /* ORIGINAL: Exact offset from the left edge */
}

button.scroll-button.right {
    right: -30px; /* ORIGINAL: Exact offset from the right edge */
}

button.scroll-button:hover {
    background-color: var(--dark-accent-green-hover);
    box-shadow: var(--dark-hover-shadow);
}

.manual-scroll-wrapper {
    overflow: hidden;
    padding: 10px 0;
}

.manual-scroll-track {
    overflow: hidden; /* Still needed for content hiding */
    display: flex; /* Still needed for card layout */
    overflow-x: auto; /* Still needed for scrolling */
    scroll-behavior: smooth; /* Still needed for smooth scrolling */
    /* All other properties (padding, gap, align-items) will be controlled by carousel.css or the individual cards */
}

.manual-scroll-track::-webkit-scrollbar {
    display: none;
}

.card-text {
    text-align: center;
    margin-top: 10px;
}

.card-text .image-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 6px;
    color: var(--dark-text-primary);
}

.card-text a {
    font-size: 13px;
    color: var(--dark-accent-green);
    text-decoration: none;
}

.card-text a:hover {
    text-decoration: underline;
}

/* Styles for search results cards (from renderMealPlans) */
.meal-plan-search-results-container {
    width: 80%;
    margin: 40px auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.meal-plan-result-card {
    background-color: var(--dark-card-bg);
    border-radius: 16px;
    box-shadow: var(--dark-shadow);
    padding: 24px;
    display: flex;
    gap: 24px;
    align-items: flex-start;
    font-family: 'Inter', sans-serif;
}

.meal-plan-result-card img {
    width: 120px;
    height: 120px;
    border-radius: 12px;
    object-fit: contain;
    background-color: #333; /* Consider making this a variable */
    flex-shrink: 0;
}

.meal-plan-result-card-content h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 12px 0;
    color: var(--dark-text-primary);
}

.meal-plan-result-card-content p {
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--dark-text-secondary);
    margin: 0 0 16px 0;
}

.meal-plan-result-card-content h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 6px 0;
    color: var(--dark-text-primary);
}

.meal-plan-result-card-tags {
    margin: 8px 0 16px 0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.meal-plan-result-card-tags span {
    background-color: #2f6f35; /* Consider making this a variable, e.g., --tag-bg-color */
    color: var(--dark-text-primary);
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 500;
}

.meal-plan-result-card-samples {
    margin: 8px 0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.meal-plan-result-card-samples span {
    background-color: var(--dark-input-bg); /* Reuses input background, which is fine */
    color: var(--dark-text-primary);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); /* Consider making this a variable, e.g., --subtle-shadow */
}

.meal-plan-result-card-details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--dark-accent-green);
    margin-bottom: 10px;
}

.meal-plan-result-card-link {
    display: inline-block;
    background-color: var(--dark-accent-green);
    color: var(--dark-bg-primary);
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: background-color 0.2s ease;
    margin-top: 12px;
}

.meal-plan-result-card-link:hover {
    background-color: var(--dark-accent-green-hover);
}

/* Add this block back to ai-search-page.css (where you removed the previous button styles) */
button.scroll-button {
    position: absolute;
    top: 50%; /* Center vertically relative to item-carousel-section */
    transform: translateY(-50%);
    z-index: 10;
    font-size: 24px;
    padding: 12px 16px;
    background-color: var(--dark-accent-green);
    color: var(--dark-bg-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--dark-card-shadow);
    transition: background-color 0.3s;
}

button.scroll-button.left {
    left: -30px; /* Position outside the box */
}

button.scroll-button.right {
    right: -30px; /* Position outside the box */
}

button.scroll-button:hover {
    background-color: var(--dark-accent-green-hover);
    box-shadow: var(--dark-hover-shadow);
}

/* Responsive adjustments for page content */
@media (max-width: 992px) {
    /* Adjust breakpoint for tablet/smaller desktops */
    /* No header-specific rules here anymore */
}

@media (max-width: 768px) {
    /* No header-specific rules here anymore */
}

@media (max-width: 600px) {
    .meal-plan-result-card {
        flex-direction: column;
        align-items: center;
    }

    .ai-search-bar {
        flex-direction: column;
    }

    .ai-search-bar input {
        width: 100%;
    }

    .ai-search-bar button {
        width: 100%;
    }

    button.scroll-button.left {
        left: 0px;
    }

    button.scroll-button.right {
        right: 0px;
    }
}

/* Ensure focus states are consistent for page elements (excluding header elements) */
input:focus,
button:focus, /* This will apply to all buttons on the page not specifically styled in the header */
summary:focus {
    outline: 3px solid rgba(88, 214, 141, 0.4); /* Using color-mix(in srgb, var(--dark-accent-green) 40%, transparent) is also an option if --dark-accent-green is defined */
    outline-offset: 2px;
}
