/* ========================================
   PROJECT PRAGATI - Static Dashboard Styles
   Government of India Design System Compliant
   Light Theme MVP
   ======================================== */

:root {
    /* India Government Color Palette (Tiranga + Official) */
    --saffron: #FF9933;
    --white: #FFFFFF;
    --green: #138808;
    --navy-blue: #000080;
    /* Ashoka Chakra */

    /* UI Colors */
    --primary-blue: #1a237e;
    --bg-light: #f5f5f5;
    --bg-white: #ffffff;
    --text-dark: #212121;
    --text-muted: #757575;
    --border-light: #e0e0e0;

    /* Priority Colors (Hybrid Profiling) */
    --priority-critical: #d32f2f;
    /* Red - Dead/Critical */
    --priority-severe: #f57c00;
    /* Orange - Failing */
    --priority-shock: #fbc02d;
    /* Yellow - Warning */
    --priority-surge: #1976d2;
    /* Blue - Expanding */
    --priority-safe: #388e3c;
    /* Green - Normal */

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Inter', 'Noto Sans', -apple-system, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    font-size: 14px;
    line-height: 1.4;
}

/* ========== HEADER ========== */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg-white);
    border-bottom: 3px solid var(--saffron);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    height: 48px;
    width: auto;
}

.header-text h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-blue);
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.header-text p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.header-stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    text-align: center;
    padding: 4px 12px;
    background: var(--bg-light);
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.stat-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1;
}

.stat-value.critical {
    color: var(--priority-critical);
}

.stat-value.severe {
    color: var(--priority-severe);
}

.stat-value.shock {
    color: var(--priority-shock);
}

.stat-value.surge {
    color: var(--priority-surge);
}

.stat-value.safe {
    color: var(--priority-safe);
}

.stat-value.nodata {
    color: #bdbdbd;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-top: 4px;
    display: block;
}

/* ========== MAIN CONTAINER ========== */
.main-container {
    display: flex;
    height: calc(100vh - 76px);
    /* Adjust based on header height */
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 320px;
    background: var(--bg-white);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-light);
}

.sidebar-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
}

/* Category Toggle */
.category-toggle {
    display: flex;
    padding: 12px;
    gap: 8px;
    background: var(--bg-white);
}

.cat-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border-light);
    background: var(--bg-light);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.cat-btn.active {
    background: var(--primary-blue);
    color: var(--white);
    border-color: var(--primary-blue);
    box-shadow: var(--shadow-sm);
}

.cat-btn:hover:not(.active) {
    background: #e0e0e0;
}

/* Search Bar */
.search-container {
    padding: 8px 12px;
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border-light);
}

#pincode-search {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
}

#pincode-search:focus {
    border-color: var(--primary-blue);
}

#search-btn {
    padding: 8px;
    width: 36px;
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#search-btn:hover {
    background: #0d47a1;
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    /* Fix layout breaking */
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-white);
}

.filters select {
    flex: 1;
    min-width: 120px;
    padding: 8px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 0.8rem;
    background: var(--bg-white);
    cursor: pointer;
}

.filters select:focus {
    outline: none;
    border-color: var(--primary-blue);
}

/* Pincode List */
.pincode-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-light);
}

.pincode-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--bg-white);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.pincode-item:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Border Color by Priority */
.pincode-item.critical {
    border-left-color: var(--priority-critical);
}

.pincode-item.severe {
    border-left-color: var(--priority-severe);
}

.pincode-item.shock {
    border-left-color: var(--priority-shock);
}

.pincode-item.surge {
    border-left-color: var(--priority-surge);
}

.pincode-item.safe {
    border-left-color: var(--priority-safe);
}

.pincode-item .location {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
}

.pincode-item .pincode {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ========== MAP CONTAINER ========== */
.map-container {
    flex: 1;
    position: relative;
    z-index: 1;
}

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

/* ========== DETAIL PANEL ========== */
.detail-panel {
    position: absolute;
    bottom: 24px;
    /* Bottom */
    right: 24px;
    /* Right */
    left: auto;
    /* Reset left */
    top: auto;
    /* Reset top */
    transform: none !important;
    /* Remove centering */

    width: 750px;
    /* Wide Landscape */
    height: 450px;
    /* Increased Height */
    background: var(--bg-white);
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    padding: 24px;
    display: none;
    z-index: 2000;

    /* Layout */
    /* Layout */
    display: none;
    grid-template-columns: 280px 1fr;
    /* Widen left column */
    gap: 24px;
    align-items: start;
}

.detail-panel.active {
    display: grid !important;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-light);
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
}

.close-btn:hover {
    background: #e0e0e0;
    color: var(--text-dark);
}

/* LEFT COLUMN: Info */
.detail-info {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    /* Prevent Bleeding */
    padding-right: 8px;
    /* Scrollbar space */
}

.detail-header {
    margin-bottom: 24px;
    flex-shrink: 0;
    /* Header won't shrink */
}

.detail-header h3 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-dark);
    line-height: 1.2;
}

.detail-subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.priority-badge {
    display: inline-block;
    margin-top: 12px;
    font-size: 0.85rem;
    padding: 6px 16px;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.priority-badge.critical {
    background: #ffebee;
    color: var(--priority-critical);
}

.priority-badge.severe {
    background: #fff3e0;
    color: var(--priority-severe);
}

.priority-badge.shock {
    background: #fff8e1;
    color: var(--priority-shock);
}

.priority-badge.surge {
    background: #e3f2fd;
    color: var(--priority-surge);
}

.priority-badge.safe {
    background: #e8f5e9;
    color: var(--priority-safe);
}

.detail-metrics {
    display: flex;
    flex-direction: column;
    /* Stack Vertical in Left Col */
    gap: 12px;
    margin-top: auto;
    /* Push to bottom of info col */
    margin-bottom: 24px;
    flex-shrink: 0;
}

.metric {
    text-align: left;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-light);
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.metric-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-blue);
}

.metric-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.anomaly-flags {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.flag {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 4px;
    background: #eee;
    color: #555;
    font-weight: 500;
}

/* RIGHT COLUMN: Graph */
.detail-graph-area {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chart-container {
    flex: 1;
    /* Fill remaining height */
    height: auto !important;
    min-height: 0;
    position: relative;
    width: 100%;
}

/* ========== SCROLLBAR ========== */
.pincode-list::-webkit-scrollbar,
.detail-panel::-webkit-scrollbar {
    width: 6px;
}

.pincode-list::-webkit-scrollbar-track,
.detail-panel::-webkit-scrollbar-track {
    background: transparent;
}

.pincode-list::-webkit-scrollbar-thumb,
.detail-panel::-webkit-scrollbar-thumb {
    background: #bdbdbd;
    border-radius: 3px;
}

.pincode-list::-webkit-scrollbar-thumb:hover,
.detail-panel::-webkit-scrollbar-thumb:hover {
    background: #9e9e9e;
}