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

:root {
    --color-primary: #1a1a2e;
    --color-secondary: #16213e;
    --color-accent: #c9a84c;
    --color-accent-light: #e8c860;
    --color-bg: #0f0f1a;
    --color-surface: #1e1e36;
    --color-surface-light: #2a2a4a;
    --color-text: #e0dcc8;
    --color-text-muted: #8b8680;
    --color-border: #3a3a5a;
    --sidebar-width: 320px;
    --header-font: 'Cinzel', serif;
    --body-font: 'Inter', sans-serif;
}

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

body {
    font-family: var(--body-font);
    background: var(--color-bg);
    color: var(--color-text);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ==================== Layout ==================== */
#sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--color-primary);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
}

#map {
    position: fixed;
    left: var(--sidebar-width);
    top: 0;
    right: 0;
    bottom: 0;
    background: #0a0a15;
}

/* ==================== Header ==================== */
#header {
    padding: 20px 16px 12px;
    background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    border-bottom: 2px solid var(--color-accent);
    text-align: center;
    flex-shrink: 0;
}

#header h1 {
    font-family: var(--header-font);
    font-size: 20px;
    font-weight: 700;
    color: var(--color-accent);
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    letter-spacing: 2px;
    text-transform: uppercase;
}

#header h2 {
    font-family: var(--header-font);
    font-size: 12px;
    font-weight: 400;
    color: var(--color-text-muted);
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-top: 4px;
}

/* ==================== Search ==================== */
#search-container {
    position: relative;
    padding: 10px 12px;
    flex-shrink: 0;
}

#search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 13px;
    font-family: var(--body-font);
    outline: none;
    transition: border-color 0.2s;
}

#search-input::placeholder {
    color: var(--color-text-muted);
}

#search-input:focus {
    border-color: var(--color-accent);
}

#search-results {
    position: absolute;
    top: 100%;
    left: 12px;
    right: 12px;
    max-height: 300px;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 6px 6px;
    z-index: 100;
    display: none;
}

#search-results:not(.hidden) {
    display: block;
}

.search-result-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--color-border);
    transition: background 0.15s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--color-surface-light);
}

.search-result-title {
    font-size: 13px;
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-title strong {
    color: var(--color-accent);
}

.search-result-cat {
    font-size: 11px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.search-empty {
    padding: 20px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
}

/* ==================== Filters ==================== */
#filters {
    flex: 1;
    overflow-y: auto;
    padding: 0 0 8px;
}

#filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}

.btn-small {
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 10px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s;
}

.btn-small:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* Category Groups */
.category-group {
    border-bottom: 1px solid var(--color-border);
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.group-header:hover {
    background: var(--color-surface);
}

.group-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
}

.group-toggle {
    font-size: 9px;
    color: var(--color-text-muted);
}

.group-categories {
    padding: 0 0 4px;
}

.group-categories.collapsed {
    display: none;
}

.category-item {
    display: flex;
    align-items: center;
    padding: 4px 12px 4px 16px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.15s;
    gap: 8px;
}

.category-item:hover {
    background: var(--color-surface);
}

.category-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    transition: all 0.2s;
}

.category-item input[type="checkbox"]:checked {
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.category-item input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--color-primary);
    font-size: 10px;
    font-weight: bold;
}

.category-icon {
    display: inline-block;
    flex-shrink: 0;
    image-rendering: pixelated;
}

.category-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==================== Stats ==================== */
#stats {
    padding: 8px 12px;
    font-size: 11px;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
    text-align: center;
}

#stats span {
    color: var(--color-accent);
    font-weight: 600;
}

/* ==================== Custom Markers ==================== */
.custom-marker {
    background: none !important;
    border: none !important;
}

.marker-pin {
    width: 36px;
    height: 48px;
    position: relative;
    clip-path: polygon(50% 0%, 100% 35%, 100% 70%, 50% 100%, 0% 70%, 0% 35%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
    transition: opacity 0.2s, transform 0.2s;
}

.marker-pin:hover {
    opacity: 1;
    transform: scale(1.15);
    z-index: 1000 !important;
}

.marker-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -2px;
}

.marker-icon {
    display: block;
    image-rendering: pixelated;
}

/* ==================== Popups ==================== */
.leaflet-popup-content-wrapper {
    background: var(--color-surface) !important;
    color: var(--color-text) !important;
    border: 1px solid var(--color-accent);
    border-radius: 8px !important;
    font-family: var(--body-font) !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6) !important;
}

.leaflet-popup-tip {
    background: var(--color-surface) !important;
    border: 1px solid var(--color-accent);
}

.leaflet-popup-content {
    margin: 12px 16px !important;
    font-size: 13px;
    line-height: 1.5;
    min-width: 200px;
    max-width: 300px;
}

.popup-category-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    color: #fff;
}

.marker-popup-content h4 {
    font-family: var(--header-font);
    font-size: 16px;
    font-weight: 600;
    color: var(--color-accent);
    margin: 4px 0 8px;
}

.popup-description {
    font-size: 12px;
    color: var(--color-text);
    line-height: 1.6;
}

.popup-description strong {
    color: var(--color-accent-light);
}

.popup-description a {
    color: var(--color-accent);
    text-decoration: underline;
}

/* ==================== Sidebar Toggle (Mobile) ==================== */
#sidebar-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 999;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    width: 40px;
    height: 40px;
    border-radius: 6px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

#sidebar-toggle:hover {
    background: var(--color-surface-light);
    border-color: var(--color-accent);
}

/* ==================== Leaflet Overrides ==================== */
.leaflet-control-zoom a {
    background: var(--color-surface) !important;
    color: var(--color-text) !important;
    border-color: var(--color-border) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--color-surface-light) !important;
}

.leaflet-control-attribution {
    display: none !important;
}

/* ==================== Scrollbar ==================== */
#filters::-webkit-scrollbar,
#search-results::-webkit-scrollbar {
    width: 4px;
}

#filters::-webkit-scrollbar-track,
#search-results::-webkit-scrollbar-track {
    background: transparent;
}

#filters::-webkit-scrollbar-thumb,
#search-results::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 2px;
}

#filters::-webkit-scrollbar-thumb:hover,
#search-results::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
    }

    #sidebar.open {
        transform: translateX(0);
    }

    #map {
        left: 0;
    }

    #sidebar-toggle {
        display: block;
    }
}
