/* --- CSS Reset & Variables --- */
:root {
    --primary: #C84A3A;       /* Burnt Coral */
    --bg-main: #FAF9F6;       /* Warm Off-White */
    --bg-card: #FFFFFF;       /* Pure White for cards */
    --accent: #2F6F6A;        /* Muted Teal */
    --text-main: #1F1F1F;
    --text-muted: #5E5E5E;
    
    --radius-lg: 24px;
    --radius-md: 16px;
    --shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 12px 40px rgba(200, 74, 58, 0.15);
}

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

body {
    font-family: 'DM Sans', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

body.app-active {
    overflow: hidden;
    height: 100vh;
}

/* --- UTILITY CLASSES --- */
.hidden { display: none !important; }

/* --- 1. NEW HEADER STYLES --- */
.site-header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    position: fixed; /* Fixed to stay on top */
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    transition: all 0.3s ease; /* Smooth transition for background */
    background: transparent; /* Default Transparent */
}

/* Scrolled State (Added via JS) */
.site-header.scrolled {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

.site-header.scrolled .logo { color: var(--text-main); }

/* Left: Logo */
.logo { 
    font-size: 1.5rem; 
    font-weight: 700; 
    letter-spacing: -0.5px; 
    cursor: pointer;
    color: var(--text-main); 
}
.logo-accent { color: var(--primary); }

/* Center: Global Search */
/* MODIFIED: Hidden by default (Home Page) */
.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* MODIFIED: Visible ONLY when planner-mode class is active */
.site-header.planner-mode .header-center {
    opacity: 1;
    pointer-events: auto;
}

.global-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 350px;
}

