/* ============================================
   FONT DEFINITIONS
   ============================================ */

@font-face {
    font-family: 'Cormorant Garamond';
    src: url('../assets/fonts/CormorantGaramond-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Cormorant Garamond';
    src: url('../assets/fonts/CormorantGaramond-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Cormorant Garamond';
    src: url('../assets/fonts/CormorantGaramond-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Telegraf';
    src: url('../assets/fonts/Telegraf-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* ============================================
   COLOR PALETTE VARIABLES
   ============================================ */

:root {
    /* Brand colours - sampled from KANAN LABS logo */
    --brand-navy: #0a2f52;
    --brand-cream: #F4EBD0;

    /* Primary text - charcoal, avoiding pure black */
    --text-primary: #1C1C1E;
    --text-secondary: #4A4A4C;
    --text-tertiary: #6B6B6E;

    /* Primary accent - deep navy for interactive elements */
    --accent-primary: #142166;
    --accent-primary-light: rgba(20, 33, 102, 0.1);

    /* Secondary accent - amber for highlights and borders */
    --accent-amber: #B45309;
    --accent-amber-light: rgba(180, 83, 9, 0.15);

    /* Backgrounds - light and neutral */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F8F9FA;
    --bg-tertiary: #F1F3F5;

    /* Page background - navy to match brand */
    --bg-page: #0a2f52;
    --bg-page-bottom: #0a2f52;

    /* Map frame - softened for cohesion on dark bg */
    --frame-border: rgba(244, 235, 208, 0.1);
    --frame-shadow: rgba(0, 0, 0, 0.25);
    --frame-radius: 12px;

    /* Map colors */
    --map-fill: #4A90E2;
    --map-fill-hover: #3A7BC8;
    --map-border: #2C3E50;

    /* Animation timing */
    --transition-duration: 450ms;
    --transition-easing: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    height: calc(var(--vh, 1vh) * 100); /* JavaScript-calculated viewport height */
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--brand-navy);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ============================================
   PAGE WRAPPER - Full viewport container
   ============================================ */

.page-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    height: calc(var(--vh, 1vh) * 100); /* JavaScript-calculated viewport height */
    overflow: hidden;
}

/* ============================================
   LAYER 1: INSTITUTIONAL HEADER (Persistent)
   ============================================ */

.institutional-header {
    background: var(--brand-navy);
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 101;
    height: 48px;
}

.institutional-header > a:first-child {
    display: flex;
    align-items: center;
    height: 100%;
}

.brand-logo {
    height: 46px;
    width: auto;
    display: block;
}

.institutional-nav {
    display: flex;
    gap: 2rem;
}

.institutional-nav a {
    font-family: 'Telegraf', 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--brand-cream);
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.15s ease;
    letter-spacing: 0.01em;
}

.institutional-nav a:hover {
    opacity: 1;
}

/* ============================================
   LAYER 2: PRODUCT HERO (Page-Specific) - Compact
   ============================================ */

.product-hero {
    background: var(--brand-navy);
    padding: 0.375rem 2rem 0.375rem 2rem;
    text-align: center;
    flex-shrink: 0;
    z-index: 100;
}

.product-hero h1 {
    font-family: 'Cormorant Garamond', 'Playfair Display', Georgia, serif;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--brand-cream);
    margin-bottom: 0.375rem;
    letter-spacing: -0.01em;
}

.product-hero .product-subtitle {
    display: none; /* Hidden - keeping code for potential future use */
}

.product-hero .product-byline {
    display: none; /* Moved to footer */
}

/* Controls: toggle centered, timestamp below */
.product-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
}

.system-status {
    font-family: 'Telegraf', 'Inter', sans-serif;
    font-size: 0.625rem;
    color: var(--brand-cream);
    opacity: 0.5;
    font-weight: 400;
    letter-spacing: 0.01em;
    order: 2; /* Place below toggle */
}

/* Legacy header styles - kept for backwards compatibility */
header {
    background: var(--accent-primary);
    color: var(--bg-primary);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 20px rgba(20, 33, 102, 0.15);
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

.header-content h1 {
    font-family: 'Cormorant Garamond', 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* View Mode Toggle */
.view-toggle {
    display: flex;
    background: rgba(244, 235, 208, 0.15);
    border-radius: 6px;
    padding: 3px;
    position: relative;
    order: 1; /* Place first in flex container */
}

.toggle-option {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(244, 235, 208, 0.6);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    z-index: 1;
    font-family: 'Telegraf', 'Inter', sans-serif;
}

.toggle-option:hover {
    color: var(--brand-cream);
}

.toggle-option.active {
    color: var(--brand-navy);
}

.toggle-option svg {
    width: 12px;
    height: 12px;
}

.toggle-indicator {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 3px);
    height: calc(100% - 6px);
    background: var(--brand-cream);
    border-radius: 4px;
    transition: transform var(--transition-duration) var(--transition-easing);
    z-index: 0;
}

.view-toggle.all-india-active .toggle-indicator {
    transform: translateX(100%);
}

.view-toggle.all-india-active .toggle-option:first-child {
    color: rgba(244, 235, 208, 0.6);
}

.view-toggle.all-india-active .toggle-option:first-child.active {
    color: rgba(244, 235, 208, 0.6);
}

.view-toggle.all-india-active .toggle-option:last-child {
    color: var(--brand-navy);
}

/* Fix: Ensure non-active toggle in all-india mode is visible */
.view-toggle:not(.all-india-active) .toggle-option:last-child {
    color: rgba(244, 235, 208, 0.6);
}

.view-toggle:not(.all-india-active) .toggle-option:first-child {
    color: var(--brand-navy);
}

/* ============================================
   MAIN CONTAINER & FRAMED LAYOUT
   ============================================ */

.main-container {
    flex: 1;
    display: flex;
    padding: 0.75rem 1rem 0.5rem 1rem;
    gap: 1rem;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

/* ============================================
   MAP FRAME - The framed container for the map
   Animates width only; map itself is never transformed
   ============================================ */

.map-frame {
    flex: 1;
    min-width: 0;
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--frame-radius);
    border: 1px solid var(--frame-border);
    box-shadow: 0 2px 12px var(--frame-shadow);
    overflow: hidden;
    transition:
        flex var(--transition-duration) var(--transition-easing),
        opacity var(--transition-duration) var(--transition-easing);
    will-change: flex, opacity;
}

/* When panel opens, map frame shrinks to make room */
.map-frame.panel-open {
    flex: 0 0 30%;
}

/* When switching to All India view, map frame fades and collapses */
.map-frame.hidden {
    flex: 0 0 0%;
    opacity: 0;
    pointer-events: none;
    transition:
        flex var(--transition-duration) var(--transition-easing),
        opacity var(--transition-duration) var(--transition-easing);
}

/* Map container inside the frame - fills the frame entirely */
.map-container {
    width: 100%;
    height: 100%;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    background: var(--bg-secondary);
}

/* Info Icon & Tooltip - positioned within the frame */
.map-info-trigger {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    width: 28px;
    height: 28px;
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: Georgia, serif;
    transition: all 0.15s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.map-info-trigger:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 2px 8px rgba(20, 33, 102, 0.12);
}

.map-info-tooltip {
    position: absolute;
    top: 46px;
    right: 12px;
    z-index: 1000;
    width: 280px;
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 8px;
    padding: 14px 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px) scale(0.98);
    transform-origin: top right;
    transition: all 0.2s ease;
    pointer-events: none;
}

.map-info-tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.map-info-tooltip p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0;
}

