:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-color: #1f2937;
    --light-color: #f8fafc;
    --border-color: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--light-color);
    color: var(--text-primary);
    line-height: 1.6;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow);
    position: relative;
    z-index: 1000;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.header p {
    opacity: 0.9;
    font-size: 0.875rem;
}

.stats {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    text-align: right;
}

.stats-item {
    font-size: 0.75rem;
    opacity: 0.8;
}

.stats-number {
    font-size: 1.25rem;
    font-weight: 600;
    display: block;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 380px;
    background: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--light-color);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
}

.sidebar-section {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Search */
.search-container {
    position: relative;
    margin-bottom: 1rem;
}

.search-input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* Filters */
.filter-group {
    margin-bottom: 1rem;
}

.filter-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.filter-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    background: white;
}

.filter-range {
    width: 100%;
    margin: 0.5rem 0;
}

.range-display {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Location Status */
.location-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--light-color);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
}

.status-icon {
    color: var(--secondary-color);
}

.coordinates {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Selected Libraries */
.selected-list {
    max-height: 200px;
    overflow-y: auto;
}

.selected-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: var(--light-color);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
}

.selected-item-info {
    flex: 1;
}

.selected-item-distance {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.remove-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.remove-btn:hover {
    background: #dc2626;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    justify-content: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-success {
    background: var(--secondary-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.btn-group .btn {
    flex: 1;
}

/* Route Info */
.route-summary {
    background: linear-gradient(135deg, var(--secondary-color), #059669);
    color: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.route-summary h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.route-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.route-stat {
    text-align: center;
}

.route-stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    display: block;
}

.route-stat-label {
    font-size: 0.75rem;
    opacity: 0.9;
}

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

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

/* Map Controls */
.map-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.map-control-btn {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
}

.map-control-btn:hover {
    background: var(--light-color);
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -380px;
        top: 0;
        height: 100%;
        transition: var(--transition);
        z-index: 1000;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        left: 0;
    }

    .map-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: var(--transition);
    }

    .map-overlay.show {
        opacity: 1;
        visibility: visible;
    }

    .mobile-menu-btn {
        position: absolute;
        top: 1rem;
        left: 1rem;
        z-index: 1001;
        background: white;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        padding: 0.75rem;
        box-shadow: var(--shadow);
        cursor: pointer;
    }

    .stats {
        display: none;
    }
}

/* Custom Mapbox Popup */
.mapboxgl-popup-content {
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    padding: 1rem;
}

.library-popup h3 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-size: 1rem;
}

.library-popup p {
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.popup-select-btn {
    margin-top: 0.75rem;
    width: 100%;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Route note styling */
.route-note {
    font-size: 0.75rem !important;
    color: var(--warning-color) !important;
    background: rgba(245, 158, 11, 0.1);
    padding: 0.5rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    border-left: 3px solid var(--warning-color);
}