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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

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

/* Sidebar Styles */
.sidebar {
    width: 350px;
    background: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    z-index: 10;
    transition: transform 0.3s ease;
}

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

.sidebar-header {
    padding: 20px;
    background: linear-gradient(135deg, #1a472a 0%, #2d5a3d 100%);
    color: white;
}

.sidebar-header h1 {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.sidebar-header .subtitle {
    font-size: 0.85rem;
    opacity: 0.85;
    margin-bottom: 16px;
}

.search-container {
    position: relative;
    margin-bottom: 12px;
}

.search-input {
    width: 100%;
    padding: 10px 35px 10px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    background: rgba(255,255,255,0.95);
}

.search-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}

.clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #666;
    cursor: pointer;
    display: none;
    padding: 4px 8px;
}

.clear-btn.visible {
    display: block;
}

.filter-container {
    margin-top: 8px;
}

.filter-label {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 6px;
    opacity: 0.9;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: rgba(255,255,255,0.2);
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: rgba(255,255,255,0.3);
}

.filter-btn.active {
    background: rgba(255,255,255,0.95);
    color: #1a472a;
}

.filter-btn input {
    display: none;
}

/* Unit List */
.unit-list-container {
    flex: 1;
    overflow-y: auto;
}

.unit-list {
    list-style: none;
}

.unit-item {
    padding: 14px 20px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
}

.unit-item:hover {
    background-color: #f5f9f5;
}

.unit-item.active {
    background-color: #e8f4e8;
    border-left: 4px solid #228B22;
    padding-left: 16px;
}

.unit-item.hidden {
    display: none;
}

.unit-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #333;
    margin-bottom: 4px;
}

.unit-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #666;
}

.unit-agency {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.unit-agency.usfs { background: #e8f4e8; color: #228B22; }
.unit-agency.blm { background: #fef6e8; color: #b8860b; }
.unit-agency.nps { background: #f5ebe0; color: #8B4513; }
.unit-agency.bia, .unit-agency.tribal { background: #f3e8f5; color: #800080; }

.unit-type {
    color: #888;
}

.sidebar-footer {
    padding: 12px 20px;
    background: #f9f9f9;
    border-top: 1px solid #eee;
    font-size: 0.85rem;
}

.sidebar-footer a {
    color: #1a472a;
}

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

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

/* Toggle Button */
.toggle-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
    background: white;
    border: none;
    padding: 10px 14px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    cursor: pointer;
    font-size: 1.2rem;
    display: none;
}

/* Legend */
.legend {
    position: absolute;
    bottom: 30px;
    right: 10px;
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-size: 0.85rem;
    z-index: 5;
}

.legend h4 {
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: #333;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.legend-color {
    width: 18px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.2);
}

.legend-marker {
    width: 18px;
    text-align: center;
    color: #333;
    font-size: 0.9rem;
}

/* MapLibre Popup */
.maplibregl-popup {
    max-width: 320px !important;
}

.maplibregl-popup-content {
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
}

.popup-header {
    background: linear-gradient(135deg, #1a472a 0%, #2d5a3d 100%);
    color: white;
    padding: 12px 16px;
}

.popup-header h3 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.popup-header .popup-agency {
    font-size: 0.8rem;
    opacity: 0.9;
}

.popup-body {
    padding: 16px;
}

.popup-info {
    margin-bottom: 12px;
}

.popup-info p {
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #555;
}

.popup-info strong {
    color: #333;
}

.popup-link {
    display: inline-block;
    padding: 8px 16px;
    background: #1a472a;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.popup-link:hover {
    background: #2d5a3d;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        width: 300px;
        transform: translateX(-100%);
    }

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

    .toggle-btn {
        display: block;
    }

    .legend {
        bottom: 20px;
        right: 10px;
        left: auto;
        max-width: 160px;
        font-size: 0.75rem;
    }

    .legend h4 {
        font-size: 0.8rem;
    }
}

/* No results message */
.no-results {
    padding: 30px 20px;
    text-align: center;
    color: #888;
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100px;
    color: #666;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 2px solid #ddd;
    border-top-color: #1a472a;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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