/* Bihar MDM CRM — Main Stylesheet */
/* Font: Plus Jakarta Sans */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --primary:       #1a5276;
  --primary-light: #2471a3;
  --primary-dark:  #0e2f44;
  --accent:        #e67e22;
  --accent-light:  #f39c12;
  --success:       #1e8449;
  --success-bg:    #eafaf1;
  --danger:        #c0392b;
  --danger-bg:     #fdf3f1;
  --warning:       #b7770d;
  --warning-bg:    #fef9ec;
  --info:          #1a5276;
  --info-bg:       #eaf2fb;
  --bg:            #f0f4f8;
  --bg-card:       #ffffff;
  --bg-sidebar:    #0e2f44;
  --text:          #1c2833;
  --text-muted:    #717d8a;
  --text-light:    #aab4be;
  --border:        #dde3ea;
  --border-light:  #edf0f3;
  --radius:        10px;
  --radius-lg:     14px;
  --radius-xl:     20px;
  --shadow:        0 2px 8px rgba(26,82,118,.08);
  --shadow-md:     0 4px 16px rgba(26,82,118,.12);
  --sidebar-w:     260px;
  --topbar-h:      60px;
  --font:          'Plus Jakarta Sans', sans-serif;
  --font-mono:     'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── SIDEBAR ─────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}

.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
}

.logo-icon { font-size: 28px; }

.logo-title {
  font-size: 16px; font-weight: 700; color: #fff; letter-spacing: .3px;
}

.logo-sub {
  font-size: 11px; color: rgba(255,255,255,.5); margin-top: 1px;
}

