/* ═══════════════════════════════════════════════════════════
   GRMS — Main CSS  |  Local-only, no CDN
   Government of Bihar — District Administration
   ═══════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --navy:      #1A3C6E;
  --navy-dk:   #102647;
  --blue:      #2E6DB4;
  --blue-lt:   #D6E4F0;
  --teal:      #0D7377;
  --green:     #1A6B3C;
  --green-lt:  #D4EDDA;
  --amber:     #E67E22;
  --amber-lt:  #FFF3CD;
  --red:       #C0392B;
  --red-lt:    #FAD7D7;
  --gold:      #B8860B;
  --grey1:     #1a1a2e;
  --grey2:     #4a4a6a;
  --grey3:     #888;
  --silver:    #F4F6F9;
  --white:     #FFFFFF;
  --sidebar-w: 240px;
  --topbar-h:  56px;
  --radius:    8px;
  --shadow:    0 2px 8px rgba(0,0,0,.12);
}

/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body { margin: 0; font-family: 'Segoe UI', Arial, sans-serif; background: #f0f2f7; color: var(--grey1); line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.hi { font-family: 'Mangal', 'Noto Sans Devanagari', Arial, sans-serif; }
img { max-width: 100%; }

/* ── Layout ──────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy-dk);
  color: #cdd6e8;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo { display: flex; align-items: center; gap: 8px; }
.emblem-img { width: 32px; height: 32px; object-fit: contain; }
.sidebar-brand { line-height: 1.2; }
.brand-en { display: block; font-size: 16px; font-weight: 700; color: #fff; letter-spacing: 1px; }
.brand-hi { display: block; font-size: 11px; color: #8ab0d8; font-family: 'Mangal', Arial, sans-serif; }
.sidebar-toggle { background: none; border: none; color: #8ab0d8; font-size: 20px; cursor: pointer; padding: 4px; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--blue);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: white;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: #e8edf8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.user-role { font-size: 10px; padding: 1px 6px; border-radius: 8px; margin-top: 2px; display: inline-block; }

/* Role badge colours */
.badge-role-super_admin   { background: #6c3483; color: white; }
.badge-role-dm_sp         { background: #1a6b3c; color: white; }
.badge-role-control_room  { background: #2e6db4; color: white; }
.badge-role-traffic_police{ background: #e67e22; color: white; }
.badge-role-field_officer { background: #c0392b; color: white; }
.badge-role-drone_pilot   { background: #0d7377; color: white; }
.badge-role-ambulance     { background: #b8860b; color: white; }

.sidebar-menu { list-style: none; padding: 8px 0; margin: 0; flex: 1; }
.menu-item a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  color: #b0c0d8;
  transition: background .15s, color .15s;
  font-size: 14px;
}
.menu-item a:hover, .menu-item.active a {
  background: rgba(46,109,180,.25);
  color: #fff;
  text-decoration: none;
}
.menu-icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.badge-count {
  background: var(--red);
  color: white;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; flex-direction: column; gap: 8px;
}
.lang-switcher { display: flex; gap: 4px; }
.lang-btn {
  background: rgba(255,255,255,.1); border: none; color: #b0c0d8;
  padding: 4px 10px; border-radius: 4px; font-size: 12px; cursor: pointer;
}
.lang-btn.active { background: var(--blue); color: white; }
.logout-btn {
  background: rgba(192,57,43,.2); border: 1px solid rgba(192,57,43,.4);
  color: #f0b0a8; padding: 6px 12px; border-radius: 4px;
  font-size: 12px; cursor: pointer; text-align: center;
}
.logout-btn:hover { background: rgba(192,57,43,.4); }
.logout-form { margin: 0; }

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 2px solid var(--blue-lt);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.topbar-title { font-size: 15px; font-weight: 600; color: var(--navy); flex: 1; }
.topbar-profile {
  width: 34px; height: 34px;
  background: var(--blue);
  border-radius: 50%;
  color: white; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.sidebar-toggle-mobile {
  display: none;
  background: none; border: none; font-size: 22px; cursor: pointer; color: var(--navy);
}

.content-area { padding: 20px; flex: 1; }

/* ── Messages ──────────────────────────────────────────────── */
.messages-container { padding: 0 20px 0; }
.alert-msg {
  padding: 10px 14px; border-radius: var(--radius);
  margin-bottom: 8px; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.alert-success { background: #d4edda; color: #155724; border-left: 4px solid var(--green); }
.alert-error, .alert-danger   { background: var(--red-lt); color: #721c24; border-left: 4px solid var(--red); }
.alert-warning { background: var(--amber-lt); color: #856404; border-left: 4px solid var(--amber); }
.alert-info    { background: var(--blue-lt); color: #0c5460; border-left: 4px solid var(--blue); }
.close-msg { background: none; border: none; font-size: 18px; cursor: pointer; color: inherit; padding: 0 4px; }

/* ── Cards & Panels ─────────────────────────────────────────── */
.page-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.panel-card { background: white; border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--blue-lt);
}
.panel-header h3, .panel-header h4 { margin: 0; color: var(--navy); font-size: 15px; }

/* ── Stats Row ──────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  border-left: 4px solid;
}
.stat-blue { border-color: var(--blue); }
.stat-green { border-color: var(--green); }
.stat-amber { border-color: var(--amber); }
.stat-red { border-color: var(--red); }
.stat-icon { font-size: 28px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--navy); line-height: 1; }
.stat-label { font-size: 12px; color: var(--grey3); margin-top: 3px; }

/* ── Dashboard Grid ──────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.dash-panel {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* ── Event Cards ─────────────────────────────────────────────── */
.event-cards { display: flex; flex-direction: column; gap: 10px; }
.event-card {
  border: 1px solid #e0e8f0;
  border-radius: var(--radius);
  padding: 12px;
  background: #fafbfd;
}
.event-card.active { border-left: 4px solid var(--red); }
.event-card-header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.event-name { font-weight: 600; color: var(--navy); font-size: 14px; }
.event-name-hi { font-size: 12px; color: var(--grey3); font-family: 'Mangal', Arial, sans-serif; }
.event-meta { font-size: 12px; color: var(--grey2); margin-top: 3px; }
.event-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.badge-lg { font-size: 13px; padding: 4px 12px; border-radius: 12px; }
.status-draft     { background: #e9ecef; color: #495057; }
.status-approved  { background: #d4edda; color: #155724; }
.status-active    { background: #f8d7da; color: #721c24; animation: pulse-bg 2s infinite; }
.status-completed { background: #cce5ff; color: #004085; }
.status-cancelled { background: #f8d7da; color: #721c24; }
.status-archived  { background: #e9ecef; color: #6c757d; }
.type-religious   { background: #fde8d8; color: #c55a00; }
.type-political   { background: #e8d8fd; color: #6a0dad; }
.type-cultural    { background: #d8fde8; color: #155724; }
.type-sports      { background: #d8eafd; color: #004085; }
.type-other       { background: #f0f0f0; color: #555; }
@keyframes pulse-bg { 0%,100%{opacity:1} 50%{opacity:.8} }

/* ── Alert List ──────────────────────────────────────────────── */
.alert-list { display: flex; flex-direction: column; gap: 6px; }
.alert-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px; border-radius: 6px; background: #fafafa;
  border-left: 3px solid;
}
.alert-item.severity-green { border-color: var(--green); }
.alert-item.severity-amber { border-color: var(--amber); }
.alert-item.severity-red   { border-color: var(--red); background: #fff5f5; }
.alert-severity-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; background: currentColor; }
.alert-body { flex: 1; min-width: 0; }
.alert-type  { font-size: 12px; font-weight: 700; color: var(--grey1); }
.alert-desc  { font-size: 12px; color: var(--grey2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-meta  { font-size: 10px; color: var(--grey3); }

/* ── Data Table ──────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; background: white; border-radius: var(--radius); box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  background: var(--navy);
  color: white;
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #edf0f7;
  vertical-align: middle;
}
.data-table tr:hover td { background: var(--silver); }
.empty-cell { text-align: center; color: var(--grey3); padding: 24px !important; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 6px; font-size: 14px; font-weight: 500;
  border: none; cursor: pointer; text-decoration: none; transition: all .15s;
  white-space: nowrap;
}
.btn-primary   { background: var(--blue); color: white; }
.btn-primary:hover { background: #245a99; color: white; }
.btn-secondary { background: #e9ecef; color: #495057; }
.btn-secondary:hover { background: #dee2e6; }
.btn-danger    { background: var(--red); color: white; }
.btn-danger:hover  { background: #a93226; color: white; }
.btn-success   { background: var(--green); color: white; }
.btn-outline   { background: transparent; border: 1px solid currentColor; }
.btn-sm   { padding: 5px 10px; font-size: 12px; }
.btn-xs   { padding: 2px 7px; font-size: 11px; border-radius: 4px; }
.btn-full { width: 100%; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-control, .form-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color .15s;
  background: white;
  color: var(--grey1);
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(46,109,180,.15);
}
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.field-error { color: var(--red); font-size: 12px; margin-top: 3px; }
.form-error { background: var(--red-lt); color: var(--red); padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 10px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-2 .full-width { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.page-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

/* ── Auth Layout ─────────────────────────────────────────────── */
.auth-page { background: linear-gradient(135deg, var(--navy-dk), var(--navy), #2c5282); min-height: 100vh; }
.auth-layout { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.auth-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card {
  background: white;
  border-radius: 12px;
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-emblem { width: 60px; height: 60px; object-fit: contain; margin-bottom: 12px; }
.auth-title { font-size: 28px; font-weight: 700; color: var(--navy); margin: 0 0 4px; }
.auth-subtitle-en { font-size: 13px; color: var(--grey2); margin: 0; }
.auth-subtitle-hi { font-size: 12px; color: var(--grey3); margin: 0; font-family: 'Mangal', Arial, sans-serif; }
.auth-org { font-size: 12px; color: var(--grey3); margin: 6px 0 0; }
.auth-links { text-align: center; margin-top: 16px; font-size: 13px; }
.auth-footer { text-align: center; margin-top: 20px; color: var(--grey3); }

/* ── Detail Layout ───────────────────────────────────────────── */
.detail-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px; align-items: start; }
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.detail-item label { font-size: 11px; font-weight: 700; color: var(--grey3); text-transform: uppercase; display: block; }
.detail-item span { font-size: 14px; color: var(--grey1); }
.detail-section { margin-top: 12px; }
.detail-section label { font-size: 13px; font-weight: 700; color: var(--navy); display: block; margin-bottom: 4px; }
.action-list { display: flex; flex-direction: column; gap: 8px; }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; }
.page-btn { padding: 6px 14px; background: white; border: 1px solid #dee2e6; border-radius: 6px; color: var(--blue); }
.page-info { font-size: 13px; color: var(--grey3); }

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 32px 16px; color: var(--grey3); }
.empty-icon { font-size: 40px; margin-bottom: 8px; }

/* ── Knowledge Base ──────────────────────────────────────────── */
.kb-search-bar { margin-bottom: 20px; }
.search-input-group { display: flex; gap: 8px; }
.search-input-group .form-control { flex: 1; }
.kb-pinned { margin-bottom: 24px; }
.kb-article-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 10px; }
.kb-article-card {
  display: block;
  background: white;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--blue);
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s;
}
.kb-article-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.15); text-decoration: none; }
.kb-article-card.pinned { border-color: var(--gold); }
.ka-title { font-size: 14px; font-weight: 600; color: var(--navy); margin-bottom: 5px; }
.ka-summary { font-size: 12px; color: var(--grey2); margin-bottom: 5px; }
.ka-meta { font-size: 11px; color: var(--grey3); }
.kb-categories { display: flex; flex-direction: column; gap: 20px; }
.kb-category-header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.kb-category-header h3 { margin: 0; color: var(--navy); font-size: 17px; }
.kb-list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: white;
  border-radius: 6px;
  margin-bottom: 4px;
  text-decoration: none;
  color: inherit;
  transition: background .1s;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.kb-list-item:hover { background: var(--blue-lt); text-decoration: none; }
.kl-icon { font-size: 18px; }
.kl-body { flex: 1; }
.kl-title { font-size: 14px; font-weight: 500; color: var(--navy); }
.kl-meta { font-size: 11px; color: var(--grey3); }
.kl-arrow { color: var(--grey3); font-size: 18px; }
.kb-view-all { font-size: 13px; color: var(--blue); display: inline-block; margin-top: 4px; }

/* Article page */
.article-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px; align-items: start; }
.article-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.article-breadcrumb { font-size: 13px; color: var(--grey3); }
.article-breadcrumb a { color: var(--blue); }
.article-lang-toggle { display: flex; gap: 4px; }
.lang-toggle-btn { padding: 4px 12px; border: 1px solid #dee2e6; border-radius: 4px; background: #f8f9fa; cursor: pointer; font-size: 13px; }
.lang-toggle-btn.active { background: var(--blue); color: white; border-color: var(--blue); }
.article-title { color: var(--navy); margin-bottom: 8px; }
.article-summary { font-size: 15px; color: var(--grey2); background: var(--blue-lt); padding: 12px 14px; border-radius: 6px; margin-bottom: 16px; }
.article-body { font-size: 15px; line-height: 1.7; color: var(--grey1); }
.article-body p { margin-bottom: 12px; }
.article-meta { display: flex; gap: 16px; font-size: 12px; color: var(--grey3); margin-top: 20px; padding-top: 12px; border-top: 1px solid #eee; }
.related-link { display: block; padding: 6px 0; border-bottom: 1px solid #eee; font-size: 13px; color: var(--blue); }

/* ── Reports ─────────────────────────────────────────────────── */
.report-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }

/* ── Admin Panel ─────────────────────────────────────────────── */
.admin-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .kb-article-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle-mobile { display: block; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .detail-layout, .article-layout { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .monitor-layout { grid-template-columns: 1fr !important; }
  .kb-article-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 24px 20px; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .content-area { padding: 12px; }
}