.global-search-input {
    width: 100%;
    padding: 10px 20px 10px 40px;
    border-radius: 50px;
    border: 1px solid transparent;
    background: rgba(0, 0, 0, 0.05);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.global-search-input:focus {
    outline: none;
    background: white;
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

/* Icon inside search */
.search-icon-symbol {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    opacity: 0.4;
    pointer-events: none;
}

/* Right: Actions */
.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.icon-btn {
    background: white;
    border: 1px solid #eee;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}
.icon-btn:hover {
    background-color: #f9f9f9;
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.btn-login {
    background: var(--text-main);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-login:hover { background: #333; }

/* Saved Trips Dropdown */
.saved-trips-dropdown {
    position: absolute;
    top: 130%;
    right: 0;
    width: 280px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.12);
    border: 1px solid #eee;
    padding: 10px 0;
    z-index: 200;
    animation: fadeIn 0.2s ease-out;
}

.dropdown-header {
    padding: 5px 20px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    border-bottom: 1px solid #f5f5f5;
}

.saved-trip-item {
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}
.saved-trip-item:hover { background: #f9f9f9; }
.saved-trip-name { font-weight: 600; font-size: 0.95rem; }
.saved-trip-meta { font-size: 0.8rem; color: #888; margin-top: 2px; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- LANDING PAGE STYLES --- */
#landing-view {
    width: 100%;
    min-height: 100vh;
    padding-top: 80px; /* Offset for fixed header */
}

.section { padding: 80px 20px; max-width: 1100px; margin: 0 auto; }
.section-title { text-align: center; font-size: 1.8rem; margin-bottom: 40px; font-weight: 700; }

/* Hero */
.hero { 
    text-align: center; 
    padding: 60px 20px 100px;
    max-width: 900px; 
    margin: 0 auto; 
    position: relative;
}

/* Hero Decor */
.hero-decor {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -40%);
    width: 120%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.4;
}
.dashed-route {
    stroke: var(--accent);
    stroke-width: 2;
    stroke-dasharray: 10, 10;
    fill: none;
    opacity: 0.3;
}
.map-dot {
    fill: var(--bg-main);
    stroke: var(--accent);
    stroke-width: 3;
}

.hero h1 { font-size: 3.5rem; line-height: 1.1; margin-bottom: 16px; position: relative; }
.subtitle { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 50px; position: relative; }

/* Pill Search Bar (Main Input) */
.input-card {
    background: white;
    padding: 10px;
    border-radius: 100px; 
    box-shadow: 0 15px 50px rgba(0,0,0,0.06);
    max-width: 850px;
    margin: 0 auto;
    display: flex; 
    align-items: center;
    border: 1px solid rgba(0,0,0,0.04);
    position: relative;
    z-index: 2;
}

.search-group {
    flex: 1;
    padding: 5px 25px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    text-align: left;
}

.search-group:not(:last-of-type)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 20%;
    height: 60%;
    width: 1px;
    background-color: #E0E0E0;
}

.search-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 800; 
    color: var(--text-main);
    margin-bottom: 2px;
    margin-left: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-control {
    width: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-muted);
    padding: 2px 0;
    cursor: pointer;
    outline: none;
}
.search-control:focus { color: var(--primary); }

.btn-search {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 16px 36px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    margin-left: 10px;
    box-shadow: 0 4px 15px rgba(200, 74, 58, 0.3);
}
.btn-search:hover { 
    background-color: #b03d2f; 
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(200, 74, 58, 0.4);
}

/* Suggestions Dropdown Styles (Landing) */
.suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    z-index: 100;
    padding: 8px 0;
    margin-top: 15px; 
    border: 1px solid #eee;
    max-height: 300px;
    overflow-y: auto;
    text-align: left;
}

.suggestion-item {
    padding: 12px 24px;
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
    color: var(--text-main);
}

.suggestion-item:hover { background-color: #f5f5f5; color: var(--primary); }
.suggestion-item .icon { font-size: 1.1rem; opacity: 0.5; }

/* Hero Extras */
.hero-extras {
    margin-top: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    opacity: 0.8;
}

.suggestion-pill {
    background: rgba(47, 111, 106, 0.08); 
    color: var(--accent);
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.suggestion-pill:hover {
    background: rgba(47, 111, 106, 0.15);
}

.trust-text {
    display: flex;
    align-items: center;
    gap: 6px;
}
.dot-separator { width: 4px; height: 4px; background: #ccc; border-radius: 50%; }

/* Close Button Specifics */
#closePlannerBtn {
    font-size: 1.5rem;
    line-height: 1;
    font-weight: 400;
    /* Red background to distinguish it */
    background: #f0f0f0;
}
#closePlannerBtn:hover {
    background: #e0e0e0;
    color: var(--primary);
}

/* How It Works Cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 24px; }
.card { background: var(--bg-card); border-radius: var(--radius-md); padding: 24px; box-shadow: var(--shadow-soft); }
.step-card { text-align: center; }
.icon-box { font-size: 2rem; margin-bottom: 16px; background: #fdf2f0; width: 60px; height: 60px; line-height: 60px; border-radius: 50%; margin-left: auto; margin-right: auto; }

/* Footer */
footer { background: #f4f4f4; padding: 60px 20px 20px; color: var(--text-muted); margin-top: 60px; }
.footer-content { max-width: 1100px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
.copyright { text-align: center; margin-top: 40px; font-size: 0.8rem; border-top: 1px solid #ddd; padding-top: 20px; }

/* --- 2. PLANNER APP STYLES --- */
#planner-view {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: white;
    padding-top: 70px; /* Space for fixed header */
}

/* App Header styling reused from main header logic */

.split-view {
    display: flex;
    flex: 1;
    height: calc(100vh - 70px);
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 400px;
    background: white;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0,0,0,0.02);
    z-index: 10;
}

.sidebar-section { padding: 25px; border-bottom: 1px solid #f5f5f5; }
.sidebar-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 15px; }

/* Filters */
.filter-tags { display: flex; flex-wrap: wrap; gap: 10px; }
.filter-chip {
    padding: 8px 16px; border-radius: 20px; background: #f0f0f0;
    font-size: 0.85rem; cursor: pointer; user-select: none;
    transition: all 0.2s; border: 1px solid transparent;
}
.filter-chip.active {
    background-color: rgba(47, 111, 106, 0.1);
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 500;
}

.btn-update {
    background: var(--text-main); color: white; border: none;
    padding: 10px; width: 100%; border-radius: 8px; cursor: pointer;
    margin-top: 20px;
}

/* Itinerary List */
.plan-day { margin-bottom: 30px; }
.day-header {
    font-size: 0.9rem; color: var(--accent); text-transform: uppercase;
    font-weight: 700; letter-spacing: 1px; margin-bottom: 15px;
    padding-bottom: 5px; border-bottom: 2px solid #f0f0f0;
}

.plan-item {
    display: flex; gap: 15px; margin-bottom: 15px; padding: 12px;
    background: #FAFAFA; border-radius: 12px; position: relative;
    transition: transform 0.2s;
}
.plan-item:hover { transform: translateX(5px); background: #F5F5F5; }
.plan-time { font-size: 0.8rem; font-weight: 700; color: #999; min-width: 50px; }
.plan-details h4 { font-size: 0.95rem; margin-bottom: 4px; }
.plan-details p { font-size: 0.8rem; color: var(--text-muted); }

.remove-btn {
    position: absolute; top: 10px; right: 10px;
    color: #ccc; cursor: pointer; font-size: 1.2rem; line-height: 0.5;
}
.remove-btn:hover { color: var(--primary); }
.empty-state { text-align: center; color: #999; font-style: italic; padding: 20px;}

/* --- MAP CONTAINER --- */
.map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* Mapbox Marker Custom Styles */
.map-pin {
    display: flex; 
    flex-direction: column; 
    align-items: center;
    cursor: pointer; 
    z-index: 5;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s;
}
.pin-head {
    width: 30px; height: 30px; background: white;
    border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    display: flex; justify-content: center; align-items: center;
    border: 2px solid var(--primary);
}
.pin-icon { transform: rotate(45deg); font-size: 14px; }
.pin-label {
    background: white; padding: 4px 8px; border-radius: 4px;
    font-size: 0.75rem; font-weight: 700; margin-top: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.map-pin:hover { z-index: 10; transform: scale(1.1); } 
.map-pin:hover .pin-label { opacity: 1; }
.map-pin.filtered-out { opacity: 0; pointer-events: none; transform: scale(0); }

.mapboxgl-popup-content {
    border-radius: 12px;
    padding: 10px 15px;
    font-family: 'DM Sans', sans-serif;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* Destinations Section */
.cities-section { padding:30px 20px; max-width:1100px; margin:auto; }
.destinations {
  display:flex; overflow-x:auto; gap:15px; padding-bottom:10px; scroll-snap-type:x mandatory;
}
.destination-card { flex:0 0 auto; text-align:center; width:100px; scroll-snap-align:start; }
.destination-card img {
  width:100px; height:80px; object-fit:cover; border-radius:10px;
}
.destination-card span { display:block; margin-top:8px; font-size:14px; }
.destinations::-webkit-scrollbar { display:none; }
.destination-card:hover { transform: scale(1.05); }

/* Sections */
.section { padding: 20px 20px; max-width: 1100px; margin: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.card {
  background: white; padding: 20px; border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transition: transform 0.3s ease;
}
.card:hover { transform: translateY(-5px); }

/* ========== Mobile Tab Bar ========== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #0077ff;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 3px;
  margin-bottom: 0px;
  border-top: 1px solid #ddd;
  z-index: 3000;
}

.tab-bar a {
  color: white;
  text-decoration: none;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tab-bar a:hover {
  color: #ffcc00;
}

.tab-bar svg {
  width: 20px;
  height: 20px;
  margin-bottom: 4px;
}

/* Hide on desktop */
@media (min-width: 768px) {
  .tab-bar {
    display: none;
  }
}

/* --- MOBILE FIXES (Consolidated) --- */
@media (max-width: 768px) {
    /* Prevent Horizontal Scroll */
    body, html {
        overflow-x: hidden;
        width: 100%;
        position: relative;
    }

    /* Hero & Landing Adjustments */
    .hero {
        padding-top: 18px;
        padding-bottom: 28px;
    }
    
    .hero h1 {
        font-size: 2.2rem; /* Fix huge text */
        line-height: 1.2;
    }

    /* Input Card - Stack items vertically with spacing */
    .input-card {
        flex-direction: column;
        height: auto;
        padding: 20px;
        width: 100%;
        border-radius: 20px;
    }
    
    .search-group {
        width: 100%;
        border-bottom: 1px solid #eee;
        padding: 10px 0;
        margin-bottom: 5px;
    }

    .search-group:last-of-type {
        border-bottom: none;
    }
    
    .btn-search {
        width: 100%;
        margin-top: 15px;
        margin-left: 0;
        padding: 14px;
    }

    /* Planner View Mobile Layout */
    .split-view {
        flex-direction: column-reverse; /* Map on top, Sidebar on bottom */
        height: calc(100vh - 60px); /* Adjust for smaller header */
    }

    .map-container {
        height: 50vh; /* Fixed height for map */
        width: 100%;
        flex: none;
    }

    .sidebar {
        height: 50vh; /* Remaining height */
        width: 100%;
        border-right: none;
        border-top: 2px solid #eee;
    }

    /* Destination Cards Horizontal Scroll Container */
    .destinations {
        padding-bottom: 20px; /* Space for scrollbar/touch */
        padding-left: 10px;
        padding-right: 10px;
        gap: 1px;
        -webkit-overflow-scrolling: touch;
    }
    
    .destination-card {
        width: 120px; /* Slightly larger touch target */
    }

    /* Footer spacing for Tab Bar */
    footer {
        padding-bottom: 80px; /* Prevent tab bar overlap */
    }

    /* Header Mobile adjustments */
    .site-header {
        padding: 0 15px;
    }
    
    /* Ensure modals/popups are centered on mobile */
    #installPopup > div, #iosPopup > div {
        width: 90%;
        max-width: 300px;
    }

    /* Mobile Header - Button Hiding */
    .header-right .btn-login, 
    .header-right #savedTripsBtn {
        display: none !important;
    }

    /* Fix Saved Trips Dropdown for Mobile (Center it) */
    .saved-trips-dropdown {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) !important;
        width: 85%;
        max-height: 50vh;
        overflow-y: auto;
        box-shadow: 0 0 0 1000px rgba(0,0,0,0.5); /* Dim background */
    }

    /* Tab Bar Visibility & Map Overlap Fix */
    .tab-bar {
        z-index: 9999 !important; /* Ensure on top of map */
        background: #ffffff;
        border-top: 1px solid #eee;
        padding-bottom: env(safe-area-inset-bottom); /* iOS Safe Area */
    }
    
    .tab-bar a {
        color: var(--text-muted); /* Match theme */
    }
    
    /* Ensure Map doesn't get hidden behind tab bar */
    #planner-view {
        padding-bottom: 70px; 
    }
    
    /* Force Map container to respect tab bar space */
    .map-container {
        height: calc(55% - 60px) !important; /* Adjust specific mobile height */
    }

    /* Header Right Container */
    .header-right {
        display: flex !important;
        align-items: center;
        min-width: 50px; /* Reserve space for the button */
        justify-content: flex-end;
        gap: 0; /* Remove gap since other buttons are hidden */
    }

    /* Force Close Button visibility and prevent squashing */
    #closePlannerBtn {
        /* Ensure it's not hidden if the 'hidden' class is removed */
        display: flex; 
        flex-shrink: 0; /* Prevent it from shrinking to 0 width */
        width: 40px;
        height: 40px;
        background: #f5f5f5 !important; /* Light grey background to stand out */
        color: #333;
        z-index: 1100; /* Ensure it sits on top of everything */
        border-radius: 50%;
        justify-content: center;
        align-items: center;
        font-size: 1.5rem;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }
    
    /* Hide the wrapper div of Saved Trips to remove extra spacing */
    .header-right > div:has(#savedTripsBtn) {
        display: none !important;
    }
    
    /* Fallback if :has isn't supported (Hide Saved button specifically) */
    #savedTripsBtn {
        display: none !important;
    }
    
    /* Ensure only the active close button shows */
    #closePlannerBtn.hidden {
        display: none !important;
    }
     #closePlannerBtn {
        display: none !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* 3️⃣ Header Logo: Force Centering */
    .site-header {
        display: flex !important;
        justify-content: center !important; /* Centers the Logo */
        position: fixed !important; /* Ensure it stays pinned */
        top: 0; left: 0; right: 0;
        padding: 0 15px !important;
    }

    .logo {
        position: absolute !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        z-index: 20 !important;
        margin: 0 !important;
    }

    /* Keep Header Actions (Saved/Profile) to the Right */
    .header-right {
        position: absolute !important;
        right: 15px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
    }

    /* Adjust Map Container to not be hidden behind Tab Bar */
    #planner-view {
        height: 100vh !important;
        padding-bottom: 60px !important; /* Space for Tab Bar */
    }
}
/* --- RESPONSIVE FOOTER STYLES --- */
.site-footer {
    background-color: #1a1a1a;
    color: #e0e0e0;
    padding-top: 60px;
    font-size: 0.95rem;
    margin-top: 0; /* Removes default margin */
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 0 20px 40px;
    gap: 40px;
}

.footer-col {
    flex: 1;
    min-width: 220px;
}

.footer-col h3 {
    color: #fff;
    font-size: 1.2rem;
    margin-bottom: 20px;
    font-weight: 700;
}

/* About Section */
.footer-col.about p {
    line-height: 1.6;
    color: #ccc;
    max-width: 300px;
}

/* Links Section */
.footer-col.links ul {
    list-style: none;
    padding: 0;
}

.footer-col.links li {
    margin-bottom: 12px;
}

.footer-col.links a {
    color: #ccc;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-col.links a:hover {
    color: var(--primary, #C84A3A); /* Uses your existing primary color variable */
    padding-left: 5px;
}

/* Contact Section */
.footer-col.contact p {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ccc;
}

/* Social Section */
.social-icons {
    display: flex;
    gap: 15px;
}

.social-icons a {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 50%;
    text-decoration: none;
    transition: all 0.3s ease;
}

.social-icons a:hover {
    background: var(--primary, #C84A3A);
    transform: translateY(-3px);
}

/* Bottom Bar */
.footer-bottom {
    background-color: #111;
    text-align: center;
    padding: 20px;
    border-top: 1px solid #333;
    font-size: 0.85rem;
    color: #888;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .footer-container {
        flex-direction: column;
        gap: 30px;
    }
    
    .footer-col {
        width: 100%;
        text-align: left;
    }
    
    .social-icons {
        justify-content: flex-start;
    }
}