/* ============================================================
   GLOBAL BASE TOKENS (Color, spacing, shadow, radius, etc.)
   These variables are used across the dashboard (top stats, map,
   timeline, trained warden list cards).
============================================================ */
:root {
    /* brand / theme colors */
    --primary: #1A486B;
    /* main heading / accent text */
    --bg: #F4F7FA;
    /* page background */
    --card: #F4F7FA;
    /* pill / card beige */
    --muted: #5E8EA7;
    /* warm accent text for sub labels, hints */
    --pill: #2C6286;
    /* reserved for pill accents (not used below but kept) */

    /* blues + accents */
    --light: #2C6286;
    /* soft mid-blue tone */
    --soft: #5E8EA7;
    /* muted blue */
    --accent: #F4F7FA;
    /* very light soft white-blue */
    --ink: #1A2E40;
    /* primary text ink */

    /* radii / shadows for dashboard cards */
    --radius: 16px;
    --shadow: 0 10px 24px rgba(0, 0, 0, .08);

    /* -------- Extra tokens used by the Trained Warden section -------- */
    --bg-page: #F4F7FA;
    /* page bg (same as --bg, kept separate for clarity) */
    --card-bg: #F4F7FA;
    /* outer card background for trained section cards */
    --border-soft: rgba(0, 0, 0, .08);
    /* subtle stroke lines / borders */
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, .08),
        inset 0 0 0 1px rgba(255, 255, .6, .6);
    /* soft glow shadow */
    --radius-lg: 18px;
    /* larger radius for trained cards */
    --text-main: #1A2E40;
    /* dark text for rows/names */
    --text-muted: #5E8EA7;
    /* warm accent subtitle color */
    --heading-weight: 700;
    /* section subheading weight */
    --title-weight: 800;
    /* main title weight */
    --scrollbar-thumb: rgba(0, 0, 0, .25);
    /* scrollbar thumb color */
}

/* ============================================================
   GLOBAL RESET-LIKE RULES
   Basic box model + typography defaults for the whole page
============================================================ */
* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    /* light slate bg */
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial;
}

h1,
h2,
h3 {
    margin: 0 0 .5rem;
    /* first reset bottom margin, top handled by parent layout */
}

/* ============================================================
   HEADER STRIP AT TOP OF DASHBOARD
   Displays the main heading & subtitle ("National Overview")
============================================================ */
.header-section {
    text-align: center;
    padding: 18px 14px;
    background: #E9EFF5;
    /* pale slate/blue bar */
    border-bottom: 1px solid #D0E0F0;
    /* subtle bottom border */
}

.header-section h1 {
    color: var(--primary);
    /* brand heading color */
    font-weight: 800;
    /* bold heading */
    font-size: 1.6rem;
    /* base size for desktop */
    letter-spacing: .2px;
    /* slight tracking for polish */
}

.header-section p {
    color: var(--muted);
    /* warm accent text */
    font-size: .95rem;
    /* slightly smaller subtitle */
}

/* ============================================================
   MAIN TOP GRID: LEFT PILL STATS | INDIA MAP | RIGHT PILL STATS
   .shell creates a 3-column layout on desktop, collapses on mobile
============================================================ */
.shell {
    display: grid;
    grid-template-columns: 260px 1fr 260px;
    /* left col / map / right col */
    gap: 22px;
    max-width: 1200px;
    padding: 22px 16px;
    margin: 0 auto;
    align-items: center;
    /* vertically center side columns with map */
}

/* Side columns (.side) hold the stat "pills" */
.side {
    display: flex;
    flex-direction: column;
    gap: 22px;
    justify-content: center;
    /* center stack in column vertically */
}

/* Each stats pill on left/right of the map */
.stat-pill {
    background: var(--card);
    /* beige background */
    border-radius: 24px;
    box-shadow: var(--shadow);
    /* soft drop shadow */
    padding: 18px 18px;
    border: 2px solid #E0EAF2;
    /* subtle inner border tone */
}

/* Title text in pill */
.pill-title {
    color: #1A2E40;
    /* darker bluish text */
    font-weight: 700;
    margin-bottom: 6px;
}

/* Highlight number in pill */
.pill-value {
    color: var(--primary);
    /* brand color */
    font-weight: 900;
    font-size: 1.4rem;
}

