@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Outfit:wght@300;500;700&display=swap');

:root {
    --md-sys-color-primary: #3f51b5;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-secondary: #009688;
    --md-sys-color-surface: #fef7ff;
    --md-sys-color-surface-container: #f3edf7;
    --md-sys-color-on-surface: #1d1b20;
    --md-sys-color-on-surface-variant: #49454f;
    --md-sys-color-outline: #79747e;
    --md-sys-color-emerald: #4caf50;
    --md-sys-color-amber: #ffc107;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    overflow: hidden;
    /* iOS Safari: use -webkit-fill-available as fallback */
    height: 100vh;
    height: -webkit-fill-available;
    height: 100dvh;
}

h1, h2, h3 {
    font-family: 'Outfit', sans-serif;
}

#app-container {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column-reverse;
    flex-direction: column-reverse;
    /* iOS Safari viewport height fix */
    height: 100vh;
    height: -webkit-fill-available;
    height: 100dvh;
}

#map {
    height: 45vh;
    height: 45dvh;
    width: 100%;
    z-index: 1;
    /* Required for Leaflet touch on iOS */
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

#sidebar {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    height: 55vh;
    height: 55dvh;
    background: var(--md-sys-color-surface);
    border-top: 1px solid var(--md-sys-color-outline);
    z-index: 2;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    /* Smooth overscroll on iOS */
    -webkit-overflow-scrolling: touch;
    /* Safe area for home indicator on modern iPhones */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Desktop Layout */
@media (min-width: 768px) {
    #app-container {
        display: grid;
        grid-template-columns: 420px 1fr;
        height: 100vh;
        height: 100dvh;
    }

    #map {
        height: 100vh;
        height: 100dvh;
    }

    #sidebar {
        height: 100vh;
        height: 100dvh;
        border-right: 1px solid var(--md-sys-color-outline);
        border-top: none;
        box-shadow: 2px 0 12px rgba(0,0,0,0.05);
        padding-bottom: 0;
    }
}

/* Sidebar Scrollable Area */
.tab-content {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* iOS smooth scroll */
    padding: 1rem;
    scrollbar-width: thin; /* Firefox only */
    scrollbar-color: var(--md-sys-color-primary) transparent; /* Firefox only */
}

.tab-content::-webkit-scrollbar {
    width: 6px;
}

.tab-content::-webkit-scrollbar-thumb {
    background-color: var(--md-sys-color-primary);
    border-radius: 10px;
}

/* Sidebar */
/* Tabs */
.tabs {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    background: var(--md-sys-color-surface);
    padding: 0.5rem;
    /* gap fallback for Safari < 14.1 */
    gap: 0.5rem;
    border-bottom: 1px solid var(--md-sys-color-outline);
}

.tab-btn {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    /* gap fallback: use padding instead for older Safari */
    gap: 0.5rem;
    padding: 0.75rem;
    border: none;
    background: transparent;
    border-radius: 100px;
    -webkit-border-radius: 100px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
    -webkit-transition: all 0.2s;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: var(--md-sys-color-surface-container);
}

.tab-btn.active {
    background: var(--md-sys-color-primary);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.itinerary-section {
    padding: 0; /* Handled by tab-content padding */
}

/* Preparation Checklist */
.prep-item {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--md-sys-color-surface-container);
}

.prep-header {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.prep-header span {
    color: var(--md-sys-color-primary);
    font-size: 1.25rem;
}

.prep-header h4 {
    font-size: 1rem;
    font-weight: 600;
}

.prep-content {
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.5;
}

.brand {
    padding: 2.5rem 2rem;
    background: linear-gradient(135deg, #3f51b5 0%, #1a237e 100%);
    color: white;
}

.brand h1 {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.brand p {
    opacity: 0.8;
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

/* Itinerary List */
.itinerary-section {
    padding: 1.5rem;
}

.day-card {
    background-color: #1a1a1a;
    background-size: cover;
    background-position: center;
    border-radius: 16px;
    -webkit-border-radius: 16px;
    padding: 1.5rem 1.25rem;
    margin-bottom: 1rem;
    -webkit-transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: end;
    -webkit-align-items: flex-end;
    align-items: flex-end;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    min-height: 140px;
    color: white;
}

.day-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.8) 100%);
    z-index: 1;
}

.day-card:hover {
    -webkit-transform: translateY(-4px);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.day-card.active {
    box-shadow: 0 0 0 3px var(--md-sys-color-primary);
}

.day-info {
    flex: 1;
    z-index: 2;
    position: relative;
}

.day-number {
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.day-title {
    font-weight: 700;
    font-size: 1.2rem;
    margin: 0.1rem 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.day-date {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* Map */
#map {
    height: 100%;
    width: 100%;
}

/* POI Details - Elevated Sheet */
#poi-details {
    padding: 1.5rem;
    background: white;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    margin-top: auto;
}

.poi-card {
    animation: fadeIn 0.3s ease;
}

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

.poi-image {
    width: 100%;
    height: 180px;
    border-radius: 16px;
    object-fit: cover;
    margin-bottom: 1.25rem;
}

.poi-tag {
    background: var(--md-sys-color-primary);
    color: white;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.btn-primary {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--md-sys-color-primary);
    color: white;
    border: none;
    border-radius: 12px;
    -webkit-border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

/* Map Popups */
.leaflet-popup-content-wrapper {
    border-radius: 12px !important;
    padding: 5px !important;
}

.leaflet-popup-content {
    font-family: 'Inter', sans-serif !important;
    font-weight: 500 !important;
}

/* Modal — Side Panel (does not cover map) */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    /* Mobile: bottom sheet over lower half */
    left: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    max-height: 90vh;
    background-color: transparent;
}

.modal.active {
    display: flex;
    align-items: flex-end;
}

.modal-content {
    background-color: white;
    padding: 0;
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-height: 88vh;
    max-height: 88dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* iOS smooth scroll */
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.25);
    position: relative;
    animation: modalSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    /* Safe area for home indicator on notch iPhones */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Desktop: panel anchored to sidebar column, map untouched */
@media (min-width: 768px) {
    .modal {
        left: 0;
        bottom: 0;
        width: 420px;
        height: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        align-items: flex-end;
        background: transparent;
    }

    .modal-content {
        border-radius: 0 24px 0 0;
        width: 420px;
        max-height: 100vh;
        max-height: 100dvh;
        height: 100%;
        animation: modalSlideLeft 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        padding-bottom: 0;
    }

    @keyframes modalSlideLeft {
        from { opacity: 0; transform: translateX(-30px); }
        to   { opacity: 1; transform: translateX(0); }
    }
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    color: #333;
}

.close-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.close-btn .material-symbols-outlined {
    font-size: 20px;
}

#modal-body .poi-card {
    padding: 0;
    animation: none;
}

#modal-body .poi-image {
    border-radius: 0;
    height: 200px;
}

#modal-body .poi-info-container {
    padding: 1.5rem;
}

/* Map Overlay Button */
.map-overlay-btn {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    background: var(--md-sys-color-primary);
    color: white;
    border: none;
    border-radius: 100px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(63, 81, 181, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.map-overlay-btn:hover {
    transform: translateX(-50%) translateY(-5px);
    box-shadow: 0 12px 48px rgba(63, 81, 181, 0.6);
    filter: brightness(1.1);
}

.map-overlay-btn:active {
    transform: translateX(-50%) scale(0.95);
}


