/* ═══════════════════════════════════════════
   HexaPay – UI Framework
   Single-screen, no-scroll viewport layout
   ═══════════════════════════════════════════ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design Tokens ── */
:root {
  --sb-w:          220px;
  --tb-h:           52px;
  --p:          #3B82F6;
  --p-dk:       #2563EB;
  --success:    #10B981;
  --warning:    #F59E0B;
  --danger:     #EF4444;
  --info:       #06B6D4;
  --bg:         #F1F5F9;
  --card:       #FFFFFF;
  --border:     #E2E8F0;
  --text:       #1E293B;
  --text2:      #64748B;
  --text3:      #94A3B8;
  --sb-bg:      #0F172A;
  --sb-hover:   rgba(255,255,255,.05);
  --sb-active:  rgba(59,130,246,.14);
  --r:          10px;
  --r-sm:        6px;
  --r-xs:        4px;
}

/* ── Base ── */
html, body {
  height: 100%;
  overflow: hidden;                    /* ← page never scrolls */
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Root layout ── */
body { display: flex; }

/* ════════════ SIDEBAR ════════════ */
#sb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 90;
}
#sb-overlay.open { display: block; }

#sb {
  width: var(--sb-w);
  height: 100vh;
  flex-shrink: 0;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
  transition: transform .24s cubic-bezier(.4,0,.2,1);
}

/* Brand */
.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.sb-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: #F1F5F9;
  letter-spacing: .2px;
}
.sb-brand-sub {
  font-size: 9px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .9px;
  margin-top: 1px;
}

/* Section labels */
.sb-section {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: rgba(148,163,184,.4);
  padding: 12px 16px 3px;
}

/* Nav links */
.sb-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6.5px 16px;
  font-size: 12px;
  color: #94A3B8;
  text-decoration: none;
  position: relative;
  transition: background .13s, color .13s;
}
.sb-link i {
  width: 14px;
  font-size: 11.5px;
  flex-shrink: 0;
  text-align: center;
}
.sb-link:hover { background: var(--sb-hover); color: #E2E8F0; }
.sb-link.active {
  background: var(--sb-active);
  color: #60A5FA;
  font-weight: 600;
}
.sb-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 5px; bottom: 5px;
  width: 3px;
  background: #3B82F6;
  border-radius: 0 2px 2px 0;
}

/* Footer */
.sb-footer {
  margin-top: auto;
  padding: 10px 10px 14px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.sb-footer a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5.5px 10px;
  font-size: 11.5px;
  color: rgba(148,163,184,.75);
  text-decoration: none;
  border-radius: var(--r-sm);
  transition: background .13s, color .13s;
}
.sb-footer a:hover { background: var(--sb-hover); color: #E2E8F0; }
.sb-footer i { width: 13px; font-size: 11px; text-align: center; }

/* ════════════ MAIN COLUMN ════════════ */
#main {
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;              /* never scroll the wrapper */
}

/* ── Topbar ── */
#topbar {
  height: var(--tb-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  flex-shrink: 0;
  z-index: 10;
}
.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 15px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--r-sm);
  align-items: center;
  justify-content: center;
}
.hamburger:hover { background: var(--bg); }

.topbar-left { flex: 1; min-width: 0; }
.topbar-greeting { font-size: 13px; font-weight: 700; color: var(--text); }

.topbar-search {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px 11px;
  width: 240px;
}
.topbar-search i { color: var(--text3); font-size: 11px; }
.topbar-search input {
  background: none; border: none; outline: none;
  font-size: 12px; color: var(--text); width: 100%;
}
.topbar-search input::placeholder { color: var(--text3); }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.notif-btn {
  position: relative;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  cursor: pointer; color: var(--text2);
  transition: background .13s;
}
.notif-btn:hover { background: var(--bg); }
.notif-btn i { font-size: 13.5px; }
.notif-badge {
  position: absolute; top: 4px; right: 4px;
  width: 14px; height: 14px;
  background: var(--danger); color: #fff;
  font-size: 7.5px; font-weight: 700;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--card);
}