/* ============================================
   SIDE PANEL (State View) - Framed style
   ============================================ */

.side-panel {
    width: 0;
    min-width: 0;
    min-height: 0; /* Critical: Allow flex child to shrink */
    height: 100%; /* Explicit height constraint */
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--frame-radius);
    border: 1px solid var(--frame-border);
    box-shadow:
        0 8px 32px var(--frame-shadow),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    /*
     * Panel slides in synchronized with map frame shrinking.
     * Both use the same timing for coordinated animation.
     */
    transition:
        width var(--transition-duration) var(--transition-easing),
        min-width var(--transition-duration) var(--transition-easing),
        opacity var(--transition-duration) var(--transition-easing);
    will-change: width, opacity;
}

.side-panel.open {
    width: 70%;
    min-width: 400px;
    opacity: 1;
    /* Ensure panel can shrink to fit container */
    max-height: 100%;
}

.panel-header {
    background: var(--brand-cream);
    color: var(--brand-navy);
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--accent-amber);
    flex-shrink: 0;
    border-radius: var(--frame-radius) var(--frame-radius) 0 0;
}

.panel-header h2 {
    font-family: 'Cormorant Garamond', 'Playfair Display', serif;
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--brand-navy);
    letter-spacing: -0.01em;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--brand-navy);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(10, 47, 82, 0.1);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 1.5rem;
    background: var(--bg-secondary);
}

