/* HOME PAGE LAYOUT */

/* Main Grid Wrapper */
.home-layout {
    /* Desktop layout is a two-column grid */
    display: grid;
    grid-template-columns: 1fr 1fr; 
    gap: 40px;
    max-width: 1200px;
    
    /* Center the layout and set top margin */
    margin: 20px auto 0 auto; 
    padding: 0 20px;
    align-items: stretch; /* Ensures columns stretch to the full height */
    
    /* Let the layout consume all remaining space under the navbar */
    flex: 1; 
    min-height: 0; 
    /* Allow the layout itself to scroll if the content still exceeds the viewport */
    overflow-y: auto; 
}

/* Left Column Stack (Hero Bubble) */
.home-left-col {
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* --- NEW GROUPED BUBBLE FOR SEARCH & CAROUSEL (Right Side) --- */
.search-and-carousel-group {
    /* This container holds the database search box and the restaurant carousel */
    width: 100%;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* Fixed header for the database search section */
.fixed-db-header {
    padding-bottom: 20px; 
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0; /* Ensures the header doesn't shrink when the carousel grows */
}

/* Style for the carousel section wrapper */
.carousel-section {
    /* Overrides the margin-top: 20px inline style */
    margin-top: 0 !important; 
    flex: 1; /* KEY: This allows the carousel section to grow and fill the remaining height */
    min-height: 0;
    
    /* Re-add the separation spacing */
    padding-top: 20px; 
}


/* The "Bubble" Card Style (shared base style) */
.bubble-card {
    background: white;
    border-radius: 16px; 
    padding: 30px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); 
    border: 1px solid #f0f0f0;
    
    /* Must use flex to fill the vertical space of the column */
    flex: 1;
    min-height: 0;
}

/* Styling the "Find Food" Bubble Content */
.hero-bubble h1 {
    margin-top: 0;
    color: #2E7D32;
    font-size: 1.8em;
}
.hero-bubble p {
    color: #666;
    margin-bottom: 20px;
}
.hero-inputs {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.input-group label {
    font-weight: bold;
    color: #555;
    display: flex;
    justify-content: space-between;
}

/* === CAROUSEL STYLES === */
.carousel-wrapper {
    position: relative; /* Context for absolute arrows */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0; 
    
    flex-grow: 1; 
    min-height: 0; 
    padding: 0 50px; /* Space for the absolute arrows */
}

/* My single-card container. This is locked by the parent max-width. */
.restaurant-frame-container {
    /* FIX: Setting a definite height here is CRITICAL for the flex-column scroll fix */
    height: 500px; /* I changed this from 500px to 600px for a better desktop height */
    flex-grow: 1; 
    width: 400px; /* Stretch to fill the carousel wrapper */
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    background: white;
    border: 1px solid #ddd;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Hide anything outside the border radius */
}

/* The actual card structure is built by JS inside the container */
.restaurant-frame {
    width: 100%; 
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- Arrow Styling: Absolute Positioning --- */
.nav-arrow {
    position: absolute; 
    z-index: 10; 

    background: #e0e0e0; border: none; border-radius: 50%; width: 50px; height: 50px; 
    font-size: 1.5em; cursor: pointer; color: #555; transition: background 0.2s;
    display: flex; align-items: center; justify-content: center;
    top: 50%; 
    transform: translateY(-50%);
}
#prevRestBtn {
    left: 0; 
}
#nextRestBtn {
    right: 0; 
}
.nav-arrow:hover { background: #d5d5d5; }

/* The restaurant card header (fixed at the top) */
.frame-header {
    background: #2E7D32; color: white; padding: 20px; text-align: center;
    flex-shrink: 0; /* CRITICAL: Must not shrink so the body can take the rest of the space */
}
.frame-header h2 { margin: 0; font-size: 1.5em; }

/* The restaurant card body (scrolling content area) */
.frame-body {
    flex: 1; /* CRITICAL: Takes up all available vertical space */
    overflow-y: scroll; /* KEY: Only this body section scrolls when content overflows */
    padding: 20px;
}

/* --- Menu Item Layout --- */
.menu-item-row {
    display: flex; 
    flex-direction: column;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    gap: 5px; 
}
.menu-item-name {
    word-wrap: break-word; 
    overflow-wrap: break-word;
    font-weight: bold;
    color: #333;
}

/* Container for all visual stats (bars) */
.menu-item-stats.visual-stats {
    display: flex;
    flex-direction: column;
    gap: 4px; 
    padding: 0;
    background: none;
    border-radius: 0;
    min-width: 0;
}

/* Grouping for a single bar (Label + Bar) */
.nutrition-bar-group {
    width: 100%;
}
.bar-label {
    font-size: 0.8em;
    color: #555;
    margin-bottom: 2px;
}
.bar-container {
    height: 12px;
    background-color: #f0f0f0; 
    border-radius: 6px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    transition: width 0.3s ease-in-out;
}

/* --- Bar Colors --- */
.protein-bar .bar-fill {
    background-color: #EF5350; 
}
.calorie-bar .bar-fill {
    background-color: #66BB6A; 
}


.empty-state {
    display: flex; justify-content: center; align-items: center; 
    width: 100%; 
    height: 100%; 
    color: #888; 
    font-size: 1.2em;
}

/* === MOBILE MEDIA QUERY === */
@media (max-width: 1000px) { 
    .home-layout {
        /* Switch to a single column stack on mobile */
        grid-template-columns: 1fr;
        flex: unset; /* Revert flex on mobile */
        margin: 40px auto; /* Revert margin to original spacing on mobile */
        height: auto;
    }
    .restaurant-frame-container {
        /* Keep the specific height for the scroll logic on smaller screens */
        height: 500px;
    }
    .home-left-col, .search-and-carousel-group {
        max-width: 80vw; 
        padding: 0 20px; 
        margin: 0;
    }
    .carousel-wrapper {
        padding: 0 20px;
    }
    #prevRestBtn { left: 10px; }
    #nextRestBtn { right: 10px; }
}
