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

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --accent-color: #f59e0b;
    --bg-light: #f8fafc;
    --text-main: #1e293b;
    --header-height: 60px;
    --sidebar-width: 300px;
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.4);
}

html,
body,
#app {
    height: 100%;
    width: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-main);
    overflow: hidden;
    background: var(--bg-light);
}

#app {
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header */
.header {
    background: white;
    color: var(--text-main);
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 1001;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color) 0%, #4f46e5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    flex-grow: 1;
}

.stats {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary-color);
    background: #f1f5f9;
    padding: 6px 12px;
    border-radius: 999px;
    white-space: nowrap;
}

/* Menu Toggle Button */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px 5px;
    z-index: 1002;
}

.icon-bar {
    width: 22px;
    height: 2px;
    background-color: var(--text-main);
    border-radius: 2px;
    transition: 0.3s;
}

/* Main Container */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Sidebar */
.sidebar {
    position: relative;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 100;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.05);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    margin-left: 0;
    /* Default visible on desktop */
}

.sidebar:not(.active) {
    margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.sidebar-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--secondary-color);
    line-height: 1;
}

/* Hours Grid */
.hours-grid-container {
    overflow-x: auto;
    margin-top: 5px;
}

.hours-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.hours-grid th,
.hours-grid td {
    padding: 6px 4px;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.hours-grid th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--secondary-color);
}

.hours-grid td:first-child {
    background: #f8fafc;
    font-weight: 600;
    width: 30px;
}

.hours-grid input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

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

.filter-section.collapsible {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 12px;
    gap: 0;
}

.filter-section.collapsible:last-child {
    border-bottom: none;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 8px 0;
}

.header-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    margin-right: 12px;
}

.btn-section-action {
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-section-action:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #eff6ff;
}

.filter-header label {
    cursor: pointer;
    margin-bottom: 0;
    font-weight: 700;
}

.filter-body {
    overflow: hidden;
    transition: max-height 0.3s ease-in-out, opacity 0.2s, margin-top 0.2s;
    max-height: 600px;
    opacity: 1;
    margin-top: 10px;
}

.filter-section.collapsed .filter-body {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    pointer-events: none;
}

.filter-section.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.toggle-icon {
    font-size: 0.7rem;
    color: var(--secondary-color);
    transition: transform 0.3s;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.type-filter-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 350px;
    overflow-y: auto;
    padding: 12px;
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    scrollbar-width: thin;
}

.sub-type-list,
.rating-filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 0;
}

/* Hours Filter Group */
.hours-filter-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 4px;
}

.filter-subgroup {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.subgroup-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.day-checkboxes {
    display: flex;
    justify-content: space-between;
    background: #f1f5f9;
    padding: 8px;
    border-radius: 10px;
}

.day-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    flex: 1;
}

.day-label input {
    width: 16px;
    height: 16px;
    margin: 0;
}

.day-label span {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--secondary-color);
}

.day-label:hover span {
    color: var(--primary-color);
}

.time-checkboxes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.time-checkboxes .checkbox-label {
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-size: 0.85rem;
}

.sidebar-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Map */
#map {
    flex: 1;
    height: 100%;
    z-index: 1;
    background: #f1f5f9;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    transition: all 0.2s;
    text-align: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--secondary-color);
}

.btn-secondary:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

/* Marker Labels (Leaflet Tooltip) */
.marker-label {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(8px) !important;
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    border-radius: 8px !important;
    padding: 2px 8px !important;
    font-weight: 800 !important;
    font-size: 0.85rem !important;
    color: #1e293b !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
    white-space: nowrap !important;
    cursor: pointer;
    transition: all 0.2s;
}

/* Force specific color for buttons in popups to avoid inheritance from .popup-content a */
.popup-content .btn-primary {
    color: white !important;
}

.popup-content .btn-secondary {
    color: var(--secondary-color) !important;
}

/* Yellow Theme (★4+) */
.marker-label.rating-gold {
    background: #fef9c3 !important;
    border: 1px solid #facc15 !important;
    color: #854d0e !important;
    text-shadow: none !important;
    z-index: 1000 !important;
}

/* Gray Theme (★3+) */
.marker-label.rating-silver {
    background: #f3f4f6 !important;
    border: 1px solid #d1d5db !important;
    color: #374151 !important;
    text-shadow: none !important;
    z-index: 500 !important;
}

/* Sidebar Rating Colors */
.label-gold-text {
    background: #fef9c3;
    color: #854d0e;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid #facc15;
    font-weight: 800;
}

.label-silver-text {
    background: #f3f4f6;
    color: #374151;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-weight: 800;
}

.leaflet-tooltip-top::before {
    border-top-color: rgba(255, 255, 255, 0.9) !important;
}

.rating-gold.leaflet-tooltip-top::before {
    border-top-color: #facc15 !important;
}

.rating-silver.leaflet-tooltip-top::before {
    border-top-color: #d1d5db !important;
}

/* Popup Styles */
.leaflet-popup-content-wrapper {
    border-radius: 20px;
    padding: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.popup-content h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
}

.popup-content p {
    margin-bottom: 8px;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--secondary-color);
}

.popup-content strong {
    color: var(--text-main);
}

.popup-content a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 700;
}

/* Error Container */
.error-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 40px;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    z-index: 2000;
    width: 90%;
    max-width: 400px;
}

.hidden {
    display: none;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 85%;
    }

    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        width: var(--sidebar-width);
        z-index: 1100;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
        margin-left: 0 !important;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar:not(.active) {
        transform: translateX(-100%);
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0 16px;
        gap: 12px;
    }

    .title {
        font-size: 1.1rem;
    }

    .stats {
        padding: 4px 10px;
        font-size: 0.75rem;
    }
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 6px;
    vertical-align: middle;
}

.badge-open {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.badge-closed {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Weekly Schedule in Popup */
.weekly-schedule {
    margin-top: 8px;
    padding: 8px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.weekly-schedule details {
    font-size: 0.8rem;
    cursor: pointer;
}

.weekly-schedule summary {
    font-weight: 700;
    color: var(--primary-color);
    outline: none;
    margin-bottom: 4px;
}

.weekly-hours-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 5px;
}

.weekly-hours-table tr {
    border-bottom: 1px solid #f1f5f9;
}

.weekly-hours-table tr:last-child {
    border-bottom: none;
}

.weekly-hours-table td {
    padding: 2px 4px;
    line-height: 1.4;
}

.day-cell {
    font-weight: 800;
    width: 24px;
    color: var(--text-main);
}

.time-cell {
    color: var(--secondary-color);
    font-family: 'Inter', monospace;
}

.text-closed {
    color: #ef4444;
    font-weight: 600;
}