/* ============================================
   ALL INDIA PANEL (Full Width View) - Framed
   ============================================ */

.all-india-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-secondary);
    border-radius: var(--frame-radius);
    border: 1px solid var(--frame-border);
    box-shadow:
        0 8px 32px var(--frame-shadow),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    z-index: 200;
    transition: opacity var(--transition-duration) var(--transition-easing);
}

.all-india-panel.visible {
    opacity: 1;
    pointer-events: auto;
}

.all-india-header {
    background: var(--bg-primary);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--bg-tertiary);
    border-radius: var(--frame-radius) var(--frame-radius) 0 0;
    flex-shrink: 0;
}

.all-india-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.all-india-subtitle {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

.all-india-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 1.5rem 2rem;
}

/* ============================================
   CATEGORY CARDS (Horizontal Rail)
   ============================================ */

.category-rail {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 1.5rem;
}

.category-card-compact {
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.category-card-compact:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 2px 12px rgba(20, 33, 102, 0.08);
}

.category-card-compact.active {
    border-color: var(--accent-primary);
    background: var(--accent-primary-light);
}

.category-card-compact.active .card-expand-hint {
    transform: rotate(180deg);
    color: var(--accent-primary);
}

.category-card-compact.empty {
    opacity: 0.5;
}

.category-card-compact.empty:hover {
    border-color: var(--bg-tertiary);
    box-shadow: none;
}

.card-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    position: relative;
}

/* Green indicator dot for new updates today */
.new-indicator {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 10px;
    height: 10px;
    background: #10b981;
    border: 2px solid var(--bg-primary);
    border-radius: 50%;
    animation: pulse-indicator 2s ease-in-out infinite;
}

