/* ACIS Climate Data Viewer - Dark Theme */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #1a1a2e;
    color: #eaeaea;
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
#header {
    background: linear-gradient(135deg, #16213e 0%, #1a1a2e 100%);
    padding: 12px 20px;
    border-bottom: 1px solid #0f3460;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

#header h1 {
    font-size: 1.3rem;
    color: #00bcd4;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(0, 188, 212, 0.3);
    margin: 0;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.legal-btn {
    padding: 4px 12px;
    font-size: 12px;
    background-color: #7f8c8d;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
}

.legal-btn:hover {
    background-color: #95a5a6;
}

#controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-size: 0.9rem;
    color: #a0a0a0;
}

/* Inputs */
input[type="date"],
input[type="text"],
select {
    background: #16213e;
    border: 1px solid #0f3460;
    color: #eaeaea;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

input[type="date"]:hover,
input[type="text"]:hover,
select:hover {
    border-color: #00bcd4;
}

input[type="date"]:focus,
input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: #00bcd4;
    box-shadow: 0 0 8px rgba(0, 188, 212, 0.3);
}

/* Buttons */
.primary-btn {
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
    border: 1px solid #00bcd4;
    color: #00bcd4;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.primary-btn:hover {
    background: #00bcd4;
    color: #1a1a2e;
    box-shadow: 0 0 15px rgba(0, 188, 212, 0.4);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.primary-btn:disabled:hover {
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
    color: #00bcd4;
    box-shadow: none;
}

.secondary-btn {
    background: #16213e;
    border: 1px solid #0f3460;
    color: #a0a0a0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    border-color: #00bcd4;
    color: #00bcd4;
}

/* Unit toggle buttons */
.unit-toggle {
    background: #16213e;
    border: 1px solid #0f3460;
    color: #00bcd4;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

.unit-toggle:hover {
    background: #0f3460;
    border-color: #00bcd4;
}

/* Dropdown */
.dropdown-container {
    position: relative;
    display: inline-block;
}

.dropdown-btn {
    padding: 8px 14px;
    background: #16213e;
    border: 1px solid #00d4ff;
    color: #00d4ff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.dropdown-btn:hover {
    background: #1f2b4a;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 160px;
    background: #16213e;
    border: 1px solid #00d4ff;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    margin-top: 4px;
    padding: 8px;
}

.dropdown-content.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    color: #ccc;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 4px;
}

.dropdown-item:hover {
    background: #0f3460;
    color: #fff;
}

.dropdown-item input[type="radio"],
.dropdown-item input[type="checkbox"] {
    accent-color: #00d4ff;
    cursor: pointer;
}

/* Station Search */
.station-search {
    display: flex;
    align-items: center;
    gap: 4px;
}

.station-search input {
    background: #16213e;
    border: 1px solid #0f3460;
    color: #eaeaea;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    width: 160px;
}

.station-search input::placeholder { color: #555; }
.station-search input:focus { outline: none; border-color: #00bcd4; box-shadow: 0 0 6px rgba(0, 188, 212, 0.3); }

.go-btn {
    padding: 6px 12px;
    background: #00bcd4;
    border: 1px solid #00bcd4;
    color: #1a1a2e;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.go-btn:hover { background: #00a5bb; }

/* Selected State Label + Back Button */
.selected-state-label {
    font-size: 1rem;
    font-weight: 600;
    color: #00bcd4;
}

.selected-state-label.hidden,
.back-btn.hidden {
    display: none;
}

.back-btn {
    padding: 6px 14px;
    background: #16213e;
    border: 1px solid #0f3460;
    color: #a0a0a0;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.back-btn:hover {
    border-color: #00bcd4;
    color: #00bcd4;
}

/* State Tooltip (Leaflet) */
.state-tooltip {
    background: #16213e;
    border: 1px solid #00bcd4;
    color: #eaeaea;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.state-tooltip::before {
    border-top-color: #00bcd4;
}

/* Legend */
.legend-section p {
    font-size: 0.82rem;
    color: #a0a0a0;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
}

.legend-subtitle {
    font-size: 0.75rem !important;
    color: #666 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px !important;
    margin-top: 2px;
}

.legend-dot {
    display: inline-block;
    border-radius: 50%;
    margin-right: 6px;
    flex-shrink: 0;
}

/* Status */
#statusMessage {
    font-size: 0.85rem;
    color: #7bed9f;
    margin-left: 10px;
}

/* Main Content */
#main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Map */
#map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    background: #0d1117;
}

/* Sidebar */
#sidebar {
    width: 400px;
    background: #16213e;
    border-left: 1px solid #0f3460;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

/* Station Info Panel */
#stationInfo {
    padding: 15px;
    background: rgba(15, 52, 96, 0.5);
    border-radius: 6px;
}

#stationInfo.hidden {
    display: none;
}

#stationInfo h3 {
    font-size: 1.1rem;
    color: #00bcd4;
    margin-bottom: 8px;
}

.detail-row {
    font-size: 0.85rem;
    color: #c0c0c0;
    margin-bottom: 4px;
}

.detail-label {
    color: #888;
}

/* Data Controls */
#dataControls {
    padding: 15px;
    background: rgba(15, 52, 96, 0.5);
    border-radius: 6px;
}

#dataControls.hidden {
    display: none;
}

#dataControls h4 {
    font-size: 0.9rem;
    color: #00bcd4;
    margin-bottom: 10px;
}