/* ============================================================
   MAP CARD (center column in the shell)
============================================================ */
.map-card {
    border-radius: 14px;
    padding: 16px;
    min-height: 1000px;
    /* ensures map area has presence on desktop */
    display: flex;
    flex-direction: column;
}

.map-title {
    color: var(--primary);
    font-size: 1.05rem;
    margin-bottom: auto;
    text-align: center;
}

/* container where amCharts renders India map */
#indiaMap {
    flex: 1;
    min-height: 420px;
    /* map minimum height so it’s usable even with little data */
}

/* hint text under map (e.g. "click any state…") */
.map-hint {
    margin-top: 10px;
    background: #E6EEF6;
    border: 1px dashed #BFD5E6;
    border-radius: 10px;
    padding: 10px;
    color: #1D546C;
    font-size: .92rem;
    text-align: center;
}


/* ============================================================
   TIMELINE TABLE (date-wise schedule of trainings)
   - Used for Master Trainer & Warden timelines
   - This version:
       • Keeps true table layout on all breakpoints
       • Uses .table-responsive for horizontal scroll
       • Adds sticky first column (State / UT) on ≥576px
============================================================ */

/* ---- Outer wrapper for timeline section ----
   Applied on: <section class="timeline-wrap"> ... </section>
   It controls max width and horizontal padding for tables + headings.
*/
.timeline-wrap {
    max-width: 1550px;
    margin: 8px auto 28px;
    /* sits below the top shell */
    padding: 0 16px;
}

/* Optional timeline title (if used as .tbl-title) */
.tbl-title {
    color: var(--primary);
    margin: 8px 0 10px;
    font-size: 1.05rem;
}

/* Legacy: .tbl-scroll wrapper – kept for compatibility
   If you use it elsewhere, it still works as a soft card with scroll.
   For current markup (Master/Warden timelines) we rely on Bootstrap’s
   .table-responsive inside .timeline-wrap.
*/
.tbl-scroll {
    background: var(--card);
    /* beige box like stat pills */
    border-radius: 14px;
    box-shadow: var(--shadow);
    /* same soft drop shadow */
    padding: 8px 12px;
    overflow-x: auto;
    /* horizontal scroll for narrow screens */
    -webkit-overflow-scrolling: touch;
}

/* New: main scroll wrapper for your current markup
   HTML:
   <section class="timeline-wrap">
     ...
     <div class="table-responsive">
       <table class="table ... timeline-table">
         ...
*/
.timeline-wrap .table-responsive {
    background: var(--card);
    /* card-like background */
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 8px 12px;
    overflow-x: auto;
    /* horizontal scroll for narrow screens */
    -webkit-overflow-scrolling: touch;
    position: relative;
    /* anchor for sticky first column */
}

/* ---- Base table appearance (all screens) ---- */
.timeline-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
    min-width: 720px;
    /* keeps columns readable on mid/large screens */
}

/* Table cells (head + body) */
.timeline-table th,
.timeline-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #E2E8F0;
    /* row separator line */
    text-align: center;
    vertical-align: middle;
}

/* Table header styling */
.timeline-table thead th {
    color: #1A486B;
    font-weight: 600;
    white-space: nowrap;
    /* avoid wrapping short headings */
}

/* Hover row highlight for better readability */
.timeline-table tbody tr:hover {
    background: #F4F7FA;
    transition: background-color 0.2s ease-in-out;
}

/* Remove border from last row for a cleaner edge */
.timeline-table tbody tr:last-child td {
    border-bottom: none;
}

/* ------------------------------------------------------------
   STICKY FIRST COLUMN (State / UT)
   - Keeps first column visible while horizontally scrolling
   - Works for both completed + upcoming tables
   - Disabled on very small mobiles (≤575.98px) below
------------------------------------------------------------ */

/* First column cells (header + body) stick to the left edge
   of the .table-responsive container.
*/
.timeline-table th:first-child,
.timeline-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    /* above other cells */
    background: #F8FAFC;
    /* solid bg for readability while scrolling */
}

/* First header cell (State / UT header) sits on top of everything */
.timeline-table thead th:first-child {
    z-index: 3;
    background: #cfe2ff;
    /* close to .table-primary background */
    box-shadow: 4px 0 8px rgba(15, 23, 42, 0.15);
    /* vertical divider shadow */
}

/* Subtle separation shadow for body cells of first column */
.timeline-table tbody td:first-child {
    box-shadow: 4px 0 8px rgba(15, 23, 42, 0.08);
}

