/* Info Modal Colorful Circle Bullets */
.info-bullet {
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    border-radius: 50%;
    margin-right: 0.6em;
    vertical-align: middle;
    box-shadow: 0 0 2px #8882;
    border: 1.5px solid #fff;
}
/* Info Modal Status Table Alignment */
.info-status-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.5rem;
    margin: 0.08rem 0 1.5rem 0;
}
/* Reduce space above 'Current flow is ...' phrase in status table */
.info-status-table tr:first-child td:last-child {
    padding-top: 0.02em !important;
    padding-bottom: 0.02em !important;
}
.info-status-table td {
    vertical-align: top;
    padding: 0.2rem 0.5rem 0.2rem 0;
    font-size: 0.97rem;
}
.info-status-table td:first-child {
    width: 2.2rem;
    text-align: right;
}
.info-status-table td:nth-child(2) {
    white-space: nowrap;
    font-size: 0.97rem;
}
.info-status-table td:last-child {
    color: #333;
    font-size: 0.97rem;
}
/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --header-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --button-color: #667eea;
    --button-hover: #5568d3;
    --accent-color: #667eea;
    --card-background: #ffffff;
    --sidebar-background: #f8f9fa;
    --text-color: #333;
    --secondary-text: #666;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--text-color);
    overflow: hidden;
    height: 100vh;
}

/* Elevation Display */
.elevation-display {
    position: fixed;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    backdrop-filter: blur(4px);
    min-width: 120px;
}

.elevation-content strong {
    color: #667eea;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.elevation-close {
    position: absolute;
    top: 0.25rem;
    right: 0.4rem;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    line-height: 1;
    font-weight: 300;
    transition: color 0.2s;
}

.elevation-close:hover {
    color: #667eea;
}

/* Elevation Toggle Control */
.elevation-toggle-control {
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}

.elevation-toggle-btn {
    display: block;
    cursor: pointer;
    transition: all 0.2s ease;
}

.elevation-toggle-btn:hover {
    opacity: 0.8;
}

/* Header */
.header {
    background: var(--header-gradient);
    color: white;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.state-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.state-selector label {
    font-weight: 500;
}

#state-select {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    background: white;
    color: #333;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

#state-select:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

#state-select:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-refresh {
    background: white;
    color: var(--button-color);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
}

.btn-refresh:hover {
    transform: rotate(90deg);
}

.btn-refresh:active {
    transform: rotate(90deg) scale(0.95);
}

.refresh-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.btn-primary {
    background: var(--button-color);
    color: white;
}

.btn-primary:hover {
    background: var(--button-hover);
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.btn-icon {
    background: transparent;
    color: white;
    font-size: 1.25rem;
    padding: 0.25rem 0.5rem;
}

/* Main Container */
.main-container {
    display: flex;
    height: calc(100vh - 80px);
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--sidebar-background);
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    padding: 1.5rem;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    color: #333;
}

.stats-card,
.filter-card,
.legend-card {
    background: var(--card-background);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.stats-card h3,
.filter-card h3,
.legend-card h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: #222;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    color: var(--secondary-text);
    font-size: 0.9rem;
}

.stat-value {
    font-weight: 600;
    color: var(--text-color);
}

/* Filter Options */
.filter-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.filter-option:hover {
    background: #f8f9fa;
}

.filter-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.filter-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #333;
    flex-shrink: 0;
}

.filter-option span:not(.filter-color):not(.filter-count) {
    flex: 1;
}

.filter-count {
    background: #e0e0e0;
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
}

/* Legend */
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #333;
    flex-shrink: 0;
}