@keyframes pulse-indicator {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

.card-info {
    flex: 1;
    min-width: 0;
}

.card-name {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.card-count {
    display: block;
    font-size: 0.6875rem;
    color: var(--text-tertiary);
}

.card-expand-hint {
    color: var(--text-tertiary);
    transition: transform 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

/* ============================================
   EXPANDED CATEGORY CONTENT
   ============================================ */

.expanded-content {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition:
        max-height 0.3s ease,
        opacity 0.2s ease;
    display: block;
}

.expanded-content.visible {
    max-height: 5000px;
    overflow: visible;
    opacity: 1;
    display: block;
}

.expanded-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 2px solid var(--accent-primary);
    margin-bottom: 1rem;
}

.expanded-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.collapse-btn {
    background: transparent;
    border: 1px solid var(--bg-tertiary);
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.collapse-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.updates-list-expanded {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.no-updates-inline {
    text-align: center;
    padding: 2rem;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

/* ============================================
   UPDATE ITEMS
   ============================================ */

.update-item {
    background: var(--bg-primary);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    border-left: 3px solid var(--accent-primary);
    transition: all 0.15s ease;
}

.update-item:hover {
    box-shadow: 0 2px 8px rgba(20, 33, 102, 0.08);
    transform: translateX(2px);
}

.update-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-primary);
    text-decoration: none;
    display: block;
    margin-bottom: 6px;
    line-height: 1.4;
}

.update-title:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.update-summary {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 6px;
}

.update-date {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.no-updates {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-tertiary);
    font-size: 0.9375rem;
}

/* ============================================
   PAGINATION CONTROLS
   ============================================ */

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    padding-bottom: 0.5rem;
    border-top: 1px solid var(--bg-tertiary);
    width: 100%;
    position: relative;
    z-index: 1;
}

.pagination-btn {
    background: var(--bg-primary);
    border: 1.5px solid #0a2f52;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #0a2f52;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-width: 80px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: rgba(10, 47, 82, 0.1);
    touch-action: manipulation;
}

.pagination-btn:hover:not(:disabled) {
    background: #0a2f52;
    color: var(--bg-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(10, 47, 82, 0.2);
}

.pagination-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(10, 47, 82, 0.15);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: var(--bg-tertiary);
    color: var(--text-tertiary);
    background: var(--bg-secondary);
}

.pagination-info {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-width: 100px;
    text-align: center;
}

/* Mobile responsive pagination */
@media (max-width: 768px) {
    .expanded-content {
        display: block !important;
        transition: opacity 0.2s ease !important;
    }

    .expanded-content.visible {
        max-height: none !important;
        overflow: visible !important;
        display: block !important;
        height: auto !important;
        opacity: 1 !important;
    }

    .pagination-controls {
        flex-wrap: wrap;
        gap: 0.75rem;
        margin-top: 1.25rem;
        padding-top: 1.25rem;
        padding-bottom: 1rem;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        width: 100% !important;
        box-sizing: border-box !important;
        z-index: 10 !important;
    }

    .pagination-btn {
        flex: 1;
        min-width: 0;
        padding: 0.625rem 0.875rem;
        font-size: 0.75rem;
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
    }

    .pagination-info {
        flex-basis: 100%;
        min-width: 0;
        font-size: 0.75rem;
        order: -1;
        margin-bottom: 0.25rem;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
    }
}

@media (max-width: 480px) {
    .pagination-controls {
        gap: 0.5rem;
        margin-top: 1rem;
        padding-top: 1rem;
    }

    .pagination-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.6875rem;
        min-width: 70px;
    }

    .pagination-info {
        font-size: 0.6875rem;
        margin-bottom: 0.5rem;
    }
}

/* ============================================
   LEAFLET OVERRIDES & TOOLTIPS
   ============================================ */

/* Remove focus outline from map SVG paths (the blue box on click) */
.leaflet-interactive:focus {
    outline: none;
}

.leaflet-container svg path:focus {
    outline: none;
}

.leaflet-tooltip.state-tooltip {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--accent-amber);
    border-radius: 4px;
    padding: 6px 10px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(20, 33, 102, 0.12);
    white-space: nowrap;
    transition: opacity 0.1s ease;
    line-height: 1.4;
}

.leaflet-tooltip.state-tooltip::before {
    border-top-color: var(--accent-amber);
}

.state-tooltip .tooltip-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.state-tooltip .state-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.8125rem;
}

.state-tooltip .update-indicator {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    font-weight: 400;
}

.state-tooltip .update-indicator .count {
    color: var(--accent-amber);
    font-weight: 600;
}

.state-tooltip .update-indicator.no-updates {
    color: var(--text-tertiary);
    opacity: 0.6;
    font-size: 0.75rem;
}

/* ============================================
   LOADING & UTILITY STATES
   ============================================ */

.loading {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-tertiary);
}

.loading::after {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--bg-tertiary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

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

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

.panel-content::-webkit-scrollbar,
.all-india-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-track,
.all-india-content::-webkit-scrollbar-track {
    background: transparent;
}

.panel-content::-webkit-scrollbar-thumb,
.all-india-content::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 3px;
}

.panel-content::-webkit-scrollbar-thumb:hover,
.all-india-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ============================================
   FOOTER
   ============================================ */

.site-footer {
    background: transparent;
    padding: 0.5rem 2rem;
    text-align: center;
    flex-shrink: 0;
}

