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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
#sidebar {
    width: 380px;
    min-width: 320px;
    background: linear-gradient(180deg, #16213e 0%, #1a1a2e 100%);
    display: flex;
    flex-direction: column;
    border-right: 1px solid #0f3460;
    overflow: hidden;
}

header {
    padding: 20px;
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
    border-bottom: 2px solid #4cc9f0;
}

header h1 {
    font-size: 1.4rem;
    color: #4cc9f0;
    margin-bottom: 8px;
}

header .subtitle {
    font-size: 0.85rem;
    color: #94a3b8;
    font-style: italic;
}

#info-box {
    padding: 15px 20px;
    background: rgba(15, 52, 96, 0.5);
    border-bottom: 1px solid #0f3460;
}

.stat {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.stat:last-child {
    margin-bottom: 0;
}

.stat .label {
    color: #94a3b8;
    font-size: 0.9rem;
}

.stat .value {
    color: #4cc9f0;
    font-weight: 600;
}

.callout {
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(76, 201, 240, 0.1);
    border-left: 3px solid #4cc9f0;
    font-size: 0.8rem;
    color: #94a3b8;
    border-radius: 0 4px 4px 0;
}

#loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #64748b;
    font-size: 0.9rem;
}

#loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #0f3460;
    border-top-color: #4cc9f0;
    border-radius: 50%;
    margin-right: 10px;
    animation: spin 1s linear infinite;
}

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

#search-box {
    padding: 15px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid #0f3460;
    align-items: center;
}

#selected-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

#selected-filters:empty {
    display: none;
}

#filter-total {
    width: 100%;
    padding: 8px 12px;
    background: rgba(76, 201, 240, 0.1);
    border-radius: 4px;
    font-size: 0.85rem;
    color: #94a3b8;
}

#filter-total.hidden {
    display: none;
}

#filter-total .total-area {
    color: #4cc9f0;
    font-weight: 600;
}

#filter-total .total-percent {
    color: #64748b;
}

.filter-tag {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #4cc9f0;
    color: #16213e;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.filter-tag button {
    background: none;
    border: none;
    color: #16213e;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    margin-left: 2px;
    opacity: 0.7;
}

.filter-tag button:hover {
    opacity: 1;
}

#search-input-wrapper {
    flex: 1;
    position: relative;
    min-width: 150px;
}

#state-search {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #0f3460;
    border-radius: 6px;
    background: #16213e;
    color: #e0e0e0;
    font-size: 0.95rem;
}

#state-search:focus {
    outline: none;
    border-color: #4cc9f0;
}

#state-search::placeholder {
    color: #64748b;
}

#search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #16213e;
    border: 1px solid #4cc9f0;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
}

#search-dropdown.hidden {
    display: none;
}

.dropdown-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #e0e0e0;
}

.dropdown-item:hover,
.dropdown-item.highlighted {
    background: #0f3460;
}

.dropdown-item.disabled {
    color: #64748b;
    cursor: default;
}

#clear-search {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    background: #0f3460;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

#clear-search:hover {
    background: #1a4670;
    color: #e0e0e0;
}

#selected-info {
    padding: 15px 20px;
    background: rgba(76, 201, 240, 0.1);
    border-bottom: 1px solid #4cc9f0;
}

#selected-info.hidden {
    display: none;
}

#selected-info h3 {
    color: #4cc9f0;
    font-size: 0.9rem;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#selected-states {
    color: #e0e0e0;
    font-size: 0.9rem;
    margin-bottom: 8px;
    line-height: 1.5;
}

#selected-area {
    color: #4cc9f0;
    font-weight: 600;
    margin-bottom: 12px;
}

#clear-selection {
    padding: 8px 16px;
    border: 1px solid #4cc9f0;
    border-radius: 4px;
    background: transparent;
    color: #4cc9f0;
    cursor: pointer;
    font-size: 0.85rem;
}

#clear-selection:hover {
    background: rgba(76, 201, 240, 0.2);
}

#combination-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.list-header {
    padding: 12px 20px;
    background: rgba(15, 52, 96, 0.3);
    color: #64748b;
    font-size: 0.8rem;
    border-bottom: 1px solid #0f3460;
}

#combinations {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.combo-item {
    padding: 12px 15px;
    margin-bottom: 8px;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.combo-item:hover {
    background: #1a4670;
    border-color: #4cc9f0;
}

.combo-item.selected {
    background: rgba(76, 201, 240, 0.2);
    border-color: #4cc9f0;
}

.combo-header {
    margin-bottom: 6px;
}

.combo-count {
    font-size: 0.8rem;
    color: #64748b;
    background: #0f3460;
    padding: 3px 8px;
    border-radius: 10px;
}

.combo-area {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 6px;
}

.combo-states {
    font-size: 0.8rem;
    color: #64748b;
    line-height: 1.4;
}

/* Map Container */
#map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* Custom Leaflet styles */
.leaflet-container {
    background: #0d1b2a;
}

/* Mobile tabs - hidden on desktop */
#mobile-tabs {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    #app {
        flex-direction: column;
    }

    #mobile-tabs {
        display: flex;
        background: #0f3460;
        border-bottom: 1px solid #4cc9f0;
    }

    #mobile-tabs .tab {
        flex: 1;
        padding: 12px;
        border: none;
        background: transparent;
        color: #64748b;
        font-size: 0.9rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
    }

    #mobile-tabs .tab.active {
        color: #4cc9f0;
        background: rgba(76, 201, 240, 0.1);
        border-bottom: 2px solid #4cc9f0;
    }

    #sidebar {
        width: 100%;
        flex: 1;
        min-width: unset;
        min-height: 0;
    }

    #sidebar.hidden {
        display: none;
    }

    #map-container {
        flex: 1;
        min-height: 0;
    }

    #map-container.hidden {
        display: none;
    }

    header h1 {
        font-size: 1.1rem;
    }

    header .subtitle {
        font-size: 0.75rem;
    }

    #info-box {
        padding: 10px 15px;
    }

    .stat {
        font-size: 0.85rem;
    }

    .callout {
        font-size: 0.7rem;
        padding: 6px 10px;
    }
}

/* Scrollbar styling */
#combinations::-webkit-scrollbar {
    width: 8px;
}

#combinations::-webkit-scrollbar-track {
    background: #16213e;
}

#combinations::-webkit-scrollbar-thumb {
    background: #0f3460;
    border-radius: 4px;
}

#combinations::-webkit-scrollbar-thumb:hover {
    background: #1a4670;
}
