/* =====================================================================
   CPHC Training Maharashtra — shared styles
   ---------------------------------------------------------------------
   Simple, friendly, clean. This is the ONE place to change the look.
   To re-theme: edit the colours under ":root" below.
   ===================================================================== */

:root {
  /* ---- Colours ---- */
  --bg:          #F6F8FA;   /* page background        */
  --surface:     #FFFFFF;   /* cards, header          */
  --surface-alt: #EEF1F5;   /* soft grey panels       */
  --text:        #1F2933;   /* main text              */
  --text-soft:   #6B7684;   /* labels, secondary text */
  --accent:      #0D9488;   /* main colour (teal)     */
  --accent-dark: #0B7C71;   /* hover                  */
  --accent-soft: #E4F4F1;   /* light teal background  */
  --chart-2:     #3B82F6;   /* second friendly colour */
  --border:      #E4E8EC;   /* hairlines and edges    */

  --radius: 14px;
  --max-width: 1040px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ===== Header + navigation ===== */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.brand { font-size: 18px; font-weight: 600; color: var(--text); text-decoration: none; }
.brand span { color: var(--accent); }

.nav { display: flex; gap: 6px; }
.nav a {
  padding: 7px 13px; border-radius: 8px; text-decoration: none;
  color: var(--text-soft); font-size: 15px;
}
.nav a:hover { color: var(--text); background: var(--bg); }
.nav a.active { color: var(--accent); background: var(--accent-soft); }

/* ===== Page layout ===== */
.page { max-width: var(--max-width); margin: 0 auto; padding: 32px 24px 64px; }
.page-title { font-size: 28px; font-weight: 600; margin-bottom: 2px; }
.page-subtitle { font-size: 16px; color: var(--text-soft); margin-bottom: 26px; }

/* ===== Toolbar / filter (dashboard) ===== */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.toolbar label { font-size: 15px; color: var(--text-soft); }
.filter {
  font-family: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 14px; cursor: pointer;
}
.filter:focus { outline: none; border-color: var(--accent); }
.scope-note { font-size: 14px; color: var(--text-soft); margin-left: auto; }

/* ===== Key-number cards ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 26px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.kpi-label { font-size: 13px; color: var(--text-soft); margin-bottom: 6px; }
.kpi-value { font-size: 28px; font-weight: 600; }
.kpi-sub { font-size: 12px; color: var(--text-soft); margin-top: 4px; }

/* ===== Chart cards ===== */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 26px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.chart-card h3 { font-size: 16px; font-weight: 600; }
.chart-card .chart-sub { font-size: 13px; color: var(--text-soft); margin-bottom: 14px; }
.chart-box { position: relative; height: 300px; }

/* ===== Data table ===== */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 20px 10px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { text-align: left; padding: 11px 8px; border-bottom: 1px solid var(--border); }
.data-table th { font-size: 12px; color: var(--text-soft); font-weight: 500; }
.data-table td.num, .data-table th.num { text-align: right; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ===== Buttons ===== */
.btn { display: inline-block; background: var(--accent); color: #fff; border: none; border-radius: 10px; padding: 11px 20px; font-size: 15px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: 0.6; cursor: default; }

/* Shared text input */
.input {
  width: 100%;
  font-family: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px;
}
.input:focus { outline: none; border-color: var(--accent); }

/* =====================================================================
   GALLERY  (Photos + Videos)
   ===================================================================== */

/* ---- Stats strip in the page header ---- */
.gallery-stats { display: flex; gap: 26px; margin: -14px 0 24px; flex-wrap: wrap; }
.gallery-stats .stat b { font-size: 22px; font-weight: 600; }
.gallery-stats .stat span { font-size: 13px; color: var(--text-soft); margin-left: 5px; }

/* ---- Photos / Videos tabs ---- */
.tabs { display: inline-flex; gap: 4px; background: var(--surface-alt); padding: 4px; border-radius: 12px; margin-bottom: 18px; }
.tab {
  border: none; background: none; cursor: pointer; font-family: inherit;
  font-size: 15px; color: var(--text-soft); padding: 8px 18px; border-radius: 9px;
  display: flex; align-items: center; gap: 7px;
}
.tab.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 2px rgba(0,0,0,0.05); font-weight: 500; }
.tab svg { width: 16px; height: 16px; }

/* ---- Sticky filter bar ---- */
.filterbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; margin-bottom: 20px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.filterbar::-webkit-scrollbar { height: 0; }
.search-wrap { position: relative; flex: 0 0 auto; }
.search-wrap input {
  width: 210px; font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 9px 14px 9px 34px;
}
.search-wrap input:focus { outline: none; border-color: var(--accent); }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-soft); }

