/* --- Global Resets & Variables --- */
:root {
    --primary-color: #1a73e8; /* Google Blue */
    --secondary-color: #f8f9fa; /* Light Grey */
    --text-color: #3c4043;
    --border-color: #dadce0;
    --shadow-color: rgba(60, 64, 67, 0.15);
    --sidebar-width-desktop: 380px;
    --top-ad-height-desktop: 250px;
    --top-ad-height-mobile: 250px;
    --sidebar-ad-top-height: 280px;
    --sidebar-ad-bottom-height-desktop: 250px;
    --sidebar-ad-bottom-height-mobile: 250px;
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Roboto', Arial, sans-serif; /* More modern font */
}

html, body {
    height: 100%;
    /* overflow: hidden; */ /* Removed to allow scrolling on mobile */
    color: var(--text-color);
}

/* --- Base Layout --- */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
    overflow: hidden; /* Prevent body scroll with columns */
}

/* --- Loading Overlay --- */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* Highest */
    transition: opacity var(--transition-speed) ease-in-out;
    opacity: 1;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#loading-overlay .spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

#loading-overlay p {
    font-size: 1.2em;
    color: var(--text-color);
}

/* --- Sidebar --- */
#sidebar {
    width: var(--sidebar-width-desktop);
    height: 100%;
    background-color: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10; /* Above map, below overlay */
    transition: width var(--transition-speed) ease;
    box-shadow: 2px 0 5px var(--shadow-color);
    flex-shrink: 0; /* Prevent shrinking */
}

.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.logo {
    font-size: 1.8em;
    font-weight: bold;
    color: var(--primary-color);
    text-align: center;    
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

/* --- Controls Section --- */
.controls-section {
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 15px;
    position: relative; /* For positioning the button */
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #5f6368;
    font-size: 0.9em;
}

.input-group label i {
    margin-right: 8px;
    color: var(--primary-color);
}

.input-group input[type="text"] {
    width: 100%;
    padding: 12px 40px 12px 15px; /* Space for icon button */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.input-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

#use-location-btn {
    position: absolute;
    right: 1px;
    top: 30px; /* Adjust based on label height */
    height: calc(100% - 31px); /* Adjust */
    width: 40px;
    background: none;
    border: none;
    border-left: 1px solid var(--border-color);
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    color: #5f6368;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

#use-location-btn:hover {
    background-color: #f1f3f4;
    color: var(--primary-color);
}

.travel-modes {
    display: flex;
    justify-content: space-around;
    margin-top: 10px;
    margin-bottom: 10px;
    padding: 5px 0;
    background-color: #f8f9fa;
    border-radius: 4px;
}

.travel-mode-btn {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 1.1em;
    transition: color 0.2s ease, background-color 0.2s ease;
    border-radius: 4px;
}

.travel-mode-btn:hover {
    color: #495057;
    background-color: #e9ecef;
}

.travel-mode-btn.active {
    color: #007bff;
    background-color: #e7f1ff;
}

#get-directions-btn {
    background-color: gray;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    transition: background-color var(--transition-speed), box-shadow var(--transition-speed);
    text-align: center;
    margin-top: 10px; /* Add some space */
}

#get-directions-btn:hover {
    background-color: #185abc;
    box-shadow: 0 1px 3px var(--shadow-color);
}

#get-directions-btn:disabled {
    background-color: #d1e3ff;
    cursor: not-allowed;
}

/* Spinner next to Search button */
.directions-spinner {
    display: none; /* Hidden by default */
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
    margin: 10px auto 0 auto; /* Center below button */
}

.error-message {
    color: #d93025; /* Google Red */
    padding: 10px 0;
    font-size: 0.9em;
    display: none; /* Hidden by default */
    text-align: center;
    margin-top: 5px;
}

/* --- Ad Placeholders --- */
.ad-sidebar {
    background-color: #f1f3f4;
    border: 1px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #80868b;
    font-size: 0.9em;
    text-align: center;
    margin: 10px 0;
    border-radius: 8px;
}

.ad-sidebar-top {
    min-height: calc(var(--sidebar-ad-top-height) + 10px); /* Use variable + 30px */
}

.ad-sidebar-bottom {
    min-height: var(--sidebar-ad-bottom-height-desktop);
}

.ad-top {
    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    min-height: var(--top-ad-height-desktop);
    max-height: 300px; /* Set a max-height large enough for 250px ad + padding/border */
    background-color: #f1f3f4;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #80868b;
    transition: max-height var(--transition-speed) ease, border var(--transition-speed) ease, padding var(--transition-speed) ease, margin var(--transition-speed) ease; /* Animate max-height */
    overflow: hidden; /* Keep overflow hidden */
    flex-shrink: 0;
}

