/* Dashboard Styles */
.dashboard {
    display: grid; /* Changed from display: none; */
    grid-template-columns: 380px 1fr;
    height: 100vh;
}

.sidebar {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(148, 163, 184, 0.1);
    padding: 24px;
    overflow-y: auto;
    position: relative;
}

.mobile-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.mobile-toggle {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 6px;
    padding: 8px 12px;
    color: #e2e8f0;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-toggle:hover {
    background: rgba(59, 130, 246, 0.3);
}

.sidebar-close {
    display: none;
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    padding: 6px 10px;
    color: #fecaca;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 1002;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    position: relative;
}

.logo-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-image: url('/logo.png');
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}

.logo-icon:empty::before {
    content: '';
}

.logo-text {
    font-size: 18px;
    font-weight: 600;
    color: #f1f5f9;
    flex: 1;
}

.logout-btn {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    padding: 6px 12px;
    color: #fecaca;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.2s ease;
}

.stat-card:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(59, 130, 246, 0.3);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #3b82f6;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.areas-list {
    margin-top: 24px;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.country-group {
    margin-bottom: 20px;
}

.country-header {
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: rgba(30, 41, 59, 0.3);
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.country-flag {
    width: 20px;
    height: 15px;
    border-radius: 2px;
    object-fit: cover;
}

.area-item {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.area-item:hover {
    background: rgba(30, 41, 59, 0.7);
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

.area-name {
    font-weight: 500;
    color: #f1f5f9;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.weather-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.weather-icon {
    font-size: 16px;
}

.weather-age {
    font-size: 10px;
    color: #64748b;
    margin-left: 4px;
}

.area-details {
    font-size: 12px;
    color: #94a3b8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.entries-count {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    color: #fbbf24;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.map-container {
    position: relative;
    height: 100vh;
    overflow: hidden;
}

#map {
    height: 100%;
    width: 100%;
    transition: height 0.3s ease;
}

.map-container.chart-open #map {
    height: 50%;
}

.map-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 800;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.control-btn {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    padding: 12px 16px;
    color: #e2e8f0;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.control-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
}

.control-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.control-btn.location {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.3);
}

.control-btn.location:hover {
    background: rgba(16, 185, 129, 0.3);
    border-color: rgba(16, 185, 129, 0.5);
}

.legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 16px;
    z-index: 800;
    min-width: 200px;
}

.legend-title {
    font-size: 14px;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

/* Weather Chart Panel Styles */
.weather-chart-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    z-index: 900;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.weather-chart-panel.show {
    transform: translateY(0);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    flex-shrink: 0;
}

.chart-title h3 {
    margin: 0;
    color: #f1f5f9;
    font-size: 16px;
    font-weight: 600;
}

.chart-title p {
    margin: 4px 0 0 0;
    color: #94a3b8;
    font-size: 12px;
}

.chart-controls {
    display: flex;
    gap: 8px;
}

.chart-btn {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 6px;
    padding: 8px;
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-btn:hover {
    background: rgba(59, 130, 246, 0.3);
}

.chart-btn.close {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
}

.chart-btn.close:hover {
    background: rgba(239, 68, 68, 0.3);
}

.chart-container {
    height: calc(100% - 73px);
    padding: 8px;
    position: relative;
    box-sizing: border-box;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #94a3b8;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(59, 130, 246, 0.1);
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

.hidden {
    display: none !important;
}

.date-picker-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(51, 65, 85, 0.8);
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid #475569;
}

.date-label {
    font-size: 14px;
    color: #e2e8f0;
    margin: 0;
}

.styled-date-input {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid #475569;
    border-radius: 6px;
    color: #e2e8f0;
    padding: 6px 8px;
    font-size: 12px;
    font-family: Inter, sans-serif;
    min-width: 120px;
}

.styled-date-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.styled-date-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.7;
}

.apply-date {
    background: #10b981 !important;
    font-size: 11px;
    padding: 6px 10px;
}

.apply-date:hover {
    background: #059669 !important;
}

/* Tablet styles */
@media (max-width: 1024px) {
    .dashboard {
        grid-template-columns: 320px 1fr;
    }

    .sidebar {
        padding: 20px;
    }

    .map-controls {
        gap: 8px;
        top: 15px;
        right: 15px;
    }

    .control-btn {
        padding: 10px 14px;
        font-size: 13px;
    }

    .legend {
        bottom: 15px;
        left: 15px;
        padding: 14px;
    }

    .weather-chart-panel {
        height: 40%;
    }

    .map-container.chart-open #map {
        height: 60%;
    }
}