/* NOTE:
   Any inline background (e.g., style="background-color:#e5e6e3;")
   on first-column cells will override this background, which is
   desired (e.g., for grouping Telengana rows etc.).
*/


/* ------------------------------------------------------------
   RESPONSIVE BEHAVIOUR (by breakpoint)
   We keep table layout consistent and only adjust:
   - min-width
   - font sizes
   - paddings
   - wrapping rules for long columns (Venue)
------------------------------------------------------------ */

/* ≥1200px – large desktops */
@media (min-width: 1200px) {

    .timeline-wrap {
        padding: 0 24px;
    }

    .timeline-table {
        min-width: 900px;
    }

    .timeline-table th,
    .timeline-table td {
        padding: 14px 12px;
        font-size: 1rem;
    }
}

/* 992px–1199.98px – laptops, small desktops */
@media (min-width: 992px) and (max-width: 1199.98px) {

    .timeline-wrap {
        padding: 0 16px;
    }

    .timeline-table {
        min-width: 820px;
    }

    .timeline-table th,
    .timeline-table td {
        padding: 10px 8px;
        font-size: 0.95rem;
    }
}

/* 768px–991.98px – tablets */
@media (min-width: 768px) and (max-width: 991.98px) {

    .timeline-wrap {
        padding: 0 12px;
        margin: 6px auto 22px;
    }

    .timeline-wrap .table-responsive {
        padding: 8px 8px;
    }

    .timeline-table {
        min-width: 700px;
        font-size: 0.90rem;
    }

    .timeline-table th,
    .timeline-table td {
        padding: 9px 6px;
    }

    /* Allow wrapping for text-heavy columns (Venue) */
    .timeline-table th:nth-child(3),
    .timeline-table td:nth-child(3),
    .timeline-table th:nth-child(6),
    .timeline-table td:nth-child(6) {
        white-space: normal;
    }
}

/* 576px–767.98px – large mobiles / small tablets */
@media (min-width: 576px) and (max-width: 767.98px) {

    .timeline-wrap {
        padding: 0 10px;
        margin: 6px auto 20px;
    }

    .timeline-wrap .table-responsive {
        padding: 6px 6px;
    }

    .timeline-table {
        min-width: 640px;
        font-size: 0.88rem;
    }

    .timeline-table th,
    .timeline-table td {
        padding: 7px 6px;
    }

    /* Allow wrapping for long venue / remarks columns */
    .timeline-table th:nth-child(3),
    .timeline-table td:nth-child(3),
    .timeline-table th:nth-child(6),
    .timeline-table td:nth-child(6) {
        white-space: normal;
    }
}

