/* METAR/TAF Drone Weather System - Styles */

:root {
    --color-primary: #2563eb;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-bg: #f8fafc;
    --color-panel: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-light: #64748b;
}

/* Dark Theme */
[data-theme="dark"] {
    --color-primary: #3b82f6;
    --color-success: #10b981;
    --color-warning: #fbbf24;
    --color-danger: #f87171;
    --color-bg: #0f172a;
    --color-panel: #1e293b;
    --color-border: #334155;
    --color-text: #ffffff;
    --color-text-light: #cbd5e1;
}

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

/* Smooth theme transition for color changes */
body,
.header,
.sidebar,
.sidebar-header,
.sidebar-section,
.map-container,
.btn,
.search-input,
.filter-select,
.stat-card,
.legend-item,
.custom-marker {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

/* Header */
.header {
    background-color: var(--color-panel);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-content {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-right: 1.5rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.last-update {
    font-size: 0.875rem;
    color: var(--color-text-light);
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background-color: #1d4ed8;
}

/* Main Layout */
.main-container {
    display: flex;
    height: calc(100vh - 57px);
}

/* Sidebar */
.sidebar {
    width: 320px;
    background-color: var(--color-panel);
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
}

/* Sidebar Header (Logo/Title) */
.sidebar-header {
    padding: 2rem 1.5rem 1.5rem;
    border-bottom: 2px solid var(--color-border);
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    text-align: center;
    position: relative;
}

/* Sidebar Close Button (mobile only) */
.sidebar-close {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar-close:active {
    transform: scale(0.9);
}

.sidebar-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.sidebar-subtitle {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.4;
    font-weight: 400;
}

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

.sidebar-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-text-light);
    margin-bottom: 1rem;
}

/* Search Box */
.search-box {
    position: relative;
}

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

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

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

.filter-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

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

/* Legend */
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-color.ok {
    background-color: var(--color-success);
}

.legend-color.caution {
    background-color: var(--color-warning);
}

.legend-color.no-fly {
    background-color: var(--color-danger);
}

.legend-color.no-data {
    background-color: #94a3b8;
}

.legend-label {
    font-size: 0.875rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.stat-card {
    padding: 0.75rem;
    background-color: var(--color-bg);
    border-radius: 0.375rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--color-text-light);
    margin-top: 0.25rem;
}

/* Map Container */
.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-color: var(--color-panel);
    border: 1px solid var(--color-border);
    padding: 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
    border-radius: 0.5rem;
    padding: 0;
}

.leaflet-popup-content {
    margin: 0;
    min-width: 280px;
}

.popup-header {
    padding: 1rem;
    background-color: var(--color-primary);
    color: white;
    border-radius: 0.5rem 0.5rem 0 0;
}

.popup-header h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

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

.popup-body {
    padding: 1rem;
}

.popup-section {
    margin-bottom: 1rem;
}

.popup-section:last-child {
    margin-bottom: 0;
}

.popup-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-text-light);
    margin-bottom: 0.5rem;
}

.metar-raw {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    background-color: var(--color-bg);
    padding: 0.5rem;
    border-radius: 0.25rem;
    word-break: break-all;
}

.conditions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.condition-item {
    display: flex;
    justify-content: space-between;
}

.condition-label {
    color: var(--color-text-light);
}

.condition-value {
    font-weight: 500;
}

/* Drone Status Badge */
.drone-status-badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
}

.drone-status-badge.ok {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
}

.drone-status-badge.caution {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--color-warning);
}

.drone-status-badge.no-fly {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--color-danger);
}

.drone-score {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin: 0.5rem 0;
}

.warnings-list {
    list-style: none;
    padding: 0;
}

.warnings-list li {
    padding: 0.25rem 0;
    font-size: 0.875rem;
    color: var(--color-danger);
}

.warnings-list li:before {
    content: "⚠ ";
}

.popup-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.btn-details {
    width: 100%;
    padding: 0.625rem;
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}

.btn-details:hover {
    background-color: #1d4ed8;
}

/* Loading Spinner */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    background: var(--color-primary);
    border: none;
    color: white;
    font-size: 1.5rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 0.375rem;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.mobile-menu-toggle:hover {
    background-color: #1d4ed8;
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

/* Sidebar Overlay (for mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Responsive Design */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .sidebar {
        width: 280px;
    }

    .sidebar-section {
        padding: 1.25rem;
    }

    .sidebar-title {
        font-size: 1.35rem;
    }
}

