/* Stat cards */
.stat-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
}

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 32px;
    font-weight: 700;
    color: var(--brand);
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.stat-change {
    font-size: 11px;
    color: var(--accent-green);
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ============================================
   FILTER PANEL - GIS Controls
   ============================================ */

.filter-panel {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.filter-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
}

.filter-panel-header:hover {
    background: var(--border-color);
}

.filter-panel-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-panel-title svg {
    width: 14px;
    height: 14px;
    fill: var(--text-muted);
}

.filter-panel-toggle {
    width: 16px;
    height: 16px;
    fill: var(--text-muted);
    transition: transform 0.2s ease;
}

.filter-panel.collapsed .filter-panel-toggle {
    transform: rotate(-90deg);
}

.filter-panel.collapsed .filter-panel-body {
    display: none;
}

.filter-panel-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Class checkboxes */
.class-filter-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.class-filter-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.class-filter-item:hover {
    background: var(--bg-tertiary);
}

.class-filter-item input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

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

.class-filter-item input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.class-filter-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.class-filter-color.dump { background: var(--color-dump); }
.class-filter-color.graffiti { background: var(--color-graffiti); }
.class-filter-color.litter { background: var(--color-litter); }
.class-filter-color.mattress { background: var(--color-mattress); }
.class-filter-color.furniture { background: var(--color-furniture); }
.class-filter-color.appliance { background: var(--color-appliance); }
.class-filter-color.tires { background: var(--color-tires); }
.class-filter-color.construction { background: var(--color-construction); }

.class-filter-label {
    font-size: 12px;
    color: var(--text-primary);
    flex: 1;
}

.class-filter-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
}

/* Filter row for inline controls */
.filter-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-row-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

/* Date inputs */
.date-input-group {
    display: flex;
    gap: 8px;
}

.date-input-wrapper {
    flex: 1;
    position: relative;
}

.date-input-wrapper label {
    position: absolute;
    top: -6px;
    left: 8px;
    font-size: 9px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.date-input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-primary);
    transition: border-color 0.15s ease;
}

.date-input:focus {
    outline: none;
    border-color: var(--brand);
}

/* Range slider */
.range-slider-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.range-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.range-slider-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--brand);
    font-weight: 600;
}

.range-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--brand);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.15s ease;
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.range-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--brand);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.range-slider-ticks {
    display: flex;
    justify-content: space-between;
    padding: 0 2px;
}

.range-slider-tick {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: var(--text-muted);
}

/* Dual-thumb date range slider */
.date-range-slider {
    position: relative;
    height: 6px;
    margin: 8px 0 4px;
}

.date-range-slider-track {
    position: absolute;
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.date-range-slider-fill {
    position: absolute;
    height: 6px;
    background: var(--brand);
    border-radius: 3px;
    opacity: 0.4;
}

.date-range-slider input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    position: absolute;
    width: 100%;
    height: 6px;
    background: transparent;
    pointer-events: none;
    margin: 0;
    top: 0;
    left: 0;
    outline: none;
}

/* The max slider sits on top so its thumb is always grabbable on the right side */
.date-range-slider input[type="range"]#date-slider-max {
    z-index: 3;
}

.date-range-slider input[type="range"]#date-slider-min {
    z-index: 4;
}

.date-range-slider input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    background: transparent;
}

.date-range-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--brand);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    pointer-events: auto;
    margin-top: -5px;
    transition: transform 0.15s ease;
}

.date-range-slider input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.date-range-slider input[type="range"]::-moz-range-track {
    height: 6px;
    background: transparent;
    border: none;
}

.date-range-slider input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--brand);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    pointer-events: auto;
}

.date-range-slider-labels {
    display: flex;
    justify-content: space-between;
    padding: 4px 2px 0;
}

.date-range-slider-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: var(--text-muted);
}

/* Select dropdown */
.filter-select {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.15s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%2352525b'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--brand);
}

/* Reset link */
.filter-reset {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--text-muted);
    text-decoration: underline;
    cursor: pointer;
    text-align: center;
    padding: 4px;
}

.filter-reset:hover {
    color: var(--accent-red);
}

/* Filter summary badge */
.filter-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    background: var(--brand);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
}

/* Divider */
.filter-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.date-range {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 12px;
    color: var(--text-primary);
    width: 100%;
    font-family: 'JetBrains Mono', monospace;
}

/* Buttons */
.route-button {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-active) 100%);
    border: none;
    border-radius: 8px;
    padding: 14px 20px;
    font-size: 13px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.route-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 40%, transparent);
}

/* Fallback for browsers without color-mix support */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
    .route-button:hover {
        box-shadow: 0 4px 12px rgba(74, 124, 89, 0.3);
    }
}

.export-button {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.export-button:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

/* Data source status */
.data-source-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.data-source-status .status-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

.data-source-status.loaded .status-icon {
    color: var(--brand, var(--accent-green));
}

.data-source-status.error {
    border-color: var(--accent-red);
}

.data-source-status.error .status-icon {
    color: var(--accent-red);
}

/* ============================================
   ROUTE SELECTION OVERLAY
   ============================================ */

.route-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.15);
    backdrop-filter: none;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 20px;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
    pointer-events: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.route-overlay-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px 32px;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
}

.route-overlay-content h3 {
    margin: 0 0 12px 0;
    font-size: 20px;
    color: var(--text-primary);
}

.route-overlay-content p {
    margin: 0 0 24px 0;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.route-overlay-hint {
    margin: 12px 0;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.route-overlay-hint kbd {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.route-overlay-cancel {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.route-overlay-cancel:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ============================================
   ROUTE PANEL
   ============================================ */

.route-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 380px;
    max-height: calc(100vh - 40px);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 500;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.route-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.route-panel-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
}

.route-panel-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}

.route-panel-close:hover {
    color: var(--text-primary);
}

.route-panel-summary {
    display: flex;
    padding: 16px 20px;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

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

.route-stat-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.route-stat-value {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 700;
    color: var(--brand);
}

.route-panel-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.route-action-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
}

.route-action-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--text-muted);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.route-action-btn-primary {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-active) 100%);
    border: none;
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
    padding: 14px 20px;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 40%, transparent);
}

.route-action-btn-primary:hover {
    background: linear-gradient(135deg, var(--brand-active) 0%, #2a4830 100%);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px color-mix(in srgb, var(--brand) 40%, transparent);
}

/* Fallback for browsers without color-mix support */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
    .route-action-btn-primary {
        box-shadow: 0 2px 8px rgba(74, 124, 89, 0.4);
    }

    .route-action-btn-primary:hover {
        box-shadow: 0 4px 16px rgba(74, 124, 89, 0.4);
    }
}

.route-secondary-actions {
    display: flex;
    gap: 8px;
}

.route-secondary-actions .route-action-btn {
    flex: 1;
    font-size: 11px;
    padding: 10px 12px;
}

.route-panel-directions {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.route-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 6px;
    font-size: 12px;
    color: #fbbf24;
    margin-bottom: 16px;
}

.route-direction-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.route-direction-item:last-child {
    border-bottom: none;
}

.route-direction-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.route-icon-start {
    background: var(--accent-green);
    font-size: 16px;
}

.route-direction-text {
    flex: 1;
    padding-top: 2px;
}

.route-direction-name {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 4px;
}

.route-direction-details {
    font-size: 11px;
    color: var(--text-muted);
}