.elements-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.element-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: #c0c0c0;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}

.element-checkbox:hover {
    background: rgba(0, 188, 212, 0.1);
}

.element-checkbox input[type="checkbox"] {
    accent-color: #00bcd4;
}

.element-color {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.date-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.date-row label {
    font-size: 0.8rem;
    color: #888;
}

.date-row input[type="date"] {
    padding: 6px 8px;
    font-size: 0.8rem;
}

.controls-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* Results Panel */
#resultsPanel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

#resultsPanel.hidden {
    display: none;
}

/* Chart */
#chartContainer {
    background: rgba(15, 52, 96, 0.5);
    border-radius: 6px;
    padding: 10px;
    height: 280px;
    min-height: 200px;
}

#chartContainer canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Data Table */
.table-container {
    background: rgba(15, 52, 96, 0.5);
    border-radius: 6px;
    overflow: auto;
    flex: 1;
    min-height: 100px;
    max-height: 300px;
}

#dataTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

#dataTable thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

#dataTable th {
    background: #0f3460;
    color: #00bcd4;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #00bcd4;
    white-space: nowrap;
}

#dataTable td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(15, 52, 96, 0.8);
    color: #c0c0c0;
    white-space: nowrap;
}

#dataTable tbody tr:hover {
    background: rgba(0, 188, 212, 0.05);
}

.missing {
    color: #666;
    font-style: italic;
}

.trace {
    color: #f39c12;
    font-style: italic;
}

/* Info Section */
#info-section {
    padding: 15px;
    background: rgba(15, 52, 96, 0.5);
    border-radius: 6px;
}

#info-section h3 {
    font-size: 0.9rem;
    color: #00bcd4;
    margin-bottom: 10px;
}

#info-section p {
    font-size: 0.85rem;
    color: #a0a0a0;
    margin-bottom: 6px;
}

#info-section a {
    color: #00bcd4;
    text-decoration: none;
}

#info-section a:hover {
    text-decoration: underline;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 46, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #0f3460;
    border-top-color: #00bcd4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loading-overlay p {
    margin-top: 15px;
    color: #00bcd4;
    font-size: 1rem;
}

/* Station Tooltip */
.station-tooltip {
    font-size: 12px;
    line-height: 1.5;
}

.station-tooltip strong {
    color: #00bcd4;
    font-size: 13px;
}

.leaflet-tooltip {
    background: #16213e;
    border: 1px solid #0f3460;
    color: #eaeaea;
    border-radius: 6px;
    padding: 8px 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.leaflet-tooltip-top::before {
    border-top-color: #0f3460;
}

/* Leaflet Customizations */
.leaflet-container {
    background: #0d1117;
}

.leaflet-control-zoom {
    border: none !important;
}

.leaflet-control-zoom a {
    background: #16213e !important;
    color: #00bcd4 !important;
    border: 1px solid #0f3460 !important;
}

.leaflet-control-zoom a:hover {
    background: #0f3460 !important;
}

.leaflet-control-attribution {
    background: rgba(22, 33, 62, 0.8) !important;
    color: #666 !important;
}

.leaflet-control-attribution a {
    color: #00bcd4 !important;
}

/* Legal Modal */
.legal-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    overflow-y: auto;
    padding: 20px;
}

.legal-modal.hidden {
    display: none !important;
}

.legal-modal-content {
    background-color: #2c3e50;
    border-radius: 8px;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.legal-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid #34495e;
}

.legal-modal-header h2 {
    color: #3498db;
    font-size: 22px;
    margin: 0;
}

.legal-close-btn {
    background: none;
    border: none;
    color: #ecf0f1;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.legal-close-btn:hover {
    color: #e74c3c;
}

.legal-modal-body {
    padding: 25px;
    overflow-y: auto;
    color: #ecf0f1;
}

.legal-section {
    margin-bottom: 25px;
}

.legal-section h3 {
    color: #3498db;
    font-size: 16px;
    margin-bottom: 10px;
    border-bottom: 1px solid #34495e;
    padding-bottom: 6px;
}

.legal-section p {
    margin-bottom: 8px;
    line-height: 1.5;
}

.legal-section ul {
    margin-left: 20px;
    margin-bottom: 8px;
}

.legal-section li {
    margin-bottom: 6px;
    line-height: 1.5;
}

.legal-section a {
    color: #3498db;
    text-decoration: none;
}

.legal-section a:hover {
    text-decoration: underline;
}

.warning-box {
    background-color: #e67e22;
    border-left: 4px solid #d35400;
    padding: 12px;
    margin: 12px 0;
    border-radius: 4px;
}

.warning-box p {
    margin: 0;
    color: #ffffff;
}

.legal-footer {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #34495e;
    text-align: center;
    color: #95a5a6;
    font-size: 13px;
}

/* Scrollbar */
#sidebar::-webkit-scrollbar,
.table-container::-webkit-scrollbar {
    width: 6px;
}

#sidebar::-webkit-scrollbar-track,
.table-container::-webkit-scrollbar-track {
    background: #0f3460;
}

#sidebar::-webkit-scrollbar-thumb,
.table-container::-webkit-scrollbar-thumb {
    background: #00bcd4;
    border-radius: 3px;
}

/* Responsive */
@media (max-width: 768px) {
    #header {
        flex-direction: column;
        align-items: flex-start;
    }

    #controls {
        width: 100%;
    }

    #sidebar {
        display: none;
    }
}