.footer-brand {
    font-family: 'Cormorant Garamond', 'Playfair Display', Georgia, serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--brand-cream);
    opacity: 0.6;
    margin-bottom: 0.125rem;
    letter-spacing: 0.02em;
}

.footer-byline {
    font-family: 'Telegraf', 'Inter', sans-serif;
    font-size: 0.5625rem;
    font-style: italic;
    color: var(--brand-cream);
    opacity: 0.4;
    margin-bottom: 0.25rem;
}

.footer-attribution {
    font-family: 'Telegraf', 'Inter', sans-serif;
    font-size: 0.6875rem;
    color: var(--brand-cream);
    opacity: 0.4;
    margin-bottom: 0.25rem;
}

.footer-links {
    font-family: 'Telegraf', 'Inter', sans-serif;
    font-size: 0.5625rem;
    color: var(--brand-cream);
    opacity: 0.35;
    margin-bottom: 0.25rem;
}

.footer-links a {
    color: var(--brand-cream);
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.footer-links a:hover {
    opacity: 0.8;
}

.footer-links .separator {
    margin: 0 0.375rem;
    opacity: 0.3;
}

.footer-description {
    display: none; /* Hidden in compact layout */
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1200px) {
    .category-rail {
        grid-template-columns: repeat(2, 1fr);
    }

    .map-frame.panel-open {
        flex: 0 0 25%;
    }

    .side-panel.open {
        width: 75%;
        min-width: 350px;
    }
}

@media (max-width: 768px) {
    /* Institutional header - mobile */
    .institutional-header {
        padding: 0 0.75rem;
        height: 40px;
    }

    .brand-logo {
        height: 38px;
    }

    .institutional-nav {
        gap: 1rem;
    }

    .institutional-nav a {
        font-size: 0.75rem;
    }

    /* Product hero - mobile */
    .product-hero {
        padding: 0.25rem 1rem 0.25rem 1rem;
    }

    .product-hero h1 {
        font-size: 1rem;
        margin-bottom: 0.25rem;
    }

    .product-controls {
        gap: 0.25rem;
    }

    .system-status {
        font-size: 0.5625rem;
    }

    /* Legacy header - mobile */
    header {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.875rem 1.25rem;
        text-align: center;
    }

    .header-content h1 {
        font-size: 1.25rem;
    }

    .view-toggle {
        width: auto;
    }

    .toggle-option {
        padding: 5px 10px;
        font-size: 0.6875rem;
    }

    .main-container {
        padding: 0.5rem;
        gap: 0.5rem;
        min-height: 0;
    }

    .map-frame.panel-open {
        flex: 0 0 0%;
        opacity: 0;
        pointer-events: none;
    }

    .side-panel.open {
        width: 100%;
        min-width: 0;
    }

    .category-rail {
        grid-template-columns: 1fr;
    }

    .all-india-panel {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100%;
        max-height: 100%;
    }

    .all-india-header {
        padding: 1.25rem;
        flex-shrink: 0;
    }

    .all-india-content {
        padding: 1.25rem;
        flex: 1 1 0%;
        min-height: 0;
        max-height: none; /* Remove any max-height constraint */
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }

    .panel-content {
        padding: 1rem 1.25rem;
        flex: 1 1 0%;
        min-height: 0;
        max-height: none; /* Remove any max-height constraint */
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }

    /* Ensure expanded content and pagination are fully visible on mobile */
    .expanded-content {
        display: block !important;
    }

    .expanded-content.visible {
        max-height: none !important;
        overflow: visible !important;
        padding-bottom: 1.5rem;
        min-height: auto !important;
        height: auto !important;
        display: block !important;
    }

    .pagination-controls {
        position: relative !important;
        z-index: 10 !important;
        margin-bottom: 0.5rem;
        margin-top: 1.5rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .pagination-btn {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .pagination-info {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .side-panel {
        height: 100%;
        max-height: 100%;
    }

    .side-panel.open {
        height: 100%;
        max-height: 100%;
    }

    .site-footer {
        padding: 0.375rem 0.75rem;
    }

    .footer-byline {
        font-size: 0.5rem;
    }

    .footer-links {
        font-size: 0.5rem;
    }

    .map-info-tooltip {
        width: 200px;
        right: 8px;
    }

    :root {
        --frame-radius: 8px;
    }
}

/* Mobile phones - hide nav (links available in footer) */
@media (max-width: 480px) {
    .institutional-header {
        padding: 0 0.5rem;
        height: 36px;
        justify-content: center;
    }

    .brand-logo {
        height: 34px;
    }

    .institutional-nav {
        display: none;
    }

    .product-hero {
        padding: 0.25rem 0.75rem 0.125rem 0.75rem;
    }

    .product-hero h1 {
        font-size: 0.875rem;
        margin-bottom: 0.125rem;
    }

    .toggle-option {
        padding: 4px 8px;
        font-size: 0.625rem;
        gap: 3px;
    }

    .toggle-option svg {
        width: 10px;
        height: 10px;
    }

    .system-status {
        font-size: 0.5rem;
    }

    .main-container {
        padding: 0.375rem;
        min-height: 0;
        /* Force explicit height for mobile */
        flex: 1 1 0%;
    }

    .all-india-content,
    .panel-content {
        flex: 1 1 0%;
        min-height: 0;
        max-height: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }

    .footer-byline {
        font-size: 0.4375rem;
    }

    .footer-links {
        font-size: 0.4375rem;
    }

    .footer-links .separator {
        margin: 0 0.25rem;
    }
}

/* ============================================
   MOBILE LANDSCAPE ORIENTATION FIXES
   ============================================ */

@media (max-width: 768px) and (orientation: landscape) {
    /* Reduce header heights to maximize content space */
    .institutional-header {
        padding: 0 0.5rem;
        height: 32px;
    }

    .brand-logo {
        height: 30px;
    }

    .product-hero {
        padding: 0.125rem 0.75rem;
    }

    .product-hero h1 {
        font-size: 0.875rem;
        margin-bottom: 0.125rem;
    }

    .system-status {
        font-size: 0.5rem;
    }

    .toggle-option {
        padding: 3px 6px;
        font-size: 0.625rem;
    }

    /* Optimize main container for landscape */
    .main-container {
        padding: 0.25rem;
        gap: 0.25rem;
        min-height: 0;
    }

    /* Reduce padding in content areas */
    .panel-content {
        padding: 0.75rem 1rem;
    }

    .all-india-content {
        padding: 0.75rem 1rem;
    }

    .all-india-header {
        padding: 0.75rem 1rem;
    }

    .panel-header {
        padding: 0.75rem 1rem;
    }

    /* Reduce category card padding */
    .category-card-compact {
        padding: 10px 12px;
    }

    .card-icon {
        font-size: 1.25rem;
    }

    .card-name {
        font-size: 0.75rem;
    }

    .card-count {
        font-size: 0.625rem;
    }

    /* Reduce update item padding */
    .update-item {
        padding: 0.75rem 1rem;
    }

    .update-title {
        font-size: 0.85rem;
    }

    .update-summary {
        font-size: 0.75rem;
    }

    .update-date {
        font-size: 0.625rem;
    }

    /* Reduce expanded header padding */
    .expanded-header {
        padding: 0.75rem 0;
        margin-bottom: 0.75rem;
    }

    .expanded-header h3 {
        font-size: 0.9375rem;
    }

    /* Optimize pagination for landscape */
    .pagination-controls {
        margin-top: 1rem;
        padding-top: 1rem;
        padding-bottom: 0.75rem;
        gap: 0.5rem;
    }

    .pagination-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.6875rem;
        min-width: 65px;
    }

    .pagination-info {
        font-size: 0.6875rem;
        margin-bottom: 0.375rem;
    }

    /* Reduce footer size */
    .site-footer {
        padding: 0.25rem 0.5rem;
    }

    .footer-byline {
        font-size: 0.4375rem;
        margin-bottom: 0.125rem;
    }

    .footer-links {
        font-size: 0.4375rem;
        margin-bottom: 0.125rem;
    }
}