/* Ensure inner ad placeholder divs fill the .ad-top container */
.ad-top > .ad-desktop-only,
.ad-top > .ad-mobile-only {
    width: 100%;
    height: 100%;
    /* display: flex is already set on these classes, which is fine */
}

/* Collapsed state for top ad */
.ad-top.collapsed {
    max-height: 0; /* Collapse using max-height */
    border-bottom-width: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    min-height: 0px;
}

/* Toggle button styling */
.ad-toggle-btn {
    position: absolute; /* Keep button absolute relative to ad-top */
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    background-color: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 2px 10px;
    cursor: pointer;
    z-index: 6;
    font-size: 0.9em;
    color: #5f6368;
    line-height: 1;
    transition: background-color var(--transition-speed);
}

.ad-toggle-btn:hover {
    background-color: #f1f3f4;
}

/* Rotate arrow when collapsed */
.ad-top.collapsed .ad-toggle-btn i {
    transform: rotate(180deg);
}

/* Hide/Show specific ad sizes */
.ad-desktop-only {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}
.ad-mobile-only {
    display: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

/* --- Directions Panel --- */
#directions-panel {
    margin-top: 10px; /* Reduced margin as time is above */
    /* border-top: 1px solid var(--border-color); */ /* Border now above time */
    padding-top: 10px;
    flex-grow: 1; /* Takes remaining space */
    /* Style Google's directions output if needed */
}

.travel-time {
    font-size: 1.1em;
    font-weight: 500;
    color: var(--primary-color);
    padding: 10px 0;
    margin-top: 15px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    display: none; /* Hide initially */
}

/* --- Main Content (Map Area) --- */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* New wrapper for map + overlay (REMOVED) */
/*
.map-area-wrapper {
    flex-grow: 1;
    position: relative;
    display: flex;
    min-height: 150px;
    padding: 15px;
    overflow: hidden;
}
*/

#map {
    flex-grow: 1; /* Let map fill space below ad */
    background-color: #e0e0e0;
    width: 100%;
    /* height: 100%; */ /* Height is determined by flex-grow */
    min-height: 150px; /* Add back min-height for map */
    z-index: 0; /* Ensure map is below overlay */
}

/* --- Map Overlay (User Info & Quick Links) --- */
#map-overlay {
    position: absolute;
    /* top: 0; */ /* Top will be set by JS */
    left: 15px; /* Position from left edge of main-content */
    /* padding: 15px; */ /* Padding removed */
    top: calc(var(--top-ad-height-desktop) + 35px); /* Set initial top based on default ad height */
    z-index: 6;
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* pointer-events: none; */ /* Removed for now */
    transition: top var(--transition-speed) ease; /* Restore transition */
}

/* Allow interaction with elements inside the overlay (REMOVED) */
#map-overlay > * { pointer-events: auto; }

#user-info-box {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 1px 4px var(--shadow-color);
    font-size: 0.9em;
    backdrop-filter: blur(5px); /* Fancy blur */
    border: 1px solid rgba(218, 220, 224, 0.5); /* Subtle border */
}

#user-info-box p {
    margin-bottom: 5px;
    display: flex;
    align-items: center;
}

#user-info-box p:last-child {
    margin-bottom: 0;
}

#user-info-box i {
    margin-right: 8px;
    color: var(--primary-color);
    width: 15px; /* Align icons */
    text-align: center;
}

#quick-links {
    display: flex;
    gap: 8px;
}

.quick-link-btn {
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(218, 220, 224, 0.5);
    border-radius: 20px; /* Pill shape */
    padding: 8px 15px;
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-color);
    box-shadow: 0 1px 3px var(--shadow-color);
    transition: all var(--transition-speed) ease;
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
}

.quick-link-btn i {
    margin-right: 6px;
    color: var(--primary-color);
}

.quick-link-btn:hover {
    background-color: white;
    border-color: #c2c4c6;
    box-shadow: 0 2px 5px var(--shadow-color);
}

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

/* --- Responsive Design --- */
@media (max-width: 1024px) { /* Adjust breakpoint for 3 columns */
    #results-column {
        width: 300px; /* Shrink results column */
    }
}

/* --- Results Column (Desktop/Base) --- */
#results-column {
    width: 380px; 
    height: 100vh; 
    background-color: #fff;
    border-left: 1px solid #ccc;
    display: flex;
    flex-direction: column;
    position: relative; 
    z-index: 5; 
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

#place-list-display {
    flex-grow: 1;
    overflow-y: auto; 
    padding: 15px; 
    min-height: 0;
}