/* Info Button */
.btn-info {
    width: 100%;
    margin-top: 1rem;
    padding: 0.75rem;
    background: #185a9d;
    color: #fff;
    font-weight: 600;
    font-family: 'Montserrat', Arial, sans-serif;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-info:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.btn-info:active {
    transform: translateY(0);
}

/* Info Modal */
.info-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.info-modal {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.info-header {
    background: var(--header-gradient);
    color: white;
    padding: 1.5rem;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-header h3 {
    margin: 0;
    font-size: 1.5rem;
}

.btn-close {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    line-height: 1;
    padding: 0;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.info-body {
    padding: 2rem;
    line-height: 1.6;
    color: #333;
}

.info-body h4 {
    color: #185a9d;
    margin: 1.5rem 0 0.75rem 0;
    font-size: 1.1rem;
}

.info-body h4:first-child {
    margin-top: 0;
}

.info-body p {
    margin: 0.75rem 0;
}

.info-body code {
    background: #f5f5f5;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: #185a9d;
    font-size: 0.9rem;
}

.info-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
}

.info-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 6px;
}

.info-bullet {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #333;
    flex-shrink: 0;
    margin-top: 2px;
}

.info-example {
    background: #f0f4ff;
    padding: 1rem;
    border-radius: 6px;
    border-left: 4px solid var(--accent-color);
    font-size: 0.95rem;
}

/* Mobile Responsive for Info Modal */
@media (max-width: 768px) {
    .info-modal {
        max-height: 85vh;
    }
    
    .info-body {
        padding: 1.5rem;
    }
    
    .info-header h3 {
        font-size: 1.25rem;
    }
}

/* Map Container */
.map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* Crosshair cursor for map - using SVG data URI for consistent dark grey */
.leaflet-container {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="21" height="21" viewBox="0 0 21 21"><line x1="10.5" y1="0" x2="10.5" y2="21" stroke="%23555555" stroke-width="1.5"/><line x1="0" y1="10.5" x2="21" y2="10.5" stroke="%23555555" stroke-width="1.5"/></svg>') 10 10, crosshair;
}

/* Leaflet specific containers and dragging states */
.leaflet-grab,
.leaflet-dragging .leaflet-container,
.leaflet-dragging .leaflet-clickable {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="21" height="21" viewBox="0 0 21 21"><line x1="10.5" y1="0" x2="10.5" y2="21" stroke="%23555555" stroke-width="1.5"/><line x1="0" y1="10.5" x2="21" y2="10.5" stroke="%23555555" stroke-width="1.5"/></svg>') 10 10, crosshair !important;
}

/* Keep pointer cursor for clickable elements */
.leaflet-marker-icon,
.leaflet-popup,
.leaflet-popup-content-wrapper,
.leaflet-popup-tip,
.leaflet-control a,
.leaflet-control button {
    cursor: pointer !important;
}

/* Loading Overlay */
.loading-overlay,
.error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.hidden {
    display: none !important;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 1rem;
    color: #666;
    font-size: 1.1rem;
}

.error-overlay {
    background: rgba(255, 255, 255, 0.98);
}

.error-content {
    text-align: center;
    max-width: 500px;
    padding: 2rem;
}

.error-content h3 {
    color: #d32f2f;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.error-content p {
    color: #666;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0;
    min-width: 300px;
}

.popup-header {
    background: var(--header-gradient);
    color: white;
    padding: 1rem;
}

.popup-header h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}

.popup-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.9rem;
}

.popup-body {
    padding: 1rem;
}

.popup-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.popup-info-item {
    display: flex;
    flex-direction: column;
}

.popup-info-label {
    font-size: 0.75rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.popup-info-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.popup-temp-section {
    background: #f8f9fa;
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.popup-temp-section h4 {
    font-size: 0.85rem;
    margin: 0 0 0.5rem 0;
    color: #185a9d;
}

.popup-temp-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.popup-link {
    display: block;
    background: #185a9d;
    color: #fff !important;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    text-decoration: none;
    text-align: center;
    box-shadow: 0 2px 8px rgba(24,90,157,0.08);
    font-family: 'Montserrat', Arial, sans-serif;
    font-size: 1rem;
    transition: background 0.2s, box-shadow 0.2s;
    margin: 0 auto;
    width: fit-content;
}

.popup-link:hover {
    background: #143e6e;
    box-shadow: 0 4px 16px rgba(24,90,157,0.15);
}

.popup-footer {
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    font-size: 0.8rem;
    color: #666;
    text-align: center;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .app-title {
        font-size: 1.1rem;
    }

    .header-controls {
        gap: 0.5rem;
    }

    .state-selector label {
        display: none;
    }

    #state-select {
        padding: 0.5rem;
        font-size: 0.9rem;
    }

    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 1000;
        transform: translateX(-100%);
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    #toggle-sidebar {
        display: block;
    }

    /* Mobile popup optimizations */
    .leaflet-popup-content {
        min-width: 260px;
        max-width: 85vw;
    }
    
    .popup-header {
        padding: 0.75rem;
    }
    
    .popup-header h3 {
        font-size: 0.95rem;
        line-height: 1.3;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    
    .popup-header p {
        font-size: 0.8rem;
    }
    
    .popup-body {
        padding: 0.75rem;
    }
    
    .popup-info-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .popup-info-label {
        font-size: 0.7rem;
    }
    
    .popup-info-value {
        font-size: 0.95rem;
    }
    
    .popup-temp-section {
        padding: 0.6rem;
        margin-bottom: 0.75rem;
    }
    
    .popup-temp-section h4 {
        font-size: 0.8rem;
        margin-bottom: 0.4rem;
    }
    
    .popup-temp-grid {
        gap: 0.4rem;
    }
    
    .popup-temp-grid .popup-info-label {
        font-size: 0.65rem;
    }
    
    .popup-temp-grid .popup-info-value {
        font-size: 0.85rem;
        line-height: 1.3;
    }
    
    .popup-link {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .popup-footer {
        padding: 0.6rem 0.75rem;
        font-size: 0.75rem;
    }
}

@media (min-width: 769px) {
    #toggle-sidebar {
        display: none;
    }
}

/* Dark scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