.chip {
  flex: 0 0 auto; cursor: pointer; font-family: inherit; font-size: 14px;
  padding: 8px 15px; border-radius: 999px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-soft);
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active { background: var(--text); border-color: var(--text); color: #fff; }

.seg { flex: 0 0 auto; display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin-left: 4px; }
.seg button { border: none; background: var(--surface); cursor: pointer; font-family: inherit; font-size: 14px; color: var(--text-soft); padding: 8px 14px; }
.seg button.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 500; }

.divider-chip { flex: 0 0 auto; width: 1px; align-self: stretch; background: var(--border); margin: 4px 2px; }

/* ---- Photos: masonry, packed tight so no empty space ---- */
.masonry { column-width: 240px; column-gap: 14px; }
.photo-card {
  position: relative; overflow: hidden; cursor: pointer;
  border-radius: var(--radius); background: var(--surface-alt);
  display: inline-block; width: 100%; margin: 0 0 14px;
  break-inside: avoid; -webkit-column-break-inside: avoid;
}
.photo-card img { width: 100%; height: auto; display: block; transition: transform .35s ease; }
.photo-card:hover img { transform: scale(1.04); }
.photo-card .overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 12px 13px 11px; opacity: 0; transition: opacity .25s ease;
  background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0.15) 55%, rgba(0,0,0,0) 100%);
}
.photo-card:hover .overlay, .photo-card:focus-within .overlay { opacity: 1; }
.photo-card .overlay .o-name { color: #fff; font-weight: 600; font-size: 14px; line-height: 1.3; }
.photo-card .overlay .o-meta { color: rgba(255,255,255,0.85); font-size: 12px; margin-top: 2px; }
.photo-card .type-tag {
  position: absolute; top: 9px; left: 9px; font-size: 11px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px; background: rgba(255,255,255,0.92); color: var(--accent-dark);
}

/* ---- Videos: tidy card grid ---- */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.video-card { cursor: pointer; }
.video-thumb {
  position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius);
  overflow: hidden; background: var(--surface-alt);
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
.video-card:hover .video-thumb img { transform: scale(1.04); }
.video-thumb .play {
  position: absolute; inset: 0; margin: auto; width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); border-radius: 999px;
}
.video-thumb .play svg { width: 20px; height: 20px; fill: #fff; margin-left: 2px; }
.video-thumb .dur { position: absolute; bottom: 7px; right: 7px; font-size: 11px; color: #fff; background: rgba(0,0,0,0.78); padding: 1px 6px; border-radius: 5px; }
.video-card .v-name { font-weight: 600; font-size: 14px; margin-top: 9px; line-height: 1.35; }
.video-card .v-meta { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

/* ---- Admin delete button on cards ---- */
.admin-banner {
  background: var(--accent-soft); color: var(--accent-dark);
  border: 1px solid var(--accent); border-radius: 10px;
  padding: 10px 14px; font-size: 14px; margin-bottom: 20px;
}
.del-btn {
  position: absolute; top: 9px; right: 9px; z-index: 3;
  width: 32px; height: 32px; border-radius: 999px; cursor: pointer;
  border: none; background: rgba(179,38,30,0.92); color: #fff;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s ease;
}
.del-btn svg { width: 16px; height: 16px; }
.del-btn:hover { background: #B3261E; }
.del-btn:disabled { opacity: 0.5; cursor: default; }
.photo-card:hover .del-btn, .photo-card:focus-within .del-btn,
.video-card:hover .del-btn { opacity: 1; }
/* On touch screens (no hover) show it permanently so it's reachable */
@media (hover: none) { .del-btn { opacity: 1; } }

/* ---- Empty / loading ---- */
.empty-note { text-align: center; color: var(--text-soft); padding: 54px 20px; }

/* ---- Lightbox (photos + videos) ---- */
.lightbox { position: fixed; inset: 0; background: rgba(15,20,25,0.92); display: none; align-items: center; justify-content: center; padding: 3vh 4vw; z-index: 1000; }
.lightbox.open { display: flex; }
.lb-stage { max-width: 1100px; width: 100%; display: flex; gap: 20px; align-items: center; justify-content: center; }
.lb-media { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; min-width: 0; }
.lb-media img { max-width: 100%; max-height: 86vh; border-radius: 10px; }
.lb-frame { width: min(90vw, 960px); aspect-ratio: 16 / 9; border: none; border-radius: 10px; }
.lb-info { flex: 0 0 230px; color: #fff; }
.lb-info .li-name { font-size: 18px; font-weight: 600; margin-bottom: 10px; }
.lb-info .li-row { font-size: 14px; color: rgba(255,255,255,0.8); margin-bottom: 6px; display: flex; gap: 8px; }
.lb-info .li-row span { color: rgba(255,255,255,0.55); min-width: 62px; }
.lb-close { position: absolute; top: 16px; right: 22px; background: none; border: none; color: #fff; font-size: 32px; line-height: 1; cursor: pointer; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.12); border: none; color: #fff; width: 44px; height: 44px; border-radius: 999px; font-size: 22px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.lb-nav:hover { background: rgba(255,255,255,0.24); }
.lb-prev { left: 14px; } .lb-next { right: 14px; }

/* =====================================================================
   ADMIN forms
   ===================================================================== */
.login-card, .form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; max-width: 480px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-soft); margin-bottom: 6px; }
.field .opt { font-weight: 400; }
.type-options { display: flex; gap: 20px; }
.type-options label { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--text); }
.admin-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; max-width: 480px; }
.signed-in { font-size: 14px; color: var(--text-soft); }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 14px; font-family: inherit; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* Admin: photo/video mode switch */
.mode-switch { display: inline-flex; gap: 4px; background: var(--surface-alt); padding: 4px; border-radius: 12px; margin-bottom: 20px; }
.mode-switch button { border: none; background: none; cursor: pointer; font-family: inherit; font-size: 15px; color: var(--text-soft); padding: 8px 18px; border-radius: 9px; }
.mode-switch button.active { background: var(--surface); color: var(--accent); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

.yt-preview { display: none; margin-top: 10px; }
.yt-preview.show { display: block; }
.yt-preview img { width: 180px; border-radius: 10px; border: 1px solid var(--border); }

/* Messages */
.msg { padding: 11px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.msg.error { background: #FDECEC; color: #B3261E; }
.msg.success { background: var(--accent-soft); color: var(--accent-dark); }

/* ===== Small screens ===== */
@media (max-width: 760px) { .chart-grid { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .lb-stage { flex-direction: column; }
  .lb-info { flex-basis: auto; width: 100%; }
  .masonry { column-width: 46vw; column-gap: 10px; }
}
@media (max-width: 560px) {
  .site-header .inner { flex-direction: column; align-items: flex-start; }
  .nav { flex-wrap: wrap; }
  .page { padding: 22px 16px 56px; }
}

/* =====================================================================
   District map (added for the Maharashtra map section)
   ---------------------------------------------------------------------
   Everything below is only used by the map at the bottom of the
   dashboard. Nothing above this line was changed.
   ===================================================================== */

.map-section { max-width: 1520px; margin: 0 auto; padding: 0 16px 60px; }

.map-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.map-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 14px;
}
.map-head h3 { font-size: 17px; font-weight: 600; }
.map-head .sub { font-size: 13px; color: var(--text-soft); }
.map-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.seg {
  display: inline-flex; border: 1px solid var(--border);
  border-radius: 9px; overflow: hidden; background: var(--surface-alt);
}
.seg button {
  border: 0; background: transparent; font: inherit; font-size: 13px;
  color: var(--text-soft); padding: 7px 15px; cursor: pointer;
}
.seg button.on {
  background: var(--surface); color: var(--text);
  font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

.map-wrap {
  position: relative; height: min(92vh, 1150px); min-height: 820px;
  border-radius: 10px; overflow: hidden; background: #FCFDFE;
}
#cphcMap { width: 100%; height: 100%; background: #FCFDFE; }
.leaflet-container { font: inherit; background: #FCFDFE; }
.leaflet-bottom.leaflet-left { margin-bottom: 6px; margin-left: 6px; }

/* names sitting on the districts */
.dist-label { background: none; border: 0; box-shadow: none; padding: 0; text-align: center; }
.dist-label::before { display: none; }
.dist-label .nm {
  display: block; font-size: 11px; font-weight: 600;
  color: #111827; letter-spacing: .1px; line-height: 1.15;
}
.dist-label .vl { display: block; font-size: 13.5px; font-weight: 700; color: #000; line-height: 1.15; }

/* hover read-out */
.info-box {
  position: absolute; top: 14px; left: 14px; z-index: 600; background: #FFF;
  border: 1px solid var(--border); border-radius: 11px; padding: 13px 16px;
  width: 252px; box-shadow: 0 3px 14px rgba(16,24,40,.09); pointer-events: none;
}
.info-box .t { font-size: 15px; font-weight: 600; line-height: 1.3; }
.info-box .d { font-size: 11.5px; color: var(--text-soft); margin-bottom: 9px; }
.info-box table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.info-box td { padding: 3px 0; border-bottom: 1px solid #F1F4F6; }
.info-box tr:last-child td { border-bottom: 0; }
.info-box td.k { color: var(--text-soft); }
.info-box td.v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.info-box .hint { font-size: 12px; color: var(--text-soft); }

/* colour key */
.legend {
  position: absolute; right: 14px; bottom: 14px; z-index: 600; background: #FFF;
  border: 1px solid var(--border); border-radius: 11px; padding: 11px 13px;
  box-shadow: 0 3px 14px rgba(16,24,40,.09);
}
.legend .lt {
  font-size: 10.5px; font-weight: 600; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 7px;
}
.legend .row { display: flex; align-items: center; gap: 9px; font-size: 12px; margin-top: 4px; }
.legend .sw { width: 17px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.05); }

.map-note { font-size: 12.5px; color: var(--text-soft); margin-top: 12px; }

/* the table sits inside the page width, so pull it in line with the map */
.map-section + * { margin-top: 0; }

@media (max-width: 720px) {
  .map-wrap { height: 72vh; min-height: 480px; }
  .info-box { width: 200px; padding: 10px 12px; }
  .dist-label .nm { font-size: 9.5px; }
  .dist-label .vl { font-size: 11.5px; }
}

/* =====================================================================
   Dashboard layout v2 (map in the middle, cadres below it)
   ---------------------------------------------------------------------
   Only adds new rules. Nothing above this line was changed.
   ===================================================================== */

/* top part (title, filters, key numbers) sits right above the map */
.page.page-top { padding-bottom: 0; }
.page-top .table-card { margin-bottom: 26px; }

/* ---- Cadres trained ---- */
.cadre-card { margin-top: 16px; padding: 22px 24px 20px; }
.cadre-card h3 { font-size: 17px; }
.cadre-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.cadre-head .chart-sub { margin-bottom: 0; }
.cadre-total { text-align: right; }
.cadre-total b { display: block; font-size: 26px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.cadre-total span { font-size: 13px; color: var(--text-soft); }

/* two columns of five on wide screens, one column on smaller ones */
.cadre-list {
  display: grid; grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(5, auto); grid-auto-flow: column;
  column-gap: 40px; row-gap: 2px;
}
.cadre-row {
  display: grid;
  grid-template-columns: 12px 52px minmax(0, 200px) minmax(60px, 1fr) 64px;
  align-items: center; gap: 12px;
  padding: 9px 4px; border-bottom: 1px solid var(--border);
}
.cadre-row .sw { width: 12px; height: 12px; border-radius: 3px; }
.cadre-row .code { font-size: 14px; font-weight: 600; }
.cadre-row .name { font-size: 13px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cadre-row .bar { height: 8px; border-radius: 999px; background: var(--surface-alt); overflow: hidden; }
.cadre-row .bar i { display: block; height: 100%; border-radius: 999px; }
.cadre-row .count { font-size: 15px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.cadre-empty { color: var(--text-soft); padding: 30px 0; }

@media (max-width: 1000px) {
  .cadre-list { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-flow: row; }
}
@media (max-width: 560px) {
  .cadre-card { padding: 18px 16px 18px; }
  .cadre-head { flex-direction: column; gap: 8px; }
  .cadre-total { text-align: left; }
  .cadre-row { grid-template-columns: 12px 48px minmax(40px, 1fr) 56px; gap: 10px; }
  .cadre-row .name { display: none; }
}
