/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
}

/* ===== Back Button ===== */
.back-btn {
    position: fixed;
    top: 12px;
    right: 16px;
    left: auto;
    z-index: 1100;
    background: rgba(20, 20, 40, 0.85);
    color: #a78bfa;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    backdrop-filter: blur(6px);
    border: 1px solid rgba(167, 139, 250, 0.3);
    transition: background 0.2s, color 0.2s;
}
.back-btn:hover {
    background: rgba(167, 139, 250, 0.2);
    color: #c4b5fd;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: rgba(15, 15, 30, 0.96);
    backdrop-filter: blur(8px);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 18px 16px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #e0e0ff;
    letter-spacing: 0.02em;
}

.sidebar-subtitle {
    font-size: 0.78rem;
    color: #888;
    margin-top: 2px;
}

.sidebar-toggle {
    display: none;
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    color: #ccc;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

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

.sidebar-content::-webkit-scrollbar {
    width: 4px;
}
.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

.sidebar-hint {
    font-size: 0.78rem;
    color: #888;
    line-height: 1.5;
}

/* ===== Category List ===== */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.category-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--cat-color, rgba(255,255,255,0.08));
    border-radius: 8px;
    padding: 9px 12px;
    cursor: pointer;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: left;
    transition: background 0.15s;
    width: 100%;
    background: color-mix(in srgb, var(--cat-color, transparent) 10%, rgba(255,255,255,0.03));
}

.category-btn:hover {
    background: color-mix(in srgb, var(--cat-color, transparent) 20%, rgba(255,255,255,0.06));
}

.cat-chevron {
    margin-left: auto;
    color: #555;
    font-size: 1.1rem;
    line-height: 1;
}

.cat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--cat-color);
    flex-shrink: 0;
}

.cat-count {
    font-size: 0.75rem;
    color: #888;
    background: rgba(255,255,255,0.06);
    padding: 1px 7px;
    border-radius: 10px;
    flex-shrink: 0;
}

/* ===== Detail View ===== */
.detail-back-btn {
    background: none;
    border: none;
    color: #a78bfa;
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0 0 12px 0;
    display: block;
    transition: color 0.15s;
}
.detail-back-btn:hover {
    color: #c4b5fd;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 10px;
}

.detail-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e0e0ff;
    flex: 1;
}

.address-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.address-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 9px 12px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.15s;
}
.address-item:hover {
    background: rgba(255,255,255,0.09);
}

.address-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #e0e0ff;
}

.address-detail {
    font-size: 0.75rem;
    color: #888;
}

/* ===== Result Summary ===== */
.result-summary {
    font-size: 0.78rem;
    color: #888;
    line-height: 1.5;
}

/* ===== Map ===== */
#map {
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* ===== Search This Area Button ===== */
.search-area-btn {
    position: fixed;
    bottom: 28px;
    left: calc(280px + 50%);
    transform: translateX(-50%);
    z-index: 1050;
    background: #4f46e5;
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 24px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.45);
    transition: background 0.2s, box-shadow 0.2s, opacity 0.2s;
    letter-spacing: 0.01em;
}
.search-area-btn:hover {
    background: #4338ca;
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.6);
}
.search-area-btn.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 20, 0.55);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}
.loading-overlay p {
    color: #ddd;
    font-size: 0.9rem;
}

.spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: #a78bfa;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Leaflet popup dark theme ===== */
.leaflet-popup-content-wrapper {
    background: #1e1e3a;
    color: #e0e0e0;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}
.leaflet-popup-tip {
    background: #1e1e3a;
}
.leaflet-popup-content {
    margin: 12px 16px;
    line-height: 1.5;
}
.popup-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #e0e0ff;
    margin-bottom: 4px;
}
.popup-category {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}
.popup-detail {
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 2px;
}
.popup-link {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: #a78bfa;
    text-decoration: none;
}
.popup-link:hover {
    text-decoration: underline;
}

/* ===== No results message ===== */
.no-results-msg {
    background: rgba(15, 15, 30, 0.92);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.82rem;
    color: #aaa;
    line-height: 1.5;
}

/* ===== Mobile ===== */
@media (max-width: 700px) {
    .sidebar {
        width: 100%;
        height: auto;
        bottom: 0;
        top: auto;
        border-right: none;
        border-top: 1px solid rgba(255,255,255,0.08);
        max-height: 55vh;
        transform: translateY(calc(100% - 56px));
    }

    .sidebar.open {
        transform: translateY(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .back-btn {
        right: 12px;
        left: auto;
        top: 10px;
    }

    #map {
        left: 0;
        bottom: 56px;
    }

    .loading-overlay {
        left: 0;
        bottom: 56px;
    }

    .search-area-btn {
        left: 50%;
        bottom: calc(56px + 16px);
        transform: translateX(-50%);
    }
}