/* Mobile (max 768px) */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .sidebar-close {
        display: flex;
    }

    .header-content {
        padding-left: 1rem;
        padding-right: 1rem;
        justify-content: space-between;
    }

    .header-actions {
        gap: 0.5rem;
    }

    .last-update {
        display: none; /* Hide on small mobile */
    }

    .legends-btn {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        z-index: 1000;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    .sidebar.open {
        left: 0;
    }

    .main-container {
        flex-direction: column;
        height: calc(100vh - 57px);
    }

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

/* Small Mobile (max 480px) */
@media (max-width: 480px) {
    .sidebar {
        width: 90%;
    }

    .sidebar-header {
        padding: 1.5rem 1rem 1rem;
    }

    .sidebar-title {
        font-size: 1.25rem;
    }

    .sidebar-subtitle {
        font-size: 0.75rem;
    }

    .sidebar-section {
        padding: 1rem;
    }

    .sidebar-section h3 {
        font-size: 0.8rem;
    }

    .legends-btn {
        font-size: 1.25rem;
        padding: 0.4rem;
    }

    .legends-btn:not(:first-child) {
        /* Show only icons on very small screens */
    }
}

/* Custom Marker Styles */
.custom-marker {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    color: white;
}

.marker-ok {
    background-color: var(--color-success);
}

.marker-caution {
    background-color: var(--color-warning);
}

.marker-no-fly {
    background-color: var(--color-danger);
}

.marker-no-data {
    background-color: #94a3b8;
}

/* Geozones Controls */
.geozones-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s;
}

.checkbox-label:hover {
    background-color: var(--color-bg);
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.checkbox-label input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.checkbox-label span {
    flex: 1;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Geozone Popup */
.geozone-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-width: 250px;
}

.geozone-popup strong {
    font-weight: 600;
    color: var(--color-text);
}

.geozone-popup small {
    font-size: 0.75rem;
    color: var(--color-text-light);
}

/* ============================================
   THEME TOGGLE (DARK MODE)
   ============================================ */

.theme-toggle {
    background: rgba(100, 116, 139, 0.1);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 1.25rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background: var(--color-primary);
    color: white;
    transform: scale(1.05);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Dark mode specific adjustments */
[data-theme="dark"] .sidebar-header {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
}

[data-theme="dark"] .sidebar-title,
[data-theme="dark"] .sidebar-subtitle {
    color: #ffffff !important;
}

[data-theme="dark"] .sidebar-section h3 {
    color: var(--color-text-light) !important;
}

[data-theme="dark"] .sidebar-section {
    color: var(--color-text);
}

[data-theme="dark"] .search-input,
[data-theme="dark"] .filter-select {
    background-color: var(--color-bg);
    color: var(--color-text);
    border-color: var(--color-border);
}

[data-theme="dark"] .search-input::placeholder {
    color: var(--color-text-light);
}

[data-theme="dark"] .legend-label,
[data-theme="dark"] .stat-label,
[data-theme="dark"] .stat-value,
[data-theme="dark"] .filter-label {
    color: var(--color-text) !important;
}

[data-theme="dark"] p,
[data-theme="dark"] span,
[data-theme="dark"] div,
[data-theme="dark"] label {
    color: inherit;
}

[data-theme="dark"] .custom-marker {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .marker-no-data {
    background-color: #64748b;
}

[data-theme="dark"] .leaflet-popup-content-wrapper {
    background-color: var(--color-panel);
    color: var(--color-text);
}

[data-theme="dark"] .leaflet-popup-tip {
    background-color: var(--color-panel);
}

[data-theme="dark"] .popup-header {
    background-color: var(--color-primary);
}

[data-theme="dark"] .popup-body {
    color: var(--color-text);
}

[data-theme="dark"] .popup-section-title {
    color: var(--color-text-light) !important;
}

[data-theme="dark"] .condition-label {
    color: var(--color-text-light) !important;
}

[data-theme="dark"] .condition-value {
    color: var(--color-text) !important;
}

[data-theme="dark"] .metar-raw {
    background-color: var(--color-bg);
    color: var(--color-text);
}

[data-theme="dark"] .loading-overlay {
    background-color: rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] .last-update {
    color: var(--color-text-light) !important;
}

[data-theme="dark"] .btn {
    color: var(--color-text);
}

[data-theme="dark"] .btn-primary {
    color: #ffffff !important;
}

[data-theme="dark"] a {
    color: #60a5fa;
}

[data-theme="dark"] a:hover {
    color: #93c5fd;
}

[data-theme="dark"] .checkbox-label {
    color: var(--color-text) !important;
}

[data-theme="dark"] .checkbox-label span {
    color: var(--color-text) !important;
}