/* --- Mobile Layout --- */
@media (max-width: 768px) {
    html, body {
        height: auto;
        overflow-y: auto;
    }
    
    .app-container {
        flex-direction: column;
        height: auto;
        overflow: visible; 
    }

    #sidebar {
        width: 100%;
        height: auto;
        order: 1; /* Controls/Search First */
        border-bottom: 1px solid var(--border-color);
        border-right: none;
        box-shadow: none;
        flex-shrink: 0; 
    }
    
    #results-column {
        width: 100%; 
        height: auto; /* Override desktop height */
        order: 2; /* Results Second */
        border-left: none; 
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        border-top: none; 
        max-height: 60vh; /* Limit height */
        overflow: hidden; /* Column itself should NOT scroll */
        box-shadow: none; 
        z-index: auto; /* Reset z-index */
        display: none; /* Mobile hidden initially */
        flex-direction: column; /* Ensure direction is column */
        background-color: #f8f9fa; 
    }
    
    #place-list-display {
        flex-grow: 1; /* Take space within results-column */
        overflow-y: auto; /* THIS scrolls on mobile */
        padding: 15px; 
        min-height: unset; /* Override base min-height */
        flex-grow: 1; /* Ensure it still grows on mobile */
        overflow-y: auto; /* Ensure it scrolls on mobile */
    }

    .main-content {
        order: 3; /* Map Third */
        width: 100%;
        min-height: 45vh; 
        flex-grow: 1; 
        display: flex; 
        flex-direction: column;
    }
    
    #map {
        flex-grow: 1; 
        min-height: 300px; 
    }

    /* Keep other mobile rules */
    .ad-desktop-only { display: none; } 
    .ad-mobile-only { display: flex; } 
    .ad-top { min-height: var(--top-ad-height-mobile); }
    .ad-sidebar-bottom { min-height: var(--sidebar-ad-bottom-height-mobile); }
    #map-overlay { /* ... keep styles ... */ }
}

/* --- Consolidated Place List Item Styling (Apply Generally) --- */

.place-list-container h4 { /* Assuming this class is added by JS */
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.1em;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.place-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.place-list li {
    display: flex; 
    flex-direction: column; /* Stack top and actions */
    border-bottom: 1px solid #eee;
    padding: 12px 0;
}
.place-list li:last-child { border-bottom: none; }

.top-section { /* Wrapper for photo and details */
    display: flex;
    align-items: flex-start;
    gap: 10px; 
    margin-bottom: 10px; /* Space below top section */
    width: 100%; 
}

.place-photo {
    width: 80px;
    height: 80px;
    background-size: cover;
    background-position: center;
    border-radius: 4px;
    flex-shrink: 0;
    background-color: #f0f0f0;
}

.place-details {
    flex-grow: 1;
}

.place-name {
    font-weight: bold;
    display: block;
    margin-bottom: 4px;
    color: #333;
    white-space: normal;
    word-break: break-word;
}

.place-rating {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 4px;
    display: inline-block; /* Keep rating and distance together */
}

.place-rating .star {
    color: #FBBC04;
}

.place-address {
    font-size: 0.9em;
    color: #555;
    line-height: 1.3;
    display: block;
    margin-bottom: 4px;
    white-space: normal;
    word-break: break-word;
}

.place-distance {
    font-size: 0.85em;
    color: #888;
    font-style: italic;
    margin-left: 4px; /* Space before distance */
    display: inline-block; /* Keep inline with rating */
}

.place-actions { /* Wrapper for the button */
    width: 100%;
    margin-top: 0; /* Spacing handled by top-section margin */
    text-align: right;
}

.get-place-directions-btn { /* Button itself */
    display: inline-block;
    padding: 6px 12px;
    background-color: #4285F4;
    color: white;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.85em;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.get-place-directions-btn:hover {
    background-color: #357ae8;
}

.ad-list-item { /* Styles for ad list item */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
    background-color: #f9f9f9;
    margin-left: -5px; /* Adjust if needed based on parent padding */
}

.ad-list-item div { /* Styles for ad placeholder */
    max-width: 100%;
}

/* --- End Consolidated Place List Item Styling --- */

/* Ensure no other conflicting styles below */

/* --- Footer Styles --- */
footer {
    background-color: var(--secondary-color, #f8f9fa); /* Use variable or fallback */
    color: var(--text-color, #3c4043);
    padding: 15px 20px;
    border-top: 1px solid var(--border-color, #dadce0);
    text-align: center;
    font-size: 0.9em;
    position: relative; /* Needed if app-container has overflow: hidden */
    z-index: 5; /* Below sidebar/map but visible */
}

footer p {
    margin-bottom: 5px;
}

footer nav a {
    color: var(--primary-color, #1a73e8);
    text-decoration: none;
    margin: 0 5px;
}

footer nav a:hover {
    text-decoration: underline;
}

/* --- Logo Image Style --- */
#logo-container img {
    display: block; /* Helps with centering */
    max-height: 50px; /* Control image height */
    width: auto; /* Maintain aspect ratio */
    margin: 0 auto; /* Center horizontally */
    padding-bottom: 10px; /* Match original logo padding */
}