/* ============================================================
   TaxGST CMS — Professional Responsive Theme
   ============================================================ */
:root {
  --primary:       #1450a3;
  --primary-dark:  #0c3a7d;
  --primary-light: #e8f0fc;
  --accent:        #16a34a;
  --danger:        #dc2626;
  --warn:          #d97706;
  --wa-green:      #25D366;   /* WhatsApp brand colour */
  --sidebar-bg:    #0f2a4a;
  --sidebar-bg2:   #123660;
  --text-dark:     #1f2937;
  --text-muted:    #6b7280;
  --border:        #e5e7eb;
  --bg:            #f4f6fa;
  --card-bg:       #ffffff;
  --radius:        10px;
  --shadow:        0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', Segoe UI, Arial, sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--primary); text-decoration: none; }

/* ---- App shell ---- */
.app-shell { display: flex; min-height: 100vh; position: relative; }

/* ---- Sidebar ---- */
.sidebar {
  width: 234px; min-width: 234px;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg2) 100%);
  color: #dce6f5;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 16px; flex-shrink: 0;
}
.brand-text { font-weight: 700; font-size: 15px; color: #fff; }
.brand-text em { font-style: normal; color: #8fc7ff; }

.sidebar-nav { flex: 1; padding: 12px 8px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 11px; margin-bottom: 1px; border-radius: 7px;
  color: #cdddf4; font-size: 13px; font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.sidebar-nav a .ico { font-size: 14px; width: 17px; text-align: center; flex-shrink: 0; }
.sidebar-nav a:hover { background: rgba(255,255,255,.09); color: #fff; }
.sidebar-nav a.active { background: var(--accent); color: #fff; }
.sidebar-nav a.wa-link { background: rgba(37,211,102,.15); color: #4ade80; }
.sidebar-nav a.wa-link:hover { background: rgba(37,211,102,.28); }
.sidebar-nav a.wa-link.active { background: var(--wa-green); color: #fff; }
.sidebar-footer {
  padding: 12px 16px; font-size: 11px; color: #7e9cc4;
  border-top: 1px solid rgba(255,255,255,.08); flex-shrink: 0;
}

/* ---- Overlay (backdrop for mobile sidebar) ---- */
.sidebarOverlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,42,74,.5); z-index: 40;
  -webkit-tap-highlight-color: transparent;
}
.sidebarOverlay.show { display: block; }

/* ---- Main column ---- */
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---- Topbar ---- */
.topbar {
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10; gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

/* ---- Hamburger toggle — anchor tag, no form submission ---- */
.menuToggle {
  display: none; /* hidden on desktop */
  width: 40px; height: 40px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card-bg); color: var(--text-dark);
  align-items: center; justify-content: center;
  font-size: 18px; line-height: 1; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.menuToggle .burger { pointer-events: none; }

.page-title { font-size: 18px; font-weight: 700; color: var(--text-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.userinfo { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.userinfo .avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.userinfo .uname { font-size: 12.5px; font-weight: 600; color: var(--text-dark); line-height: 1.3; }
.userinfo .uname small { display: block; font-weight: 400; color: var(--text-muted); font-size: 11px; }
.logoutLink {
  margin-left: 6px; padding: 7px 13px; border: 1px solid var(--border); border-radius: 7px;
  color: var(--danger); font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.logoutLink:hover { background: #fef2f2; }

/* ---- Content area ---- */
.content { padding: 22px 26px 40px; }

/* ---- Cards / Panels ---- */
.panel {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.panel h2 {
  margin: 0 0 16px; font-size: 15px; font-weight: 700; color: var(--text-dark);
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.panel h2 .sub { font-weight: 400; color: var(--text-muted); font-size: 12px; margin-left: 8px; }

/* ---- Forms ---- */
.formGrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 26px; }
.formRow { margin-bottom: 14px; }
.formRow label { display: block; font-weight: 600; font-size: 12.5px; color: var(--text-dark); margin-bottom: 5px; }
.formRow input[type=text],
.formRow input[type=password],
.formRow input[type=file],
.formRow select,
.formRow textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 14px; font-family: inherit; background: #fcfcfd; color: var(--text-dark);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.formRow input:focus, .formRow select:focus, .formRow textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); background: #fff;
}
.helpText { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

/* ---- Buttons ---- */
.btn {
  display: inline-block; background: var(--primary); color: #fff !important; border: none;
  padding: 10px 20px; border-radius: 7px; cursor: pointer; font-size: 13.5px; font-weight: 600;
  font-family: inherit; text-align: center; transition: background .15s; white-space: nowrap;
  -webkit-tap-highlight-color: transparent; vertical-align: middle; margin-right: 8px;
}
.btn:hover { background: var(--primary-dark); }
.btnSecondary { background: #fff !important; color: var(--text-dark) !important; border: 1px solid var(--border) !important; }
.btnSecondary:hover { background: #f3f4f6 !important; }
.btnDanger { background: var(--danger) !important; }
.btnDanger:hover { background: #b91c1c !important; }
.btnSuccess { background: var(--accent) !important; }
.btnSuccess:hover { background: #15803d !important; }
.btnWA {
  background: var(--wa-green) !important; color: #fff !important; border: none;
  padding: 10px 20px; border-radius: 7px; cursor: pointer; font-size: 13.5px; font-weight: 600;
  font-family: inherit; text-align: center; transition: background .15s;
  -webkit-tap-highlight-color: transparent; white-space: nowrap; display: inline-block; margin-right: 4px;
}
.btnWA:hover { background: #1ead58 !important; }
.btnWAAll {
  background: #128C7E !important; color: #fff !important; border: none;
  padding: 11px 22px; border-radius: 7px; cursor: pointer; font-size: 14px; font-weight: 700;
  font-family: inherit; text-align: center; transition: background .15s;
  -webkit-tap-highlight-color: transparent; display: inline-block; margin-right: 8px; margin-bottom: 8px;
}
.btnWAAll:hover { background: #075E54 !important; }

/* ---- Tables ---- */
.tableWrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
table.grid { width: 100%; border-collapse: collapse; min-width: 580px; }
table.grid th {
  background: #f8fafc; color: var(--text-muted); padding: 10px 11px; text-align: left;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
table.grid td { padding: 10px 11px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-dark); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: none; }
table.grid tr:hover td { background: #f8fafc; }
table.grid a { font-weight: 600; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-filed,
.badge-paid,
.badge-verified  { background: #dcfce7; color: #166534; }
.badge-rejected,
.badge-unpaid    { background: #fee2e2; color: #991b1b; }
.badge-latefiled,
.badge-late      { background: #ffedd5; color: #9a3412; }
.badge-partiallypaid,
.badge-partial   { background: #dbeafe; color: #1e40af; }
.badge-sent      { background: #dcfce7; color: #166534; }
.badge-overdue   { background: #fee2e2; color: #991b1b; }

/* ---- Messages ---- */
.errorMsg   { display: block; color: var(--danger); font-size: 13px; margin: 10px 0; font-weight: 600; }
.successMsg { display: block; color: #166534;     font-size: 13px; margin: 10px 0; font-weight: 600; }
.errorMsg:empty, .successMsg:empty { margin: 0; display: none; }

/* ---- Dashboard stats ---- */
.statCards { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.statCard {
  flex: 1; min-width: 190px; background: var(--card-bg); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); border-left: 4px solid var(--primary);
  display: flex; align-items: center; justify-content: space-between;
}
.statCard .num { font-size: 26px; font-weight: 800; color: var(--text-dark); line-height: 1; }
.statCard .lbl { font-size: 11px; color: var(--text-muted); font-weight: 600; margin-top: 5px; text-transform: uppercase; letter-spacing: .03em; }
.statCard .icon {
  width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: 20px; background: var(--primary-light); color: var(--primary); flex-shrink: 0;
}
.statCard.c2 { border-left-color: var(--warn);   } .statCard.c2 .icon { background: #fef3c7; color: var(--warn); }
.statCard.c3 { border-left-color: var(--accent);  } .statCard.c3 .icon { background: #dcfce7; color: var(--accent); }
.statCard.c4 { border-left-color: var(--danger);  } .statCard.c4 .icon { background: #fee2e2; color: var(--danger); }
.statCard.c5 { border-left-color: var(--wa-green);} .statCard.c5 .icon { background: #dcfce7; color: var(--wa-green); }

/* ---- Ledger ---- */
.ledgerSummary { display: flex; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.ledgerSummary .box { flex: 1; min-width: 150px; background: #f8fafc; border-radius: 8px; padding: 14px 16px; border: 1px solid var(--border); }
.ledgerSummary .box .v { font-size: 20px; font-weight: 800; }
.ledgerSummary .box .l { font-size: 11.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; margin-top: 4px; }
.debit  { color: var(--danger); font-weight: 700; }
.credit { color: #166534; font-weight: 700; }

/* ---- WhatsApp reminder cards ---- */
.waCard {
  background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px;
  padding: 16px 18px; margin-bottom: 14px; display: flex; align-items: flex-start; gap: 14px;
}
.waCard .waIcon { font-size: 28px; flex-shrink: 0; line-height: 1; }
.waCard h3 { margin: 0 0 4px; font-size: 14px; font-weight: 700; color: #166534; }
.waCard p  { margin: 0 0 10px; font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.waBadge { background: var(--wa-green); color: #fff; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; margin-right: 6px; }

/* ---- Misc ---- */
.muted   { color: var(--text-muted); }
.tag     { display: inline-block; background: var(--primary-light); color: var(--primary); padding: 2px 9px; border-radius: 6px; font-size: 11px; font-weight: 700; margin-right: 4px; }
hr.sep   { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
pre      { white-space: pre-wrap; word-break: break-all; }

/* ---- Login ---- */
.loginPage {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, #1d4f8c 100%);
  font-family: 'Inter', Segoe UI, Arial, sans-serif; padding: 16px;
}
.loginWrap {
  width: 100%; max-width: 380px; background: #fff; padding: 36px 32px; border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.loginWrap .brand-mark { margin: 0 auto 14px; width: 48px; height: 48px; font-size: 22px; border-radius: 12px; }
.loginWrap h1 { font-size: 18px; text-align: center; color: var(--text-dark); margin: 0 0 4px; font-weight: 800; }
.loginWrap p.sub { text-align: center; color: var(--text-muted); font-size: 12.5px; margin: 0 0 22px; }
.loginWrap .btn { width: 100%; padding: 12px; font-size: 14.5px; margin-right: 0; }
.loginHint { margin-top: 16px; font-size: 12px; color: var(--text-muted); text-align: center; background: #f8fafc; padding: 8px 12px; border-radius: 6px; }

/* ==========================================================
   RESPONSIVE
   ========================================================== */

/* Tablet */
@media (max-width: 1100px) {
  .sidebar { width: 210px; min-width: 210px; }
  .content { padding: 18px 18px 36px; }
}

/* Mobile  ≤ 900px — sidebar becomes a slide-in drawer */
@media (max-width: 900px) {
  /* Make sidebar a fixed off-canvas drawer */
  .sidebar {
    position: fixed; top: 0; left: 0;
    width: 260px; min-width: unset; height: 100%;
    z-index: 50; overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .26s cubic-bezier(.4,0,.2,1);
    box-shadow: none;
  }
  /* Open state — toggled by JS adding sidebar-open to #appShell */
  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0,0,0,.3);
  }

  /* Show hamburger */
  .menuToggle { display: flex; }

  /* Topbar */
  .topbar { padding: 10px 14px; gap: 8px; }
  .page-title { font-size: 15px; }
  .userinfo .uname { display: none; } /* hide text on small screens, keep avatar */
  .logoutLink { padding: 6px 10px; font-size: 12px; margin-left: 2px; }

  /* Content */
  .content { padding: 14px 12px 32px; }
  .panel { padding: 14px; margin-bottom: 14px; }
  .panel h2 { font-size: 14px; margin-bottom: 12px; }
  .panel h2 .sub { display: block; margin-left: 0; margin-top: 3px; }

  /* Forms collapse to single column */
  .formGrid { grid-template-columns: 1fr; gap: 0; }
  .formRow input[type=text],
  .formRow input[type=password],
  .formRow input[type=file],
  .formRow select,
  .formRow textarea {
    font-size: 16px !important; /* prevent iOS zoom */
    padding: 11px 12px;
  }

  /* Buttons — full-width stacking */
  .btn, .btnSecondary, .btnDanger, .btnSuccess, .btnWA, .btnWAAll {
    display: block; width: 100%; margin-right: 0; margin-bottom: 10px; padding: 13px 16px; font-size: 14px;
  }

  /* Stats cards stack */
  .statCards { flex-direction: column; gap: 10px; }
  .statCard { min-width: unset; }

  /* Ledger summary stacks */
  .ledgerSummary { flex-direction: column; gap: 10px; }
  .ledgerSummary .box { min-width: unset; }

  /* Tables: wrap in scrollable div via .tableWrap in markup */
  .tableWrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); }
  table.grid { min-width: 600px; }
  table.grid th, table.grid td { font-size: 12px; padding: 9px 8px; }

  /* WhatsApp cards */
  .waCard { flex-direction: column; gap: 8px; }
}

/* Very small phones */
@media (max-width: 420px) {
  .sidebar { width: 82vw; }
  .topbar { padding: 8px 10px; }
  .page-title { font-size: 14px; }
  .statCard .num { font-size: 22px; }
  .loginWrap { padding: 28px 20px; }
}