.sidebar-school {
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.school-badge { display: flex; flex-direction: column; gap: 4px; }

.school-name {
  font-size: 12px; color: rgba(255,255,255,.75); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.role-badge {
  display: inline-block;
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px;
  padding: 2px 7px; border-radius: 30px;
  width: fit-content;
}
.role-admin    { background: #f39c12; color: #fff; }
.role-principal{ background: #2471a3; color: #fff; }
.role-clerk    { background: #1e8449; color: #fff; }

.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }

.nav-section { margin-bottom: 4px; }

.nav-section-title {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
  color: rgba(255,255,255,.35); padding: 12px 18px 4px;
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px; font-size: 13.5px; font-weight: 500;
  color: rgba(255,255,255,.7);
  border-left: 3px solid transparent;
  transition: all .18s;
}

.nav-link:hover { color: #fff; background: rgba(255,255,255,.07); text-decoration: none; }
.nav-link.active { color: #fff; background: rgba(255,255,255,.1); border-left-color: var(--accent); }

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.user-info { display: flex; align-items: center; gap: 10px; }

.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-light); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}

.user-details { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: 11px; color: rgba(255,255,255,.5); }

.logout-btn {
  color: rgba(255,255,255,.5); padding: 4px;
  display: flex; align-items: center;
  transition: color .2s;
}
.logout-btn:hover { color: #fff; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 190;
}

/* ── MAIN LAYOUT ─────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.menu-btn {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--text); padding: 4px; border-radius: 6px;
}
.menu-btn:hover { background: var(--border-light); }

.topbar-title {
  font-size: 16px; font-weight: 600; color: var(--text); flex: 1;
}

.topbar-date { font-size: 13px; color: var(--text-muted); }

.main-content { padding: 24px; flex: 1; }

/* ── CARDS ───────────────────────────────────── */
.card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

.card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 22px; }

/* ── STAT CARDS ─────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px; margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex; align-items: flex-start; gap: 14px;
  transition: box-shadow .2s, transform .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
  width: 44px; height: 44px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue    { background: #eaf2fb; }
.stat-icon.green   { background: #eafaf1; }
.stat-icon.amber   { background: #fef9ec; }
.stat-icon.red     { background: #fdf3f1; }
.stat-icon.purple  { background: #f5eef8; }
.stat-icon.teal    { background: #e8f8f5; }

.stat-body {}
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 3px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-delta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.stat-delta.up    { color: var(--success); }
.stat-delta.down  { color: var(--danger); }

/* ── TABLES ──────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

thead th {
  background: #f6f8fa; font-weight: 600; font-size: 12px;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px;
  padding: 10px 14px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 11px 14px; border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

.tfoot-row td {
  background: #f6f8fa; font-weight: 600;
  border-top: 2px solid var(--border);
}

/* ── FORMS ───────────────────────────────────── */
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-label {
  font-size: 12.5px; font-weight: 600; color: var(--text); letter-spacing: .2px;
}

.form-control {
  height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: var(--font); font-size: 14px; color: var(--text);
  background: var(--bg-card); transition: border-color .2s, box-shadow .2s;
  width: 100%;
}

.form-control:focus {
  outline: none; border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(36,113,163,.12);
}

textarea.form-control { height: auto; padding: 10px 12px; resize: vertical; }

select.form-control { cursor: pointer; }

.form-hint { font-size: 11.5px; color: var(--text-muted); }

.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 160px; }

/* ── BUTTONS ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 18px; height: 38px;
  border-radius: var(--radius); border: 1px solid transparent;
  font-family: var(--font); font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: all .18s; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.98); }

.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }

.btn-accent    { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-light); border-color: var(--accent-light); }

.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { filter: brightness(1.1); }

.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(1.1); }

.btn-outline   { background: transparent; color: var(--primary); border-color: var(--border); }
.btn-outline:hover { background: var(--info-bg); border-color: var(--primary-light); }

.btn-ghost     { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--border-light); color: var(--text); }

.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn-lg { height: 46px; padding: 0 28px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── BADGES ──────────────────────────────────── */
.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px; letter-spacing: .3px;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-primary { background: #eaf2fb; color: var(--primary); }

/* ── ALERTS ──────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13.5px; margin-bottom: 16px; border-left: 4px solid;
}
.alert-success { background: var(--success-bg); color: var(--success); border-left-color: var(--success); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border-left-color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-left-color: var(--warning); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border-left-color: var(--info); }

/* ── PAGE HEADER ─────────────────────────────── */
.page-header {
  margin-bottom: 24px; display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ── CALENDAR ────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}

.cal-day-header {
  background: #f6f8fa; text-align: center;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); padding: 8px 4px;
}

.cal-cell {
  background: var(--bg-card); padding: 8px;
  min-height: 80px; position: relative;
}

.cal-cell.empty { background: #fafafa; }
.cal-cell.holiday { background: #fff9f0; }
.cal-cell.has-data { background: #f0f7ff; }

.cal-date-num {
  font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px;
}
.cal-cell.today .cal-date-num { color: var(--primary); }

.cal-input {
  width: 100%; border: 1px solid var(--border);
  border-radius: 5px; padding: 3px 5px;
  font-size: 12px; text-align: center; color: var(--text);
  background: var(--bg-card);
}
.cal-input:focus { outline: none; border-color: var(--primary-light); }

.cal-holiday-label {
  font-size: 10px; color: var(--accent); font-weight: 600; text-align: center;
}

/* ── LEDGER TABLE ────────────────────────────── */
.ledger-positive { color: var(--success); font-weight: 600; }
.ledger-negative { color: var(--danger); font-weight: 600; }
.ledger-balance  { color: var(--primary); font-weight: 600; font-family: var(--font-mono); }
.amount-cell     { font-family: var(--font-mono); }

/* ── TABS ────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab-btn {
  padding: 10px 20px; background: none; border: none; cursor: pointer;
  font-family: var(--font); font-size: 13.5px; font-weight: 500;
  color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px;
  white-space: nowrap; transition: all .18s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── MODAL ───────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 300;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg-card); border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,.2); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 20px; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-light); display: flex; gap: 10px; justify-content: flex-end; }

/* ── REPORT SPECIFIC ─────────────────────────── */
.report-header {
  text-align: center; padding: 20px;
  border: 2px solid var(--primary); border-radius: var(--radius-lg);
  margin-bottom: 24px;
}
.report-school { font-size: 18px; font-weight: 700; color: var(--primary); }
.report-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.report-period { font-size: 14px; font-weight: 600; color: var(--text); margin-top: 6px; }

.summary-box {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 20px;
}

.summary-item {
  background: #f6f8fa; border-radius: var(--radius);
  padding: 12px 16px; border: 1px solid var(--border);
}
.summary-item-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.summary-item-value { font-size: 18px; font-weight: 700; color: var(--text); margin-top: 3px; font-family: var(--font-mono); }

/* ── DASHBOARD CHARTS ────────────────────────── */
.chart-wrap { position: relative; height: 240px; }

/* ── UTILITY ─────────────────────────────────── */
.text-right    { text-align: right; }
.text-center   { text-align: center; }
.text-muted    { color: var(--text-muted); }
.text-small    { font-size: 12px; }
.fw-bold       { font-weight: 600; }
.mono          { font-family: var(--font-mono); }
.d-flex        { display: flex; }
.align-center  { align-items: center; }
.gap-8         { gap: 8px; }
.gap-12        { gap: 12px; }
.mt-12         { margin-top: 12px; }
.mt-20         { margin-top: 20px; }
.mb-0          { margin-bottom: 0; }

.section-divider {
  border: none; border-top: 1px solid var(--border-light); margin: 20px 0;
}

/* ── LOGIN PAGE ──────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}

.login-card {
  background: var(--bg-card); border-radius: var(--radius-xl);
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
  width: 100%; max-width: 400px; padding: 40px 36px;
}

.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo-icon { font-size: 48px; margin-bottom: 8px; }
.login-logo-title { font-size: 22px; font-weight: 700; color: var(--primary); }
.login-logo-sub { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

.login-flag {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 12px; color: var(--text-muted); margin-bottom: 24px;
}

/* ── PRINT ───────────────────────────────────── */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .main-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}

/* ── RESPONSIVE ─────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-wrapper { margin-left: 0; }
  .menu-btn { display: flex; }
  .main-content { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .cal-grid { grid-template-columns: 1fr; }
  .cal-day-header { display: none; }
  .cal-cell { min-height: auto; display: flex; align-items: center; gap: 10px; padding: 10px; }
  .cal-date-num { min-width: 28px; }
}

@media (max-width: 500px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 18px; }
  .page-title { font-size: 18px; }
  .card-body { padding: 14px; }
  .table-wrap { font-size: 12px; }
  thead th, tbody td { padding: 8px 10px; }
}