/* Mobile styles */
@media (max-width: 768px) {
    /* Fix: Dashboard should account for mobile header */
    .dashboard {
        grid-template-columns: 1fr;
        height: calc(100vh - 60px); /* Subtract mobile header height */
    }

    .mobile-header {
        display: flex;
        align-items: center;
        padding: 12px 16px;
        height: 60px; /* Fixed height for predictable calculation */
        box-sizing: border-box;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    }

    .mobile-header .logo {
        flex: 1;
        margin-bottom: 0;
        border-bottom: none;
        padding-bottom: 0;
        gap: 8px;
    }

    .mobile-header .logo-icon {
        width: 28px;
        height: 28px;
        border-radius: 6px;
        background-image: url('/logo.png');
        background-size: cover;
        background-repeat: no-repeat;
        background-position: center;
    }

    .mobile-header .logo-text {
        font-size: 16px;
        font-weight: 600;
        color: #f1f5f9;
    }

    .mobile-toggle {
        background: rgba(59, 130, 246, 0.2);
        border: 1px solid rgba(59, 130, 246, 0.3);
        border-radius: 6px;
        padding: 8px 12px;
        color: #e2e8f0;
        font-size: 14px;
        cursor: pointer;
        transition: all 0.2s ease;
        flex-shrink: 0;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 90%;
        max-width: 350px;
        height: 100vh;
        z-index: 1001;
        transition: left 0.3s ease;
        border-right: 1px solid rgba(148, 163, 184, 0.1);
        padding: 60px 24px 24px 24px;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar.open .sidebar-close {
        display: block;
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* Fix: Map container now takes full remaining height */
    .map-container {
        height: 100%; /* Take full remaining height after header */
        position: relative;
        overflow: hidden;
    }

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

    .map-container.chart-open #map {
        height: 50%;
    }

    .weather-chart-panel {
        height: 50%;
    }

    .chart-header {
        padding: 12px 16px;
    }

    .chart-title h3 {
        font-size: 14px;
    }

    .chart-title p {
        font-size: 11px;
    }

    .chart-container {
        height: calc(100% - 65px);
        padding: 4px;
    }

    /* Mobile map controls */
    .map-controls {
        position: absolute;
        top: 10px;
        right: 10px;
        z-index: 800;
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: flex-end;
    }

    .control-btn {
        background: rgba(15, 23, 42, 0.9);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(148, 163, 184, 0.2);
        border-radius: 6px;
        padding: 8px 12px;
        color: #e2e8f0;
        font-size: 12px;
        cursor: pointer;
        transition: all 0.2s ease;
        white-space: nowrap;
        min-width: auto;
    }

    /* Mobile legend */
    .legend {
        position: absolute;
        bottom: 10px;
        left: 10px;
        right: 10px;
        background: rgba(15, 23, 42, 0.9);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(148, 163, 184, 0.2);
        border-radius: 8px;
        padding: 12px;
        z-index: 800;
        max-height: 40vh; /* Better mobile sizing */
        overflow-y: auto;
    }

    .legend-title {
        font-size: 12px;
        font-weight: 600;
        color: #f1f5f9;
        margin-bottom: 8px;
    }

    .legend-item {
        display: flex;
        align-items: center;
        gap: 6px;
        margin-bottom: 4px;
        font-size: 11px;
        line-height: 1.3;
    }

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

/* Very small mobile screens */
@media (max-width: 480px) {
    .mobile-header {
        padding: 8px 12px;
        height: 56px; /* Slightly smaller on very small screens */
    }

    .dashboard {
        height: calc(100vh - 56px); /* Adjust for smaller header */
    }

    .legend {
        bottom: 8px;
        left: 8px;
        right: 8px;
        padding: 10px;
    }

    .map-controls {
        top: 8px;
        right: 8px;
    }

    .control-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .weather-chart-panel {
        height: 45%;
    }

    .map-container.chart-open #map {
        height: 55%;
    }

    .chart-container {
        height: calc(100% - 60px);
        padding: 2px;
    }
}