/* =========================================================
   Layering / Leaflet Base
   Note: Header UI styles live in map_header_*.css.
   This file only consumes --map-header-height and panel-side UI.
   ========================================================= */
.leaflet-top,
.leaflet-bottom {
    z-index: 900 !important;
}

/* =========================================================
   Hamburger Menu Drawer
   ========================================================= */
#hamburger-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100dvh;
    background: white;
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1002;
    transition: right 0.3s ease;
    overflow-y: auto;
    padding: 80px 20px 20px 20px;
}

.hamburger-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #666;
    transition: color 0.2s;
    border: 0;
    background: transparent;
}

.hamburger-close:hover {
    color: #333;
}

.hamburger-title {
    margin: 0 0 20px 0;
    font-size: 20px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-item {
    width: 100%;
    border: 0;
    text-align: left;
    padding: 15px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.menu-item:hover {
    background: #e9ecef;
}

.menu-item-icon {
    font-size: 24px;
}

.menu-item-title {
    font-weight: 600;
    color: #333;
    font-size: 15px;
}

.menu-item-subtitle {
    color: #666;
    font-size: 12px;
}

/* =========================================================
   Overlays (Hamburger / Statistics)
   ========================================================= */
#menu-overlay,
#statistics-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#menu-overlay {
    z-index: 1001;
}

#statistics-overlay {
    z-index: 1002;
}

/* =========================================================
   Statistics Panel Shell
   Depends on --map-header-height for vertical offset.
   ========================================================= */
#statistics-panel {
    position: fixed;
    top: var(--map-header-height);
    right: 0;
    width: 90vw;
    max-width: 400px;
    height: calc(100dvh - var(--map-header-height));
    background: white;
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1003;
    overflow-y: auto;
    padding: 20px;
    display: none;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.statistics-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.statistics-title {
    margin: 0;
    font-size: 18px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

#stats-close-button {
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #666;
    transition: all 0.2s;
    background: #f8f9fa;
    border-radius: 50%;
    border: 0;
}

#stats-close-button:hover {
    background: #e9ecef;
    color: #333;
}

.statistics-section {
    margin-bottom: 25px;
}

.statistics-section-title {
    font-size: 15px;
    color: #555;
    margin-bottom: 10px;
}

#recent-visits-list,
#top-locations-list {
    font-size: 13px;
}

#top-locations-list {
    max-height: 360px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.visit-item,
.location-item {
    width: 100%;
    border: 0;
    text-align: left;
    padding: 10px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.location-item {
    padding: 8px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.location-main {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.location-rank {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.location-rank-medal {
    font-size: 16px;
    line-height: 1;
}

.location-rank-number {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.visit-item:hover,
.location-item:hover {
    background: #e9ecef;
}

.visit-name,
.location-name {
    font-weight: 600;
    color: #333;
}

.location-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.visit-date {
    color: #666;
    font-size: 12px;
    margin-top: 4px;
}

.visit-title {
    color: #999;
    font-size: 11px;
    margin-top: 2px;
}

.location-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

#monthlyChart {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

#topLocationsChart {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.statistics-chart-wrap {
    position: relative;
    width: 100%;
}

.statistics-chart-wrap-monthly {
    height: 220px;
}

.statistics-chart-wrap-top {
    height: clamp(280px, 40vh, 380px);
}

/* =========================================================
   Statistics Panel Responsive Adjustments
   ========================================================= */

/* =========================================================
   Responsive: Tablet / Mobile
   ========================================================= */
@media screen and (max-width: 768px) {
    #hamburger-menu {
        width: 85vw;
        max-width: 320px;
    }

    #statistics-panel {
        width: 100vw;
        max-width: 100vw;
        padding: 15px;
    }

    .statistics-header {
        position: sticky;
        top: -15px;
        z-index: 2;
        background: #ffffff;
        margin: -15px -15px 16px -15px;
        padding: 12px 15px;
        border-bottom: 1px solid #e5e7eb;
    }

    .statistics-title {
        font-size: 16px;
    }

    .statistics-section-title {
        font-size: 14px;
    }

    .visit-item,
    .location-item {
        padding: 8px;
        font-size: 12px;
    }

    .statistics-chart-wrap-monthly {
        height: 200px;
    }

    .statistics-chart-wrap-top {
        height: clamp(270px, 38vh, 340px);
    }

    #top-locations-list {
        max-height: 320px;
    }
}

/* =========================================================
   Responsive: Small Mobile
   ========================================================= */
@media (max-width: 480px) {
    #hamburger-menu {
        width: 90vw;
    }

    #statistics-panel {
        padding: 12px;
    }

    .statistics-header {
        top: -12px;
        margin: -12px -12px 14px -12px;
        padding: 10px 12px;
    }

    .statistics-title {
        font-size: 15px;
    }

    .statistics-section-title {
        font-size: 13px;
    }

    .visit-item div,
    .location-item span {
        font-size: 11px;
    }

    .statistics-chart-wrap-monthly {
        height: 180px;
    }

    .statistics-chart-wrap-top {
        height: 290px;
    }
}
