/* ============================================================
   TVK Makkal Connect — Admin Dashboard v2
   ============================================================ */

/* ── Body ───────────────────────────────────────────────────── */
.admin-body { background: #f0edec; min-height: 100vh; }

/* ── Header ─────────────────────────────────────────────────── */
.admin-header {
  position: sticky; top: 0; z-index: 300;
  background: linear-gradient(135deg, #610000 0%, #8b0000 60%, #7a0000 100%);
  padding: 0 28px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 20px rgba(0,0,0,.3);
}
.admin-header__brand { display: flex; align-items: center; gap: 10px; }
.admin-header__logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.admin-header__logo .material-symbols-outlined { color: #fdc826; font-size: 19px; }
.admin-header__text { display: flex; flex-direction: column; }
.admin-header__title { font-family: var(--font-noto); font-size: 17px; font-weight: 700; color: white; line-height: 1.2; }
.admin-header__sub   { font-family: var(--font-inter); font-size: 10px; color: rgba(255,255,255,.55); }
.admin-header__badge {
  background: var(--secondary-container); color: var(--on-secondary-container);
  font-family: var(--font-inter); font-size: 10px; font-weight: 800;
  padding: 3px 9px; border-radius: var(--r-full);
  text-transform: uppercase; letter-spacing: .08em; flex-shrink: 0;
}

.admin-header__nav { display: flex; align-items: center; gap: 3px; }
.admin-nav-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: var(--r-lg);
  font-family: var(--font-inter); font-size: 12px; font-weight: 600;
  color: rgba(255,255,255,.8); background: rgba(255,255,255,.1);
  border: none; transition: background .15s, color .15s;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.admin-nav-btn:hover  { background: rgba(255,255,255,.22); color: white; }
.admin-nav-btn .material-symbols-outlined { font-size: 15px; }
.admin-nav-btn--danger { color: #ffcdd2; }
.admin-nav-btn--danger:hover { background: rgba(244,67,54,.3); color: #ffcdd2; }

.admin-hamburger {
  display: none; background: rgba(255,255,255,.12); border: none;
  width: 36px; height: 36px; border-radius: var(--r-lg);
  align-items: center; justify-content: center; cursor: pointer; color: white;
}
.admin-hamburger .material-symbols-outlined { font-size: 21px; }

/* ── Mobile Nav ─────────────────────────────────────────────── */
.admin-mobile-nav {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
  display: none;
}
.admin-mobile-nav.open { display: flex; justify-content: flex-end; }
.admin-mobile-nav__panel {
  background: linear-gradient(160deg, #7a0000, #610000);
  width: 240px; padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--shadow-xl); overflow-y: auto;
}
.admin-nav-btn--mobile {
  width: 100%; justify-content: flex-start;
  padding: 10px 14px; font-size: 13px;
  background: rgba(255,255,255,.1);
}
.admin-nav-btn--mobile:hover { background: rgba(255,255,255,.2); }

/* ── Main ───────────────────────────────────────────────────── */
.admin-main {
  max-width: 1600px; margin: 0 auto;
  padding: 20px 24px 56px;
  display: flex; flex-direction: column; gap: 16px;
}

/* ── Stats Row ──────────────────────────────────────────────── */
.admin-stats { display: grid; grid-template-columns: repeat(6,1fr); gap: 10px; }

.stat-card {
  background: white; border-radius: var(--r-xl);
  padding: 14px 12px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 1px 8px rgba(0,0,0,.06); border: 1px solid rgba(0,0,0,.05);
  cursor: pointer; transition: transform .15s, box-shadow .15s;
  user-select: none;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.stat-card__icon {
  font-size: 20px; width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-card__num { font-family: var(--font-noto); font-size: 24px; font-weight: 800; line-height: 1; }
.stat-card__lbl { font-family: var(--font-inter); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--on-surface-var); margin-top: 2px; }

.stat-card--total    .stat-card__icon { background: rgba(97,0,0,.1);     color: var(--primary); }
.stat-card--total    .stat-card__num  { color: var(--primary); }
.stat-card--new      .stat-card__icon { background: rgba(253,200,38,.2); color: #7a5c00; }
.stat-card--new      .stat-card__num  { color: #7a5c00; }
.stat-card--review   .stat-card__icon { background: rgba(33,150,243,.12);color: #1565c0; }
.stat-card--review   .stat-card__num  { color: #1565c0; }
.stat-card--inprog   .stat-card__icon { background: rgba(255,152,0,.12); color: #e65100; }
.stat-card--inprog   .stat-card__num  { color: #e65100; }
.stat-card--resolved .stat-card__icon { background: rgba(76,175,80,.12); color: #2e7d32; }
.stat-card--resolved .stat-card__num  { color: #2e7d32; }
.stat-card--urgent   .stat-card__icon { background: rgba(156,39,176,.12);color: #6a1b9a; }
.stat-card--urgent   .stat-card__num  { color: #6a1b9a; }

/* ── Dashboard Grid ─────────────────────────────────────────── */
.admin-dashboard {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 16px;
  align-items: start;
}

/* ── Left Panel ─────────────────────────────────────────────── */
.admin-left-panel {
  display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 76px;
  max-height: calc(100vh - 92px);
  overflow-y: auto; padding-right: 2px;
}
.admin-left-panel::-webkit-scrollbar { width: 3px; }
.admin-left-panel::-webkit-scrollbar-thumb { background: var(--outline-var); border-radius: 4px; }

/* Panel Card (left panel blocks) */
.panel-card {
  background: white; border-radius: var(--r-2xl);
  box-shadow: 0 1px 8px rgba(0,0,0,.06); border: 1px solid rgba(0,0,0,.05);
  padding: 16px;
}
.panel-card__header {
  display: flex; align-items: center; gap: 6px; margin-bottom: 12px;
}
.panel-card__title {
  font-family: var(--font-inter); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--on-surface-var);
}

/* ── Tamil Nadu Map ─────────────────────────────────────────── */
.map-panel .panel-card__header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.map-bay-label {
  font-family: var(--font-inter); font-size: 9px; font-weight: 600;
  color: rgba(37,99,235,.5); letter-spacing: .04em;
}

.tn-map-wrap {
  position: relative; background: rgba(37,99,235,.06);
  border-radius: var(--r-xl); border: 1px solid rgba(37,99,235,.12);
  overflow: hidden; padding: 6px;
}

.tn-svg { width: 100%; height: auto; display: block; }

.tn-state-bg {
  fill: rgba(97,0,0,.07);
  stroke: rgba(97,0,0,.4);
  stroke-width: 1.2;
  stroke-linejoin: round;
  filter: url(#state-shadow);
}

/* District markers (via SVG + CSS) */
.tn-marker { cursor: pointer; }
.tn-marker .marker-ring {
  fill: none; stroke: white; stroke-width: 1.5;
  transition: r .15s;
}
.tn-marker .marker-dot {
  transition: r .15s;
  filter: url(#marker-glow);
}
.tn-marker:hover .marker-dot  { r: calc(var(--r) + 2px); }
.tn-marker--selected .marker-dot { stroke: #fdc826 !important; stroke-width: 2.5 !important; }
.tn-marker--selected .marker-dot { filter: url(#marker-glow) drop-shadow(0 0 5px rgba(253,200,38,.8)); }

/* Floating tooltip */
.map-tooltip {
  position: absolute; display: none; z-index: 50;
  background: rgba(28,27,27,.92); color: white;
  padding: 7px 11px; border-radius: 9px;
  font-family: var(--font-inter); font-size: 11px; line-height: 1.5;
  pointer-events: none; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.map-tooltip strong { font-size: 12px; font-weight: 700; display: block; margin-bottom: 1px; }

/* Active district badge */
.map-active-badge {
  display: flex; align-items: center; gap: 5px;
  background: rgba(97,0,0,.07); border: 1px solid rgba(97,0,0,.2);
  border-radius: var(--r-full); padding: 4px 10px; margin-top: 8px;
  font-family: var(--font-inter); font-size: 11px; font-weight: 600; color: var(--primary);
}
.map-active-badge button {
  background: none; border: none; padding: 0; cursor: pointer; color: var(--primary);
  display: flex; align-items: center; margin-left: 2px;
}

/* Map legend */
.map-legend {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--outline-var);
}
.map-legend-item {
  display: flex; align-items: center; gap: 4px;
  font-family: var(--font-inter); font-size: 10px; font-weight: 600; color: var(--on-surface-var);
}
.map-legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.map-legend-hint {
  font-family: var(--font-inter); font-size: 9px; color: var(--on-surface-var);
  opacity: .6; margin-left: auto;
}

/* ── Charts ─────────────────────────────────────────────────── */
.chart-area { display: flex; flex-direction: column; gap: 6px; }
.chart-empty { font-family: var(--font-manrope); font-size: 12px; color: var(--on-surface-var); text-align: center; padding: 12px; }

/* Category bar rows */
.cat-row {
  display: flex; align-items: center; gap: 8px;
}
.cat-row__icon {
  width: 22px; height: 22px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  font-size: 12px;
}
.cat-row__label {
  font-family: var(--font-inter); font-size: 11px; font-weight: 600; color: var(--on-surface-var);
  width: 70px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-row__bar-wrap {
  flex: 1; height: 7px; background: var(--surface-container);
  border-radius: 99px; overflow: hidden; cursor: pointer;
}
.cat-row__bar-fill {
  height: 100%; border-radius: 99px; transition: width .4s ease;
}
.cat-row__count {
  font-family: var(--font-inter); font-size: 11px; font-weight: 700; color: var(--on-surface); width: 16px; text-align: right; flex-shrink: 0;
}

/* Priority row */
.priority-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.priority-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: var(--r-lg);
  cursor: pointer; transition: opacity .15s;
}
.priority-pill:hover { opacity: .8; }
.priority-pill__dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.priority-pill__label { font-family: var(--font-inter); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.priority-pill__count { font-family: var(--font-noto); font-size: 18px; font-weight: 800; margin-left: auto; }

/* Source breakdown */
.source-row { display: flex; align-items: center; gap: 10px; }
.source-bar-wrap { flex: 1; height: 10px; background: var(--surface-container); border-radius: 99px; overflow: hidden; display: flex; }
.source-bar-ai  { background: var(--primary); border-radius: 99px 0 0 99px; height: 100%; transition: width .4s ease; }
.source-bar-wa  { background: #25D366; border-radius: 0 99px 99px 0; height: 100%; transition: width .4s ease; }
.source-labels { display: flex; justify-content: space-between; margin-top: 6px; }
.source-label { font-family: var(--font-inter); font-size: 10px; font-weight: 600; }

.divider { height: 1px; background: var(--outline-var); margin: 4px -16px; }

/* ── Right Panel ────────────────────────────────────────────── */
.admin-right-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* ── Filter Bar ─────────────────────────────────────────────── */
.admin-filter-bar {
  background: white; border-radius: var(--r-2xl);
  padding: 12px 16px;
  box-shadow: 0 1px 8px rgba(0,0,0,.06); border: 1px solid rgba(0,0,0,.05);
  display: flex; flex-direction: column; gap: 10px;
}
.filter-bar__row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.filter-bar__row--top { justify-content: space-between; }
.filter-bar__row--bottom { }

.admin-search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-low); border: 1.5px solid var(--outline-var);
  border-radius: var(--r-lg); padding: 7px 12px; flex: 1; min-width: 200px; max-width: 400px;
  transition: border-color .15s, box-shadow .15s;
}
.admin-search-wrap:focus-within {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(97,0,0,.07);
}
.admin-search-wrap .material-symbols-outlined { font-size: 17px; color: var(--on-surface-var); flex-shrink: 0; }
.admin-search { border: none; background: transparent; font-family: var(--font-inter); font-size: 13px; color: var(--on-surface); flex: 1; }
.search-clear-btn { background: none; border: none; padding: 0; cursor: pointer; color: var(--on-surface-var); display: flex; align-items: center; transition: color .12s; }
.search-clear-btn:hover { color: var(--primary); }

.filter-bar__actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.admin-count { font-family: var(--font-inter); font-size: 12px; font-weight: 700; color: var(--on-surface-var); white-space: nowrap; }

.filter-selects { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.admin-select {
  padding: 7px 10px; border: 1.5px solid var(--outline-var);
  border-radius: var(--r-lg); background: var(--surface-low);
  font-family: var(--font-inter); font-size: 12px; color: var(--on-surface);
  cursor: pointer; transition: border-color .15s;
}
.admin-select:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(97,0,0,.06); }

/* Active district filter badge */
.active-district-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(97,0,0,.08); border: 1.5px solid rgba(97,0,0,.2);
  border-radius: var(--r-full); padding: 4px 10px;
  font-family: var(--font-inter); font-size: 11px; font-weight: 600; color: var(--primary);
}
.active-district-badge button {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--primary); display: flex; align-items: center; margin-left: 2px;
}

/* ── Table ──────────────────────────────────────────────────── */
.admin-table-wrap {
  background: white; border-radius: var(--r-2xl);
  box-shadow: 0 1px 8px rgba(0,0,0,.06); border: 1px solid rgba(0,0,0,.05);
  overflow: hidden;
}
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table thead th {
  background: var(--surface-low);
  padding: 10px 14px;
  font-family: var(--font-inter); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--on-surface-var);
  border-bottom: 1.5px solid var(--outline-var);
  text-align: left; white-space: nowrap;
}
.admin-table thead th.sortable { cursor: pointer; user-select: none; transition: color .12s; }
.admin-table thead th.sortable:hover { color: var(--primary); }
.sort-icon { font-size: 11px; opacity: .4; margin-left: 2px; }
.sort-icon.active { opacity: 1; color: var(--primary); }

.admin-table tbody tr { border-bottom: 1px solid var(--outline-var); transition: background .1s; }
.admin-table tbody tr:last-child { border-bottom: none; }
.admin-table tbody tr:hover { background: rgba(97,0,0,.025); }
.admin-table tbody td { padding: 10px 14px; font-family: var(--font-manrope); font-size: 13px; color: var(--on-surface); vertical-align: middle; }

.tbl-id    { font-family: var(--font-inter); font-size: 11px; font-weight: 700; color: var(--primary); }
.tbl-src   { font-family: var(--font-inter); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--on-surface-var); margin-top: 2px; }
.tbl-title { font-size: 13px; font-weight: 600; color: var(--on-surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.tbl-desc  { font-size: 11px; color: var(--on-surface-var); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; margin-top: 2px; }
.tbl-district { font-family: var(--font-inter); font-size: 9px; color: var(--on-surface-var); margin-top: 2px; display: flex; align-items: center; gap: 2px; }

.tbl-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: var(--r-full);
  font-family: var(--font-inter); font-size: 10px; font-weight: 700; white-space: nowrap;
}
.tbl-dot { width: 5px; height: 5px; border-radius: 50%; display: inline-block; }

.tbl-act-btn {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 5px 9px; border-radius: var(--r-md);
  font-family: var(--font-inter); font-size: 11px; font-weight: 600;
  background: transparent; border: 1px solid var(--outline-var); color: var(--on-surface-var);
  transition: all .12s; cursor: pointer;
}
.tbl-act-btn:hover { background: var(--surface-container); border-color: var(--primary); color: var(--primary); }
.tbl-act-btn .material-symbols-outlined { font-size: 13px; }
.tbl-act-btn--primary { background: var(--primary); color: white; border-color: var(--primary); }
.tbl-act-btn--primary:hover { background: var(--primary-dark); }

/* ── Empty state ────────────────────────────────────────────── */
.admin-empty {
  text-align: center; padding: 56px 24px; color: var(--on-surface-var);
}
.admin-empty .material-symbols-outlined { font-size: 56px; display: block; margin-bottom: 10px; opacity: .25; }
.admin-empty h3 { font-family: var(--font-noto); font-size: 18px; font-weight: 700; color: var(--on-surface); margin-bottom: 6px; }
.admin-empty p  { font-family: var(--font-manrope); font-size: 13px; }

/* ── Mobile cards ───────────────────────────────────────────── */
.admin-cards { display: none; flex-direction: column; gap: 10px; }
.admin-card {
  background: white; border-radius: var(--r-xl);
  border: 1px solid rgba(0,0,0,.05); box-shadow: 0 1px 8px rgba(0,0,0,.06);
  display: flex; overflow: hidden;
}
.admin-card__stripe { width: 5px; flex-shrink: 0; }
.admin-card__body { flex: 1; padding: 13px; min-width: 0; }
.admin-card__id    { font-family: var(--font-inter); font-size: 10px; font-weight: 700; color: var(--primary); margin-bottom: 3px; }
.admin-card__title { font-family: var(--font-noto); font-size: 14px; font-weight: 700; color: var(--on-surface); margin-bottom: 5px; }
.admin-card__desc  { font-size: 12px; color: var(--on-surface-var); margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.admin-card__meta  { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.admin-card__acts  { display: flex; gap: 6px; }
.admin-card__acts .tbl-act-btn { flex: 1; justify-content: center; padding: 7px; font-size: 12px; }

/* ── Status modal ───────────────────────────────────────────── */
.status-opts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.status-opt {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: var(--r-lg);
  border: 1.5px solid var(--outline-var); cursor: pointer; transition: all .15s;
}
.status-opt:hover   { border-color: var(--primary); background: rgba(97,0,0,.03); }
.status-opt.selected { border-color: var(--primary); background: rgba(97,0,0,.06); }
.status-opt__title { font-family: var(--font-inter); font-size: 13px; font-weight: 600; color: var(--on-surface); }
.status-opt__desc  { font-family: var(--font-manrope); font-size: 11px; color: var(--on-surface-var); margin-top: 1px; }

/* ── Detail photo ───────────────────────────────────────────── */
.detail-photo { width: 100%; border-radius: var(--r-xl); margin-bottom: 16px; object-fit: cover; max-height: 220px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .admin-dashboard { grid-template-columns: 280px 1fr; }
  .admin-stats { grid-template-columns: repeat(3,1fr); }
}

@media (max-width: 1024px) {
  .admin-main   { padding: 16px 16px 48px; }
  .admin-header { padding: 0 16px; }
  .admin-header__nav { display: none; }
  .admin-hamburger   { display: flex; }
  .admin-dashboard { grid-template-columns: 1fr; }
  .admin-left-panel { position: static; max-height: none; flex-direction: row; flex-wrap: wrap; }
  .admin-left-panel .panel-card { flex: 1 1 250px; }
  .admin-left-panel .map-panel  { flex: 0 0 100%; }
}

@media (max-width: 768px) {
  .admin-table-wrap { display: none; }
  .admin-cards      { display: flex; }
  .admin-stats      { grid-template-columns: repeat(3,1fr); gap: 8px; }
  .admin-header__sub { display: none; }
  .stat-card__num   { font-size: 20px; }
  .stat-card__icon  { width: 34px; height: 34px; font-size: 17px; }
  .admin-left-panel { flex-direction: column; }
  .admin-left-panel .panel-card { flex: none; }
  .filter-bar__row--top { flex-direction: column; align-items: stretch; }
  .admin-search-wrap { max-width: none; }
  .filter-bar__actions { justify-content: space-between; }
}

@media (max-width: 480px) {
  .admin-header  { height: 52px; padding: 0 12px; }
  .admin-main    { padding: 12px 10px 40px; gap: 10px; }
  .admin-stats   { grid-template-columns: repeat(2,1fr); gap: 7px; }
  .admin-header__badge { display: none; }
  .btn-label { display: none; }
  .stat-card { padding: 10px 9px; gap: 8px; }
}