.user-chip {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px 3px 3px;
  cursor: default;
}
.avatar {
  width: 26px; height: 26px;
  background: var(--p); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.user-name { font-size: 11.5px; font-weight: 600; line-height: 1.2; }
.user-role { font-size: 10px; color: var(--text2); line-height: 1.2; }

/* ── Inline alerts (flash) ── */
.alert {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: var(--r-sm);
  font-size: 12.5px; margin-bottom: 0;
}
.alert-success { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.alert-danger  { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.mt-3 { margin-top: 8px !important; }

/* ════════════ CONTENT AREA ════════════ */
.content {
  flex: 1;
  min-height: 0;              /* critical for flex child shrink */
  overflow: hidden;           /* page itself never scrolls */
  padding: 10px 14px 10px;
  display: flex;
  flex-direction: column;
}

/* ════════════ DASHBOARD GRID ════════════ */
.dash {
  display: grid;
  height: 100%;
  min-height: 0;
  gap: 8px;
  grid-template-rows: auto auto 1fr;   /* KPIs | mid cards | chart+table */
}

/* KPI row */
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

/* Middle cards row */
.dash-mid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

/* Bottom row: chart left, table right */
.dash-bottom {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 8px;
  min-height: 0;
}

/* ── KPI Card ── */
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kpi-label {
  font-size: 10px; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px;
}
.kpi-value { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1; }
.kpi-sub   { font-size: 10.5px; color: var(--text3); margin-top: 3px; }
.kpi-sub .up { color: var(--success); font-weight: 600; }
.kpi-icon {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.kpi-icon.blue   { background: #EFF6FF; color: #3B82F6; }
.kpi-icon.green  { background: #F0FDF4; color: #10B981; }
.kpi-icon.orange { background: #FFF7ED; color: #F97316; }
.kpi-icon.teal   { background: #F0FDFA; color: #14B8A6; }

/* ── Cards (generic) ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  min-height: 0;
}
.stat-card { }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 13px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.card-header-title {
  font-size: 12px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.card-body {
  padding: 10px 13px;
  flex: 1; overflow-y: auto; min-height: 0;
}

/* ── Progress ── */
.progress { background: var(--bg); border-radius: 20px; overflow: hidden; }
.progress-bar {
  background: var(--p); height: 100%; border-radius: 20px;
  transition: width .5s ease;
}

/* ── Dept chart rows ── */
.dept-chart-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 7px;
}
.dept-name {
  font-size: 11px; color: var(--text2);
  width: 88px; flex-shrink: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dept-amount {
  font-size: 11px; font-weight: 700; color: var(--text);
  width: 74px; flex-shrink: 0; text-align: right;
}
.dept-emp {
  font-size: 10px; color: var(--text3);
  width: 44px; flex-shrink: 0; text-align: right;
}

/* ── Table ── */
.table-wrap { overflow-y: auto; flex: 1; min-height: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  font-size: 10px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text2); font-weight: 700;
  padding: 7px 13px; border-bottom: 1px solid var(--border);
  background: var(--bg); white-space: nowrap; position: sticky; top: 0;
}
.table td {
  font-size: 12px; padding: 6px 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { background: #F8FAFC; }
.hide-mobile { }

/* ── Badges ── */
.badge {
  font-size: 10px; padding: 2px 7px;
  border-radius: 20px; font-weight: 600;
  display: inline-block;
}
.b-locked    { background: #EDE9FE; color: #5B21B6; }
.b-generated { background: #D1FAE5; color: #065F46; }

/* ── Emp avatar ── */
.emp-avatar {
  border-radius: 50%; background: var(--p); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}

/* ── Empty state ── */
.empty-state { text-align: center; padding: 20px 0; color: var(--text3); }
.empty-state i { font-size: 22px; margin-bottom: 6px; display: block; }
.empty-state p { font-size: 11.5px; }

/* ── Buttons ── */
.btn {
  font-size: 12px; padding: 5px 11px; border-radius: var(--r-sm);
  font-weight: 500; cursor: pointer; transition: all .13s;
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; border: 1px solid transparent; line-height: 1.4;
}
.btn-sm { font-size: 11px; padding: 3.5px 9px; }
.btn-primary         { background: var(--p);   color:#fff;          border-color:var(--p);    }
.btn-primary:hover   { background: var(--p-dk);                                               }
.btn-warning         { background: var(--warning); color:#fff;      border-color:var(--warning); }
.btn-outline-primary { background:transparent; color:var(--p);      border-color:var(--p);    }
.btn-outline-primary:hover   { background:#EFF6FF; }
.btn-outline-success { background:transparent; color:var(--success); border-color:var(--success); }
.btn-outline-success:hover   { background:#F0FDF4; }
.btn-outline-warning { background:transparent; color:#D97706;       border-color:#D97706;     }
.btn-outline-warning:hover   { background:#FEF3C7; }
.btn-outline-info    { background:transparent; color:#0891B2;       border-color:#0891B2;     }
.btn-outline-info:hover      { background:#ECFEFF; }
.btn-outline-danger  { background:transparent; color:var(--danger); border-color:var(--danger); }
.btn-outline-danger:hover    { background:#FEF2F2; }
.btn-outline-secondary { background:transparent; color:var(--text2); border-color:var(--border); }
.btn-outline-secondary:hover { background:var(--bg); }
.d-grid { display: grid; }
.gap-2  { gap: 6px !important; }
.gap-3  { gap: 10px !important; }
.text-start { text-align: left; justify-content: flex-start; }

/* ── Quick-action grid (2 columns) ── */
.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.quick-grid .btn {
  font-size: 11px;
  padding: 5px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Toast ── */
.toast-container {
  position: fixed; bottom: 18px; right: 18px;
  z-index: 9999; display: flex; flex-direction: column; gap: 6px;
}
.hx-toast {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 14px; border-radius: var(--r);
  font-size: 12.5px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  transition: opacity .4s;
}
.toast-success { background:#ECFDF5; color:#065F46; border-left:3px solid var(--success); }
.toast-error   { background:#FEF2F2; color:#991B1B; border-left:3px solid var(--danger);  }
.toast-warning { background:#FFFBEB; color:#92400E; border-left:3px solid var(--warning); }

/* ── Flash strip ── */
.flash-strip {
  padding: 0 14px 6px;
  flex-shrink: 0;
}

/* ── Utility ── */
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.font-display { font-family: inherit; }
.text-muted { color: var(--text2) !important; }

/* ════════════ RESPONSIVE ════════════ */
@media (max-width: 991px) {
  .dash-bottom { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  #sb {
    position: fixed; left: 0; top: 0; height: 100vh;
    transform: translateX(-100%);
  }
  #sb.open { transform: translateX(0); }
  .hamburger { display: flex; }

  .dash-kpis { grid-template-columns: 1fr 1fr; }
  .dash-mid  { grid-template-columns: 1fr; grid-template-rows: auto; }
  .dash-bottom { grid-template-columns: 1fr; }
  .dash { grid-template-rows: auto auto auto auto; overflow-y: auto; }
  .content { overflow-y: auto; }    /* allow scroll on mobile */

  .hide-mobile { display: none; }
  .topbar-search { display: none !important; }
  .content { padding: 8px 10px; }
}

@media (min-width: 768px) {
  .hamburger { display: none !important; }
}
