/* ===== CSS Variables ===== */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --accent: #f59e0b;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 8px;
    --sidebar-width: 320px;
    --header-height: 56px;
    --footer-height: 36px;
    --transition: 0.3s ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Disclaimer Banner ===== */
.disclaimer-banner {
    background: #fef3c7;
    border-bottom: 2px solid #f59e0b;
    color: #92400e;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
    animation: slideDown 0.3s ease;
}
.disclaimer-banner.hidden { display: none; }
.disclaimer-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    line-height: 1.4;
}
.disclaimer-content > i {
    font-size: 16px;
    color: #d97706;
    flex-shrink: 0;
}
.disclaimer-content a {
    color: #92400e;
    font-weight: 600;
    text-decoration: underline;
}
.disclaimer-content a:hover { color: #78350f; }
.disclaimer-close {
    background: none;
    border: none;
    color: #92400e;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 14px;
    border-radius: 4px;
    flex-shrink: 0;
}
.disclaimer-close:hover { background: #fde68a; }
@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ===== Header ===== */
.header {
    height: var(--header-height);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    flex-shrink: 0;
}

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

.header-left i { font-size: 22px; }
.header-left h1 { font-size: 18px; font-weight: 600; white-space: nowrap; }

.header-right { display: flex; gap: 10px; }

.badge {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

/* ===== Main Layout ===== */
.main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-shrink: 0;
    transition: margin-left var(--transition);
    z-index: 900;
    position: relative;
}

.sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-toggle {
    position: absolute;
    right: -32px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 60px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 12px;
    z-index: 10;
    box-shadow: var(--shadow);
    transition: background var(--transition);
}

.sidebar-toggle:hover { background: var(--primary-light); color: var(--primary); }
.sidebar.collapsed .sidebar-toggle i { transform: rotate(180deg); }

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    scrollbar-width: thin;
}

/* ===== Panels ===== */
.panel {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
}

.panel h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.panel h3 i { color: var(--primary); font-size: 14px; }

/* ===== Search ===== */
.search-group {
    display: flex;
    gap: 6px;
}

.search-group input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

.search-group input:focus { border-color: var(--primary); }

.search-group button {
    width: 38px;
    height: 38px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}

.search-group button:hover { background: var(--primary-dark); }

.search-results {
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.search-result-item {
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 13px;
}

.search-result-item:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.search-result-item .pincode {
    font-weight: 700;
    color: var(--primary);
    font-size: 15px;
}

.search-result-item .details {
    color: var(--text-secondary);
    font-size: 11px;
    margin-top: 2px;
}

/* ===== Filters ===== */
.filter-group {
    margin-bottom: 10px;
}

.filter-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.filter-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    outline: none;
}

.filter-group select:focus { border-color: var(--primary); }
.filter-group select:disabled { opacity: 0.5; cursor: not-allowed; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    width: 100%;
}

.btn-secondary {
    background: var(--border);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: #cbd5e1;
    color: var(--text);
}

/* ===== Info Panel ===== */
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.info-row:last-child { border-bottom: none; }
.info-row .label { color: var(--text-secondary); }
.info-row .value { font-weight: 600; text-align: right; }

/* ===== Stats ===== */
.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.stat-row:last-child { border-bottom: none; }
.stat-row span { color: var(--text-secondary); }
.stat-row strong { color: var(--primary-dark); }

/* ===== Map ===== */
.map-container {
    flex: 1;
    position: relative;
}

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

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 800;
    gap: 12px;
    transition: opacity var(--transition);
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== Footer ===== */
.footer {
    height: var(--footer-height);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* ===== Leaflet Popup ===== */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-lg) !important;
}

.popup-content {
    min-width: 200px;
    padding: 4px;
}

.popup-content h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
}

.popup-content table {
    width: 100%;
    font-size: 12px;
    border-collapse: collapse;
}

.popup-content td {
    padding: 3px 0;
    border-bottom: 1px solid var(--border);
}

.popup-content td:first-child {
    color: var(--text-secondary);
    padding-right: 12px;
}

.popup-content td:last-child { font-weight: 500; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    :root { --sidebar-width: 280px; }
    
    .header-left h1 { font-size: 15px; }
    .badge { font-size: 11px; padding: 3px 8px; }
    
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 1000;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-width)); }
}