/* ≤575.98px – extra small mobiles
   - Keep table layout (no card conversion so rowspans remain intact)
   - Slightly reduce font + padding
   - Force horizontal scroll inside .table-responsive
   - Disable sticky first column to avoid overly narrow scroll area
*/
@media (max-width: 575.98px) {

    .timeline-wrap {
        padding: 0 6px;
        margin: 6px auto 18px;
    }

    .timeline-wrap .table-responsive {
        padding: 6px 4px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .timeline-table {
        min-width: 520px;
        font-size: 0.80rem;
    }

    .timeline-table th,
    .timeline-table td {
        padding: 6px 4px;
        white-space: nowrap;
        /* default: keep values on one line */
    }

    /* But allow wrapping on heavy text columns (Venue) */
    .timeline-table th:nth-child(3),
    .timeline-table td:nth-child(3),
    .timeline-table th:nth-child(6),
    .timeline-table td:nth-child(6) {
        white-space: normal;
    }

    /* Disable sticky first column on very small phones */
    .timeline-table th:first-child,
    .timeline-table td:first-child {
        position: static;
        left: auto;
        z-index: 1;
        box-shadow: none;
    }

    .timeline-table thead th:first-child {
        box-shadow: none;
    }
}

/* ------------------------------------------------------------
   LEGACY MOBILE CARD LAYOUT (DISABLED, KEPT FOR REFERENCE)
   Previously: converted table rows into stacked cards on XS.
   This breaks rowspans, so we have moved to horizontal scroll.
   Kept here commented so you can revive if needed.
------------------------------------------------------------ */
/*
@media (max-width: 575.98px) {

    .tbl-scroll {
        padding: 6px;
        overflow-x: visible;  // convert to cards instead of scrolling
    }

    .timeline-table {
        border-collapse: separate;
        border-spacing: 0;
        min-width: 0;
    }

    .timeline-table thead {
        display: none; // hide header on mobile
    }

    .timeline-table tr {
        display: block;
        margin: 0 0 10px 0;
        padding: 8px 10px;
        background: #ffffff;
        border-radius: 10px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
        border: 1px solid #E2E8F0;
    }

    .timeline-table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 6px 0;
        border: none;
        border-bottom: 1px dashed #E2E8F0;
        font-size: 0.9rem;
        text-align: left;
    }

    .timeline-table td:last-child {
        border-bottom: none;
    }

    .timeline-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--primary);
        margin-right: 10px;
        flex: 0 0 52%;
        text-align: left;
        white-space: nowrap;
    }

    // Example mapping (original for 5-column table)
    .timeline-table td:nth-child(1)::before { content: "Visit"; }
    .timeline-table td:nth-child(2)::before { content: "State / UT"; }
    .timeline-table td:nth-child(3)::before { content: "Date (Start–End)"; }
    .timeline-table td:nth-child(4)::before { content: "No. of Wardens"; }
    .timeline-table td:nth-child(5)::before { content: "No. of Master Trainers"; }
}
*/


/* ============================================================
   OVERFLOW / Z-INDEX FIXES FOR ANY NAV/POPOVER CONTENT
   Ensures dropdown menus, etc. render above cards and sticky stuff
============================================================ */
.custom-navbar,
.custom-navbar *,
.card,
.dropdown,
.btn-group {
    overflow: visible !important;
}

.dropdown-menu {
    z-index: 2000;
}

/* ============================================================
   RESPONSIVENESS FOR THE TOP GRID (.shell) AND PILLS
   Breakpoints:
   - Under 1100px: tighter side columns
   - Under 900px: collapse the 3-col layout into 1-col stacked
============================================================ */
@media (max-width:1100px) {
    .shell {
        grid-template-columns: 220px 1fr 220px;
        /* slightly narrower side columns */
    }
}

@media (max-width:900px) {
    .shell {
        grid-template-columns: 1fr;
        /* single column: left stats, map, right stats stack vertically */
    }

    .side {
        flex-direction: row;
        /* pills go side-by-side on small screens */
        flex-wrap: wrap;
    }

    .stat-pill {
        flex: 1 1 260px;
        /* pills wrap evenly; min ~260px each */
    }

    .map-card {
        min-height: 420px;
        /* still give map breathing space on mobile */
    }
}

/* ============================================================
   TRAINED WARDEN / MASTERS LIST SECTION
   Appears AFTER the timeline.
   This section has two cards:
   - Wardens (auto-scroll upward, loop)
   - Masters (auto-scroll downward, loop)
============================================================ */

/* ---- Outer wrapper for this section ---- */
.trained-warden-wrap {
    max-width: 1200px;
    margin: 32px auto 40px;
    /* separation from timeline */
    padding: 0 16px 16px;
    background: transparent;
}

/* Section heading "Trained Warden" */
.trained-page-title {
    font-weight: var(--title-weight);
    /* 800 from tokens */
    letter-spacing: .2px;
    color: var(--primary);
    font-size: clamp(1.4rem, 1.1rem + 1vw, 2rem);
    /* responsive scale */
    text-align: center;
    margin-bottom: 1.5rem;
}

/* ---- Flex container that holds both cards ---- */
.trained-flex-stack {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    align-items: stretch;
}

/* On large screens, put cards side by side, balanced. */
@media (min-width: 992px) {
    .trained-flex-stack {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1.25rem;
        align-items: stretch;
        justify-content: center;
    }

    .trained-flex-stack>.trained-card {
        flex: 1 1 0;
        min-width: 360px;
        /* not too skinny */
        max-width: 560px;
        /* not too wide */
        display: flex;
    }
}

/* On huge displays, keep them centered in a clean band. */
@media (min-width: 1400px) {
    .trained-flex-stack {
        max-width: 1200px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* ---- Individual card styling ---- */
.trained-card {
    background-color: var(--card-bg);
    /* beige surface */
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    min-height: 0;
    /* flex overflow fix in Firefox */
    display: flex;
    flex-direction: column;
    transition: box-shadow .3s ease, transform .3s ease;
}

/* hover lift for subtle affordance */
.trained-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(0, 0, 0, .12),
        inset 0 0 0 1px rgba(255, 255, 255, .6);
}

/* ---- Inner body of each card ---- */
.trained-card-body {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    padding: 1rem 1rem 1rem 1rem;
    flex: 1 1 auto;
    min-height: 0;
    /* so .trained-scroll can shrink inside flex */
}

/* Slightly more breathing room ≥768px */
@media (min-width:768px) {
    .trained-card-body {
        padding: 1.5rem 2rem;
    }
}

/* ---- Heading inside each card ("Wardens", "Masters") ---- */
.trained-list-title {
    margin: 0;
    text-align: center;
    font-weight: var(--heading-weight);
    /* 700 */
    font-size: clamp(1.05rem, .9rem + .6vw, 1.4rem);
    color: var(--primary);
    flex: 0 0 auto;
    /* don't let the heading collapse */
    line-height: 1.3;
}

/* ---- Scrollable container for names ---- */
.trained-scroll {
    flex: 1 1 auto;
    /* fill remaining card height */
    min-height: 200px;
    /* ensures visible box even on tiny viewports */
    max-height: clamp(240px, 45vh, 480px);
    /* responsive max height */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;

    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border-soft);

    /* custom scrollbar for Firefox */
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

/* When viewport is very short, keep box manageable */
@media (max-height: 500px) {
    .trained-scroll {
        max-height: 200px;
    }
}

/* Hover/focus affordance */
.trained-scroll:hover {
    cursor: pointer;
    box-shadow: 0 0 0 2px rgba(94, 142, 167, 0.25),
        0 6px 14px rgba(0, 0, 0, 0.15);
    transition: box-shadow .3s ease;
}

/* ---- Scrollbar styling for WebKit ---- */
.trained-scroll::-webkit-scrollbar {
    width: 8px;
}

.trained-scroll::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 8px;
}

.trained-scroll::-webkit-scrollbar-track {
    background: transparent;
}

/* ---- UL that holds all the names ---- */
.trained-name-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ---- Individual name row ---- */
.trained-name-row {
    padding: .8rem 1rem;
    font-weight: 600;
    line-height: 1.35;
    word-break: break-word;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-main);
    background-color: #fff;
    transition: background-color .3s ease;
}

