/* =============================================
   SchoolPay — Main Stylesheet
   ============================================= */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --info: #0891b2;
  --info-light: #ecfeff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --white: #ffffff;
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- LOGIN ---- */
.login-body { background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-wrapper { width: 100%; max-width: 440px; padding: 16px; }
.login-card { background: var(--white); border-radius: 16px; padding: 40px 36px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { font-size: 2.5rem; }
.login-logo h1 { font-size: 1.75rem; font-weight: 700; color: var(--text); margin-top: 6px; }
.login-logo p { color: var(--text-muted); font-size: .9rem; }

.role-tabs { display: flex; gap: 8px; margin-bottom: 24px; }
.role-tab { flex: 1; padding: 10px 6px; border: 2px solid var(--border); background: var(--white); border-radius: var(--radius); cursor: pointer; font-size: .85rem; font-weight: 500; color: var(--text-muted); transition: all .2s; }
.role-tab.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }
.role-tab:hover:not(.active) { border-color: #94a3b8; }

.demo-accounts { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-top: 20px; font-size: .82rem; color: var(--text-muted); line-height: 1.8; }
.demo-accounts strong { color: var(--text); }

/* ---- LAYOUT ---- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w); background: #0f172a;
  display: flex; flex-direction: column;
  z-index: 200; overflow-y: auto;
  transition: transform .3s ease;
}
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.logo-icon { font-size: 1.6rem; }
.logo-text { font-size: 1.1rem; font-weight: 700; color: #f1f5f9; flex: 1; }
.sidebar-close { display: none; background: none; border: none; color: #94a3b8; font-size: 1.1rem; cursor: pointer; padding: 4px; }

.user-info { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; flex-shrink: 0; }
.user-name { font-size: .9rem; font-weight: 600; color: #f1f5f9; }
.user-role { font-size: .75rem; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 8px 20px 4px; font-size: .7rem; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: .05em; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: #94a3b8; transition: all .15s; font-size: .88rem; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.08); color: #f1f5f9; text-decoration: none; }
.nav-item.active { border-left: 3px solid var(--primary); padding-left: 17px; color: white; background: rgba(37,99,235,.2); }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.logout-btn { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; color: #f87171 !important; }
.logout-btn:hover { background: rgba(239,68,68,.15) !important; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 150; }

.main-content { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); background: var(--white); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow); }
.hamburger { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text); padding: 4px 8px; }
.page-title { font-size: 1.1rem; font-weight: 600; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.term-badge { background: var(--primary-light); color: var(--primary); font-size: .78rem; font-weight: 600; padding: 4px 10px; border-radius: 20px; }
.logout-link { font-size: 1.2rem; text-decoration: none; }
.content-area { padding: 24px; flex: 1; }

/* ---- CARDS ---- */
.card { background: var(--white); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); background: #f8fafc; }
.card-header h3, .card-header h4 { font-size: .95rem; font-weight: 600; }
.card-body { padding: 18px; }
.card-body.p-0 { padding: 0; }

/* ---- STATS GRID ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 20px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow); border: 1px solid var(--border); border-left: 4px solid transparent; }
.stat-card.blue   { border-left-color: #2563eb; }
.stat-card.green  { border-left-color: #16a34a; }
.stat-card.red    { border-left-color: #dc2626; }
.stat-card.orange { border-left-color: #d97706; }
.stat-icon { font-size: 1.8rem; }
.stat-value { font-size: 1.3rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

/* ---- TABLES ---- */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { background: #f8fafc; padding: 10px 14px; text-align: left; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }
.table tfoot td, .table tfoot th { background: #f8fafc; font-weight: 600; border-top: 2px solid var(--border); }
.section-header td { background: #f1f5f9 !important; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: 8px 14px !important; }
.total-row td { background: #f8fafc; font-weight: 600; border-top: 1px solid var(--border); }
.grand-total td { background: #e0f2fe !important; font-size: 1rem; font-weight: 700; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 500; font-size: .85rem; color: var(--text); margin-bottom: 4px; }
.form-control { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem; color: var(--text); background: var(--white); transition: border-color .2s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-control-sm { padding: 5px 8px; font-size: .85rem; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }

/* ---- BUTTONS ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); border: none; cursor: pointer; font-size: .875rem; font-weight: 500; transition: all .15s; text-decoration: none; white-space: nowrap; }
.btn:hover { text-decoration: none; filter: brightness(0.92); }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger  { background: var(--danger); color: white; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-block, .w-100 { width: 100%; justify-content: center; }

/* ---- BADGES ---- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-paid     { background: var(--success-light); color: var(--success); }
.badge-unpaid   { background: var(--danger-light); color: var(--danger); }
.badge-partial  { background: var(--warning-light); color: var(--warning); }
.badge-lg       { padding: 5px 14px; font-size: .85rem; }
.badge-role-admin       { background: #ede9fe; color: #7c3aed; padding: 3px 9px; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-role-accountant  { background: var(--info-light); color: var(--info); padding: 3px 9px; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-role-parent      { background: var(--primary-light); color: var(--primary); padding: 3px 9px; border-radius: 20px; font-size: .75rem; font-weight: 600; }

/* ---- ALERTS ---- */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: .9rem; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }
.alert-danger   { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-warning  { background: var(--warning-light); color: var(--warning); border: 1px solid #fde68a; }
.alert-info     { background: var(--info-light); color: var(--info); border: 1px solid #a5f3fc; }

/* ---- MODAL ---- */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 500; align-items: center; justify-content: center; padding: 16px; }
.modal-dialog { background: var(--white); border-radius: 12px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 50px rgba(0,0,0,.25); }
.modal-lg { max-width: 760px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--white); z-index: 1; }
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--text-muted); padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); background: #f8fafc; }

/* ---- GRIDS ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ---- PAGE ACTIONS ---- */
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---- FILTERS ---- */
.filter-bar { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filter-form .form-control { flex: 1; min-width: 150px; max-width: 260px; }

/* ---- REPORT TABS ---- */
.report-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--border); padding-bottom: 0; }
.report-tab { padding: 8px 16px; border-radius: 6px 6px 0 0; font-size: .875rem; font-weight: 500; color: var(--text-muted); background: transparent; border: none; cursor: pointer; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.report-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--primary-light); }
.report-tab:hover:not(.active) { color: var(--text); background: var(--bg); }

/* ---- PRINT / INVOICE ---- */
.print-doc { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; max-width: 800px; margin: 0 auto; }
.print-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; padding-bottom: 20px; border-bottom: 2px solid var(--border); }
.print-school-info h1 { font-size: 1.3rem; font-weight: 700; }
.print-school-info p { font-size: .85rem; color: var(--text-muted); margin-top: 2px; }
.print-doc-title { text-align: right; }
.print-doc-title h2 { font-size: 1.5rem; font-weight: 700; color: var(--primary); letter-spacing: .05em; }
.invoice-no { font-family: monospace; font-size: 1rem; color: var(--text-muted); }
.print-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 20px 0; font-size: .9rem; line-height: 1.8; }
.print-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.print-table th { background: #f8fafc; padding: 10px 12px; text-align: left; font-weight: 600; border: 1px solid var(--border); font-size: .8rem; text-transform: uppercase; }
.print-table td { padding: 10px 12px; border: 1px solid var(--border); }
.amount-words { background: #f8fafc; border: 1px solid var(--border); border-radius: 4px; padding: 10px 14px; font-size: .88rem; font-style: italic; margin-top: 12px; }
.print-footer { text-align: center; font-size: .8rem; color: var(--text-muted); margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.receipt-sign { display: flex; justify-content: space-between; }
.receipt-sign > div { text-align: center; }
.sign-line { width: 180px; border-bottom: 1px solid var(--text); margin: 40px auto 8px; }

/* ---- BANKS ---- */
.bank-card { transition: transform .15s; }
.bank-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.bank-icon { font-size: 2rem; margin-bottom: 8px; }
.bank-balance { display: flex; justify-content: space-between; align-items: center; margin: 12px 0; padding: 10px; background: var(--bg); border-radius: 6px; }
.bank-balance .label { font-size: .78rem; color: var(--text-muted); }
.bank-balance .amount { font-weight: 700; font-size: 1.1rem; }
.bank-stats { display: flex; flex-direction: column; gap: 2px; font-size: .8rem; }
.bank-actions { display: flex; gap: 8px; }

/* ---- CHECKLIST ---- */
.checklist { list-style: none; padding: 0; font-size: .88rem; }
.checklist li { padding: 4px 0; }
.check-ok { color: var(--success); }
.check-warn { color: var(--warning); }

/* ---- UTILITIES ---- */
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.fw-bold      { font-weight: 700; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }
.ml-2   { margin-left: 8px; }
.mr-2   { margin-right: 8px; }
.p-3    { padding: 16px; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-2  { gap: 8px; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: .82rem; font-family: 'Courier New', monospace; color: #7c3aed; }
small { font-size: .8rem; }

/* ---- PRINT STYLES ---- */
@media print {
  .sidebar, .topbar, .page-actions, .filter-bar, .no-print, .report-tabs { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .content-area { padding: 0 !important; }
  .print-doc { border: none; padding: 0; max-width: 100%; }
  body { background: white; }
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filter-form .form-control { max-width: 100%; }
  .term-badge { display: none; }
  .print-header { flex-direction: column; gap: 16px; }
  .print-info-grid { grid-template-columns: 1fr; }
  .content-area { padding: 16px; }
  .report-tabs { overflow-x: auto; flex-wrap: nowrap; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .role-tab { font-size: .78rem; padding: 8px 4px; }
  .login-card { padding: 28px 20px; }
}

/* ---- DISCOUNT ---- */
.badge-discount { background:#fef3c7; color:#92400e; border:1px solid #fde68a; }
.discount-box { background:#f8fafc; border:1px solid var(--border); border-radius:var(--radius); padding:16px; }
.invoice-summary { border-top:1px solid var(--border); margin-top:12px; padding-top:10px; }
.summary-row { display:flex; justify-content:space-between; align-items:center; padding:5px 0; font-size:.9rem; }
.summary-row.discount-row { color:var(--danger); }
.summary-row.total-row { border-top:2px solid var(--border); margin-top:4px; padding-top:8px; font-size:1rem; font-weight:700; }

/* ---- JOURNAL ---- */
.badge-jtype-income     { background:#dcfce7; color:#166534; padding:3px 9px; border-radius:20px; font-size:.75rem; font-weight:600; }
.badge-jtype-expense    { background:#fee2e2; color:#991b1b; padding:3px 9px; border-radius:20px; font-size:.75rem; font-weight:600; }
.badge-jtype-transfer   { background:#dbeafe; color:#1e40af; padding:3px 9px; border-radius:20px; font-size:.75rem; font-weight:600; }
.badge-jtype-adjustment { background:#fef9c3; color:#713f12; padding:3px 9px; border-radius:20px; font-size:.75rem; font-weight:600; }

.balance-indicator { padding:10px 14px; border-radius:var(--radius); font-size:.875rem; font-weight:500; margin-top:8px; }
.balance-ok          { background:#dcfce7; color:#166534; border:1px solid #bbf7d0; }
.balance-unbalanced  { background:#fef3c7; color:#92400e; border:1px solid #fde68a; }

.template-btns { display:flex; gap:8px; flex-wrap:wrap; }
