* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }
body, html { height: 100%; background-color: #f4f7f6; overflow: hidden; }

#map { position: absolute; top: 0; left: 0; height: 100%; width: 100%; z-index: 1; }

/* --- Sidebar Layout (Desktop) --- */
.sidebar {
    position: absolute; top: 20px; left: 20px; width: 340px; max-height: calc(100vh - 40px);
    background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px);
    z-index: 1000; display: flex; flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1); border-radius: 16px;
}

.sidebar-top { padding: 24px; border-bottom: 1px solid #e2e8f0; }
h1 { color: #2c3e50; font-size: 22px; margin-bottom: 8px; }
p { color: #7f8c8d; font-size: 14px; margin-bottom: 16px; }

/* Support Floating Button */
.support-button-floating { position: fixed; bottom: 24px; right: 24px; z-index: 1000; display: flex; align-items: center; gap: 10px; text-decoration: none; outline: none; }
.support-button-floating .icon-jar-mask {
    width: 72px;
    height: 72px;
    border: none;
    border-radius: 0;
    overflow: visible;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.support-button-floating .icon-jar { 
    flex-shrink: 0; 
    width: 72px; height: 72px;
    object-fit: contain; 
    object-position: center;
    filter: drop-shadow(0 0 1px rgba(255,255,255,0.95))
            drop-shadow(0 8px 20px rgba(0,0,0,0.22));
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    z-index: 2; 
    position: relative; 
}
.support-button-floating .support-text { 
    max-width: 0; opacity: 0; white-space: nowrap; 
    color: #1e293b; font-weight: 700; font-size: 14px; 
    background: rgba(255, 255, 255, 0.96); 
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); 
    padding: 10px 0; 
    border-radius: 999px; 
    box-shadow: 0 10px 22px rgba(0,0,0,0.12); 
    margin-right: -30px; 
    z-index: 1; 
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    overflow: hidden; 
    pointer-events: none;
    border: 1px solid rgba(255,255,255,0.9);
}
.support-button-floating:hover .icon-jar { 
    transform: translateY(-4px) scale(1.05) rotate(-2deg); 
    filter: drop-shadow(0 0 1px rgba(255,255,255,0.95))
            drop-shadow(0 12px 28px rgba(0,0,0,0.28)); 
}
.support-button-floating:hover .support-text { 
    max-width: 180px; opacity: 1; 
    padding: 12px 18px; 
    margin-right: 0; 
    pointer-events: auto; 
}
.support-button-floating:active .icon-jar { transform: scale(0.92); }

.support-hover-desktop {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: inline-block;
}
.support-hover-desktop::before {
    content: "";
    position: absolute;
    right: 100%;
    bottom: 18px;
    width: 14px;
    height: 44px;
}
.support-hover-desktop .support-button-floating {
    position: static;
    right: auto;
    bottom: auto;
}
.support-hover-desktop .support-button-floating .support-text {
    display: none;
}
.support-hover-desktop:hover .support-button-floating .icon-jar,
.support-hover-desktop:focus-within .support-button-floating .icon-jar,
.support-hover-desktop .support-button-floating:hover .icon-jar,
.support-hover-desktop .support-button-floating:active .icon-jar {
    transform: translateY(-4px) scale(1.05) rotate(-2deg); 
    filter: drop-shadow(0 0 1px rgba(255,255,255,0.95))
            drop-shadow(0 12px 28px rgba(0,0,0,0.28));
}
.support-desktop-dropdown {
    position: absolute;
    right: calc(100% - 2px);
    bottom: 50%;
    transform: translateY(50%) translateX(8px);
    opacity: 0;
    pointer-events: none;
    min-width: 170px;
    padding: 6px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 10px 24px rgba(0,0,0,0.16);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.support-hover-desktop:hover .support-desktop-dropdown,
.support-hover-desktop:focus-within .support-desktop-dropdown {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(50%) translateX(0);
}
.support-desktop-dropdown a,
.support-desktop-dropdown .support-menu-action {
    width: 100%;
    white-space: nowrap;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
}
.support-desktop-dropdown a:hover,
.support-desktop-dropdown a:focus-visible,
.support-desktop-dropdown .support-menu-action:hover,
.support-desktop-dropdown .support-menu-action:focus-visible {
    background: #f1f5f9;
    outline: none;
}

.support-menu-mobile {
    display: none;
}

/* Filter Chips */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.filter-chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; background: #e2e8f0; color: #4a5568; border-radius: 20px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); border: 1px solid transparent; white-space: nowrap; line-height: 1; }
.filter-chip .material-symbols-outlined { font-size: 14px !important; vertical-align: middle; }
.filter-chip:active { transform: scale(0.95); }
.filter-chip:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.filter-chip.active { background: #007aff; color: white; }
.filters-extra { margin-top: -12px; margin-bottom: 16px; }
.filter-chip-more { background: transparent; border: 1px dashed #cbd5e1; color: #64748b; }
.filter-chip-more.active { background: transparent; border-color: #007aff; color: #007aff; }
.theme-dark .filter-chip-more { border-color: #475569; color: #94a3b8; }
.theme-dark .filter-chip-more.active { border-color: #3b82f6; color: #3b82f6; }

/* --- Refined List Item Styles --- */
.list-header { padding: 16px 24px 8px; font-weight: 700; color: #7f8c8d; font-size: 12px; text-transform: uppercase; }
.facility-list { flex: 1; overflow-y: auto; padding: 0 12px 12px; }

.list-item { 
    padding: 16px; border-radius: 12px; cursor: pointer; border-bottom: 1px solid #f1f5f9;
    display: flex; flex-direction: column; gap: 6px; transition: background 0.2s, transform 0.1s;
}
.list-item:hover { background: #f8fafc; transform: translateY(-1px); }

.list-item-header { display: flex; justify-content: space-between; align-items: flex-start; }
.list-item-title { font-weight: 700; color: #2c3e50; font-size: 15px; }
.list-item-rating { font-size: 12px; line-height: 1.2; margin-top: -5px; margin-bottom: -2px; }
.list-item-rating .score { color: #f59e0b; font-weight: 700; }
.list-item-rating .count { color: #64748b; font-weight: 600; }
.list-item-rating .pending,
.list-item-rating .empty { color: #7f8c8d; font-weight: 600; }

.empty-state-rating { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: #007aff; cursor: pointer; padding: 6px 10px; background: rgba(0,122,255,0.1); border-radius: 12px; transition: 0.2s; margin-top: -4px; margin-bottom: 8px; }
.empty-state-rating:hover { background: rgba(0,122,255,0.2); transform: scale(1.02); }
.empty-state-rating .material-symbols-outlined { font-size: 16px; }
.empty-actionable { color: #007aff !important; font-weight: 600 !important; cursor: pointer; }
.popup-title { font-weight:700; font-size:15px; color:#2c3e50; }
.popup-rating { color:#7f8c8d; margin:8px 0 12px 0; }

/* Blue Distance Badge */
.distance-badge { font-size: 11px; font-weight: 700; color: #007aff; background: #eef2ff; padding: 4px 8px; border-radius: 20px; white-space: nowrap; }

.list-item-features { font-size: 13px; color: #7f8c8d; display: flex; gap: 8px; align-items: center; }
.list-item-features:empty { display: none; }
.list-item-actions { display: flex; gap: 8px; margin-top: 0; }

.btn-action-small {
    flex: 1; padding: 8px; border-radius: 8px; font-size: 13px; font-weight: 600;
    text-align: center; text-decoration: none; border: none; cursor: pointer; transition: opacity 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 4px;
}
.btn-action-small:hover { opacity: 0.8; }

/* Blue Directions Button (Forced White Text) */
a.btn-directions, .btn-directions { background: #007aff; color: #ffffff !important; }
button.btn-rate, .btn-rate { background: #f1f5f9; color: #4a5568 !important; border: 1px solid #e2e8f0; }

/* --- Custom Map Pins (Blue) --- */
.custom-pin { background-color: #007aff; border-radius: 50%; display: flex; justify-content: center; align-items: center; box-shadow: 0 2px 5px rgba(0,0,0,0.3); border: 2px solid white; color: white; }
.custom-user-marker { background: transparent; border: none; }
.user-location-dot { width: 14px; height: 14px; background-color: #007aff; border: 2px solid white; border-radius: 50%; box-shadow: 0 0 5px rgba(0,0,0,0.4); }

/* --- Marker Cluster (brand blue, replaces default green/yellow/orange) --- */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background-color: rgba(0, 122, 255, 0.25);
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background-color: #007aff;
    color: #fff;
    font-weight: 700;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
/* Slightly deeper shade for larger clusters to retain visual hierarchy */
.marker-cluster-medium div { background-color: #0066d6; }
.marker-cluster-large div { background-color: #0052ad; }

/* --- Toast Notifications --- */
.toast-container { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); z-index: 4000; width: 90%; max-width: 350px; pointer-events: none; }
.toast { background: white; color: #2c3e50; padding: 14px 20px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); font-weight: 600; margin-bottom: 10px; transition: opacity 0.4s; display: flex; align-items: center; gap: 8px; }
.toast.hiding { opacity: 0; }
.toast.success { border-left: 4px solid #10b981; }
.toast.error { border-left: 4px solid #ef4444; }

/* --- Standard UI Elements --- */
.btn-primary { background: #007aff; color: white; border: none; padding: 12px; border-radius: 8px; font-weight: 600; cursor: pointer; width: 100%; transition: 0.2s; display: flex; justify-content: center; align-items: center; gap: 8px; }
.btn-primary:hover { background: #005ce6; }
#btn-search-area {
    display: none; position: absolute; top: 20px; left: calc(360px + (100% - 360px)/2); transform: translateX(-50%);
    z-index: 2000; background: white; color: #007aff; border: 1px solid #e2e8f0; padding: 10px 20px; border-radius: 20px; font-weight: 600; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); cursor: pointer;
}
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2100;
    width: 34px;
    height: 34px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    color: #1e293b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
    cursor: pointer;
}
.theme-toggle .material-symbols-outlined { font-size: 18px; }
.theme-toggle:hover { transform: translateY(-1px); }

/* PWA / safe-area: when launched as a standalone app on iOS/Android,
 * push the floating chrome away from the notch and home indicator so it
 * doesn't sit underneath the status bar. */
@supports (padding: env(safe-area-inset-top)) {
    .theme-toggle {
        top: calc(20px + env(safe-area-inset-top));
        right: calc(20px + env(safe-area-inset-right));
    }
    .support-button-floating {
        bottom: calc(24px + env(safe-area-inset-bottom));
        right: calc(24px + env(safe-area-inset-right));
    }
    .support-menu-mobile {
        top: calc(env(safe-area-inset-top) + 0px);
    }
}
#loader { display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2500; background: white; padding: 15px 25px; border-radius: 30px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); align-items: center; gap: 10px; font-weight: 600; color: #2c3e50; }
.spinner { width: 20px; height: 20px; border: 3px solid #e2e8f0; border-top: 3px solid #007aff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* --- Modals & Reviews --- */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 3000; justify-content: center; align-items: center; }
.modal-content { background: white; padding: 24px; border-radius: 16px; width: 90%; max-width: 400px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; color: #2c3e50; }

/* Location Error Modal Styles */
.location-error-content {
    margin-bottom: 24px;
}

.location-error-content p {
    margin-bottom: 12px;
    line-height: 1.5;
    color: #5a6c7d;
}

.location-error-content p:last-child {
    margin-bottom: 0;
}

.location-error-content strong {
    color: #2c3e50;
    font-weight: 600;
}
.stars { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 8px; margin-bottom: 16px; }
.star { font-size: 28px; color: #cbd5e1; cursor: pointer; transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s; display: inline-block; }
.star:active { transform: scale(0.8); }
.star:hover { transform: scale(1.1); }
.star.selected, .star.selected ~ .star { color: #f59e0b; animation: starPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes starPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
textarea { width: 100%; padding: 12px; border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 16px; resize: none; height: 100px; }
.feedback-form input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
}
.modal-actions { display: flex; gap: 10px; }
.btn-cancel { background: #e2e8f0; color: #4a5568; border: none; padding: 12px; border-radius: 8px; font-weight: 600; cursor: pointer; flex: 1; }

.review-card { background: #f8fafc; padding: 12px; border-radius: 8px; border: 1px solid #e2e8f0; font-size: 13px; margin-bottom: 10px; color: #4a5568; }
.reviews-list-container { max-height: 300px; overflow-y: auto; margin-bottom: 16px; }
.clickable-rating { cursor: pointer; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; font-weight: 600; display: flex; align-items: center; gap: 4px; }

/* --- Subtle Map Attribution --- */
.leaflet-control-attribution { background: transparent !important; color: #a0aec0 !important; font-size: 10px !important; }
.leaflet-control-attribution a { color: #a0aec0 !important; text-decoration: none; }
.leaflet-control-attribution a:hover { color: #4a5568 !important; }
.leaflet-control-attribution svg { fill: #a0aec0 !important; opacity: 0.7; }

/* --- Mobile Bottom Sheet Styles --- */
.mobile-handle { 
    display: none; 
    padding: 12px 0 8px 0; 
    cursor: pointer; 
    justify-content: center; 
    touch-action: none; /* Prevents Safari bounce when dragging */
}

/* The sleek iOS-style pill line */
.drag-line {
    width: 40px;
    height: 5px;
    background-color: #cbd5e1;
    border-radius: 4px;
}

.list-section { display: flex; flex-direction: column; overflow: hidden; flex: 1; }

@media (max-width: 768px) {
    /* 1. The Floating Island Card */
    .sidebar { 
        display: flex;
        flex-direction: column;
        width: calc(100% - 32px); 
        left: 16px; 
        top: auto; 
        bottom: 20px; 
        border-radius: 20px; 
        padding-bottom: 0; /* Let the header sit flush at the bottom */
        max-height: 65vh; 
        transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); 
    }
    
    /* 2. Flexbox Reordering (The Magic Trick) */
    .mobile-handle { display: flex; order: 1; } /* Handle stays at the top */
    .list-section { order: 2; } /* List squeezes into the middle */
    
    .sidebar-top { 
        order: 3; /* Header moves to the absolute bottom */
        padding: 8px 16px 16px 16px; 
        border-top: 1px solid #f1f5f9; /* Separator line above the header */
        border-bottom: none; 
    } 

    /* 3. Condense the Header */
    .sidebar-top h1 { font-size: 18px; margin-bottom: 12px; } 
    .sidebar-top p { display: none; } 
    .filters { margin-bottom: 12px; } 
    .btn-primary { padding: 10px 12px; font-size: 14px; } 

    /* 4. Collapsed State */
    .sidebar.collapsed { max-height: 150px; } /* Enough room for just handle + header */
    .sidebar.collapsed .hide-on-collapse { display: none; }
    .sidebar.collapsed .sidebar-top { border-top: none; } /* Hide separator when collapsed */
    
    #btn-search-area { left: 50%; top: 20px; }
}

@media (max-width: 768px) {
    .support-button-floating {
        display: none;
    }

    .support-hover-desktop {
        display: none;
    }

    .support-menu-mobile {
        position: fixed;
        top: 20px;
        left: 12px;
        z-index: 2600;
        display: inline-flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .support-menu-toggle {
        width: 40px;
        height: 40px;
        border: 1px solid #e2e8f0;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.98);
        color: #334155;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 6px 16px rgba(0,0,0,0.14);
        cursor: pointer;
    }
    .support-menu-toggle .support-menu-icon {
        font-size: 22px;
        line-height: 1;
        font-weight: 600;
    }

    .support-menu-dropdown {
        display: none;
        min-width: 164px;
        padding: 6px;
        border: 1px solid #e2e8f0;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.98);
        box-shadow: 0 10px 24px rgba(0,0,0,0.16);
    }
    .support-menu-mobile.open .support-menu-dropdown {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    .support-menu-dropdown a {
        display: block;
        padding: 10px 12px;
        border-radius: 10px;
        text-decoration: none;
        font-size: 14px;
        font-weight: 600;
        color: #334155;
    }
    .support-menu-dropdown .support-menu-action {
        width: 100%;
        border: none;
        background: transparent;
        text-align: left;
        cursor: pointer;
        display: block;
        padding: 10px 12px;
        border-radius: 10px;
        font-size: 14px;
        font-weight: 600;
        color: #334155;
    }
    .support-menu-dropdown a:hover,
    .support-menu-dropdown a:focus-visible,
    .support-menu-dropdown .support-menu-action:hover,
    .support-menu-dropdown .support-menu-action:focus-visible {
        background: #f1f5f9;
        outline: none;
    }

    .theme-toggle {
        top: 20px;
        right: 12px;
        width: 40px;
        height: 40px;
    }
    .theme-toggle .material-symbols-outlined { font-size: 18px; }

    .modal-overlay { align-items: flex-end; }
    .modal-content { 
        width: 100%; max-width: 100%; border-radius: 24px 24px 0 0; padding: 24px 24px 40px;
        margin: 0; animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
}

.theme-dark body, .theme-dark html { background-color: #121212; }
.theme-dark .sidebar, .theme-dark .modal-content, .theme-dark .toast, .theme-dark #loader, .theme-dark #btn-search-area { background: rgba(30, 30, 30, 0.95); color: #e2e8f0; border: 1px solid #333; }
.theme-dark h1, .theme-dark .modal-title, .theme-dark .list-item-title, .theme-dark .popup-title { color: #f8fafc !important; }
.theme-dark p, .theme-dark .list-header, .theme-dark .list-item-rating .pending, .theme-dark .list-item-features, .theme-dark .popup-rating { color: #94a3b8 !important; }
.theme-dark .filter-chip { background: #334155; color: #e2e8f0; }
.theme-dark .filter-chip:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.theme-dark .sidebar-top { border-bottom-color: #334155; }
.theme-dark .list-item { border-bottom-color: #1e293b; }
.theme-dark .list-item:hover { background: #1e293b; }
.theme-dark .btn-rate, .theme-dark .btn-cancel { background: #334155 !important; color: #f8fafc !important; border-color: #475569; }
.theme-dark .toast, .theme-dark #loader, .theme-dark .modal-content { background: #1e293b; color: #f8fafc; border: none; }
.theme-dark textarea { background: #0f172a; color: #f8fafc; border-color: #334155; }
.theme-dark .feedback-form input { background: #0f172a; color: #f8fafc; border-color: #334155; }
.theme-dark .review-card { background: #0f172a; border-color: #334155; color: #cbd5e1; }
.theme-dark .leaflet-popup-content-wrapper, .theme-dark .leaflet-popup-tip { background: #1e293b; color: #f8fafc; }
.theme-dark .leaflet-container { background: #1a1a1a; }
.theme-dark .custom-pin { border-color: #1e293b; }
.theme-dark .support-button-floating .support-text { background: transparent; color: #334155; }
.theme-dark .support-menu-toggle {
    background: rgba(30, 41, 59, 0.95);
    color: #f8fafc;
    border-color: #475569;
}
.theme-dark .support-menu-dropdown {
    background: rgba(30, 41, 59, 0.98);
    border-color: #475569;
}
.theme-dark .support-menu-dropdown a {
    color: #f8fafc;
}
.theme-dark .support-menu-dropdown .support-menu-action {
    color: #f8fafc;
}
.theme-dark .support-menu-dropdown a:hover,
.theme-dark .support-menu-dropdown a:focus-visible,
.theme-dark .support-menu-dropdown .support-menu-action:hover,
.theme-dark .support-menu-dropdown .support-menu-action:focus-visible {
    background: #334155;
}

@media (max-width: 768px) {
    .theme-dark .support-menu-toggle {
        background: rgba(30, 41, 59, 0.95);
        color: #f8fafc;
        border-color: #475569;
    }
    .theme-dark .support-menu-dropdown {
        background: rgba(30, 41, 59, 0.98);
        border-color: #475569;
    }
    .theme-dark .support-menu-dropdown a {
        color: #f8fafc;
    }
    .theme-dark .support-menu-dropdown .support-menu-action {
        color: #f8fafc;
    }
}