/* remove last border */
.trained-name-row:last-child {
    border-bottom: 0;
}

/* hover highlight per row */
.trained-name-row:hover {
    background-color: #EAF2F8;
}

/* ============================================================
   REVEAL / FADE-IN ANIMATION
   The .reveal class is added in markup. JS adds .trained-in
   once the element is in viewport (IntersectionObserver).
============================================================ */
.reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .5s ease, transform .5s ease;
}

/* When JS adds .trained-in, the item becomes visible */
.trained-in {
    opacity: 1;
    transform: translateY(0);
}

/* If user prefers reduced motion, do not animate. */
@media (prefers-reduced-motion: reduce) {
    .reveal {
        transition: none;
        opacity: 1;
        transform: none;
    }
}

/* ============================================================
   OPTIONAL SHADOW HELPER
============================================================ */
.trained-shadow-soft {
    box-shadow: var(--shadow-soft);
}

/* ============================================================
   AUTO-SCROLL HOVER/FOCUS VISUAL PAUSE
============================================================ */
.trained-scroll[data-direction]:hover,
.trained-scroll[data-direction]:focus-within,
.trained-scroll.paused-by-hover {
    box-shadow: 0 0 0 2px rgba(94, 142, 167, 0.25),
        0 6px 14px rgba(0, 0, 0, 0.18);
    outline: none;
    cursor: pointer;
}

.trained-scroll {
    cursor: default;
}

.trained-scroll:hover,
.trained-scroll:focus {
    cursor: pause;
    /* or 'default' if you prefer */
}

/* Tiny in-page styles just for list headings (safe to move to dashboard.css) */
.trained-name-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.trained-name-row {
    padding: .35rem .75rem;
}

.trained-name-row+.trained-name-row {
    border-top: 1px dashed rgba(0, 0, 0, .06);
}

.trained-name-row.state-heading {
    margin-top: .75rem;
    border-top: none !important;
    background: rgba(0, 0, 0, .03);
    border-radius: 8px;
}

.trained-name-row.state-heading strong {
    font-weight: 700;
}

.trained-name-row .state-count {
    color: var(--text-muted, #6b7280);
    font-weight: 500;
}