/* ── AfriLink Pay — Dashboard shared styles ─────────────────────────────── */
/* Requires styles.css to be loaded first for CSS tokens                      */

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

/* ── Layout shell ────────────────────────────────────────────────────────── */
.dash-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  overflow: hidden;
  background: var(--bg, #050508);
  color: var(--t-hi, #f8f8fc);
  font-family: 'Space Grotesk', sans-serif;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.dash-topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem;
  background: rgba(255,255,255,0.025);
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
  z-index: 10;
}
.dash-brand {
  display: flex; align-items: center; gap: .6rem;
  font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.1rem;
  text-decoration: none; color: inherit;
}
.dash-brand .brand-icon {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #00D26A, #00a052);
  display: grid; place-items: center;
  font-family: 'Syne', sans-serif; font-weight: 800; font-size: .8rem; color: #050508;
}
.dash-badge {
  font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  padding: .2rem .55rem; border-radius: 20px;
  background: rgba(0,210,106,.15); color: var(--accent, #00D26A);
  border: 1px solid rgba(0,210,106,.25);
}
.dash-badge.admin { background: rgba(255,176,0,.12); color: #FFB000; border-color: rgba(255,176,0,.25); }
.dash-topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.dash-user { font-size: .82rem; color: var(--t-mid); }
.btn-sm {
  font-size: .75rem; font-family: 'Space Grotesk', sans-serif; font-weight: 600;
  padding: .35rem .85rem; border-radius: 8px; cursor: pointer; border: none;
  background: rgba(255,255,255,0.07); color: var(--t-hi); transition: background .15s;
}
.btn-sm:hover { background: rgba(255,255,255,0.12); }
.btn-sm.danger { background: rgba(255,77,106,.12); color: #ff4d6a; }
.btn-sm.danger:hover { background: rgba(255,77,106,.22); }
.btn-sm.primary { background: var(--accent, #00D26A); color: #050508; }
.btn-sm.primary:hover { background: #00b85d; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.dash-sidebar {
  background: rgba(255,255,255,0.018);
  border-right: 1px solid var(--border, rgba(255,255,255,0.08));
  overflow-y: auto; padding: 1rem 0;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.sidebar-section-label {
  font-size: .63rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--t-low, rgba(248,248,252,0.38));
  padding: .75rem 1.25rem .35rem;
}
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem 1.25rem; cursor: pointer; border: none; width: 100%;
  background: none; color: var(--t-mid, rgba(248,248,252,0.65));
  font-family: 'Space Grotesk', sans-serif; font-size: .85rem; font-weight: 500;
  text-align: left; border-radius: 0; transition: background .12s, color .12s;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--t-hi); }
.nav-item.active {
  background: rgba(0,210,106,.1); color: var(--accent, #00D26A);
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; background: var(--accent, #00D26A); border-radius: 0 2px 2px 0;
}
.nav-icon { font-size: 1rem; width: 1.2rem; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; font-size: .65rem; font-weight: 700;
  padding: .1rem .4rem; border-radius: 10px;
  background: rgba(255,77,106,.15); color: #ff4d6a;
}

/* ── Main content ─────────────────────────────────────────────────────────── */
.dash-main {
  overflow-y: auto; padding: 2rem;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}

/* ── Section header ───────────────────────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.75rem;
}
.section-title {
  font-family: 'Syne', sans-serif; font-size: 1.6rem; font-weight: 800;
  letter-spacing: -.03em;
}
.section-sub { font-size: .85rem; color: var(--t-mid); margin-top: .2rem; }

/* ── Stat cards grid ──────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem; margin-bottom: 2rem;
}
.stat-card {
  background: var(--bg-card, rgba(255,255,255,0.045));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: var(--r-lg, 14px); padding: 1.25rem 1.35rem;
  backdrop-filter: blur(16px);
}
.stat-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--t-low); margin-bottom: .5rem;
}
.stat-value {
  font-family: 'Syne', sans-serif; font-size: 2rem; font-weight: 800;
  letter-spacing: -.04em; line-height: 1;
}
.stat-value.accent { color: var(--accent, #00D26A); }
.stat-value.gold   { color: #FFB000; }
.stat-value.blue   { color: #0096FF; }
.stat-value.red    { color: #ff4d6a; }
.stat-trend {
  font-size: .78rem; color: var(--t-mid); margin-top: .4rem;
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card, rgba(255,255,255,0.045));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: var(--r-xl, 20px); padding: 1.5rem;
  backdrop-filter: blur(16px); margin-bottom: 1.5rem;
}
.card-title {
  font-family: 'Syne', sans-serif; font-size: 1rem; font-weight: 700;
  margin-bottom: 1.25rem; display: flex; align-items: center; gap: .5rem;
}

/* ── Table ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .83rem; }
th {
  text-align: left; font-size: .65rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--t-low); padding: .65rem 1rem; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: .75rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--t-hi); vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.025); }

/* ── Status pills ──────────────────────────────────────────────────────────── */
.pill {
  display: inline-block; font-size: .67rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  padding: .18rem .55rem; border-radius: 20px;
}
.pill-completed, .pill-success { background: rgba(0,210,106,.12); color: #00D26A; }
.pill-pending, .pill-processing { background: rgba(255,176,0,.12); color: #FFB000; }
.pill-failed, .pill-error { background: rgba(255,77,106,.12); color: #ff4d6a; }
.pill-info { background: rgba(0,150,255,.12); color: #0096FF; }
.pill-neutral { background: rgba(255,255,255,.08); color: var(--t-mid); }

/* ── Form elements ──────────────────────────────────────────────────────────── */
.form-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .35rem; flex: 1; min-width: 160px; }
label { font-size: .72rem; color: var(--t-low); text-transform: uppercase; letter-spacing: .06em; }
input[type=text], input[type=email], input[type=number],
input[type=tel], input[type=password], select, textarea {
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  border-radius: 10px; padding: .6rem .85rem;
  color: var(--t-hi); font-family: 'Space Grotesk', sans-serif; font-size: .88rem;
  outline: none; transition: border-color .15s, background .15s; width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent, #00D26A); background: rgba(255,255,255,0.09);
}
select option { background: #14141f; }
textarea { resize: vertical; min-height: 80px; }

/* ── Toggle switch ──────────────────────────────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.toggle { position: relative; width: 44px; height: 24px; cursor: pointer; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; border-radius: 24px;
  background: rgba(255,255,255,0.1); transition: background .2s;
}
.toggle input:checked + .toggle-track { background: var(--accent, #00D26A); }
.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .2s; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.toggle input:checked ~ .toggle-thumb { transform: translateX(20px); }

/* ── Module cards ────────────────────────────────────────────────────────── */
.modules-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem;
}
.module-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 1.25rem 1.35rem;
  display: flex; align-items: flex-start; gap: 1rem;
  transition: border-color .2s;
}
.module-card.enabled { border-color: rgba(0,210,106,.25); }
.module-icon { font-size: 1.5rem; flex-shrink: 0; margin-top: .1rem; }
.module-info { flex: 1; }
.module-name { font-weight: 600; font-size: .9rem; margin-bottom: .2rem; }
.module-desc { font-size: .78rem; color: var(--t-mid); line-height: 1.4; }

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: .5rem; margin-top: 1rem;
  justify-content: flex-end; font-size: .82rem; color: var(--t-mid);
}
.page-btn {
  padding: .3rem .65rem; border-radius: 7px; border: 1px solid var(--border);
  background: none; color: var(--t-hi); cursor: pointer; font-size: .82rem;
  font-family: 'Space Grotesk', sans-serif; transition: background .12s;
}
.page-btn:hover { background: rgba(255,255,255,0.07); }
.page-btn:disabled { opacity: .35; cursor: default; }

/* ── Inline code / monospace ─────────────────────────────────────────────── */
.mono { font-family: monospace; font-size: .78rem; color: var(--t-mid); }
.copy-key {
  display: flex; align-items: center; gap: .5rem;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  border-radius: 10px; padding: .5rem .9rem;
  font-family: monospace; font-size: .82rem; color: var(--accent);
  cursor: pointer; transition: background .15s; word-break: break-all;
}
.copy-key:hover { background: rgba(0,210,106,.08); }

/* ── Login gate ───────────────────────────────────────────────────────────── */
.login-gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg, #050508);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 2.5rem 2rem;
  backdrop-filter: blur(24px);
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
}
.login-card h2 { font-family: 'Syne', sans-serif; font-size: 1.6rem; font-weight: 800; margin-bottom: .4rem; }
.login-card p  { font-size: .85rem; color: var(--t-mid); margin-bottom: 1.75rem; }
.login-btn {
  width: 100%; padding: .85rem; border-radius: 12px; border: none; cursor: pointer;
  background: var(--accent, #00D26A); color: #050508;
  font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1rem;
  transition: background .15s; margin-top: .5rem;
}
.login-btn:hover { background: #00b85d; }
.login-error { color: #ff4d6a; font-size: .82rem; margin-top: .75rem; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 4rem 2rem;
  color: var(--t-mid); font-size: .9rem;
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .5; }

/* ── Loading skeleton ──────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.09) 50%, rgba(255,255,255,.05) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
  border-radius: 6px; height: 1rem;
}
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast-wrap {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: .5rem; z-index: 9999;
}
.toast {
  padding: .75rem 1.1rem; border-radius: 12px; font-size: .85rem; font-weight: 500;
  background: rgba(20,20,31,0.95); border: 1px solid var(--border);
  backdrop-filter: blur(12px); color: var(--t-hi);
  animation: toastIn .2s ease; max-width: 340px;
}
.toast.success { border-color: rgba(0,210,106,.3); }
.toast.error   { border-color: rgba(255,77,106,.3); color: #ff4d6a; }
.toast-out { animation: toastOut .2s ease forwards; }
@keyframes toastIn  { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: none; } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform: translateY(8px); } }

/* ── Simple bar chart ─────────────────────────────────────────────────────── */
.bar-chart { display: flex; flex-direction: column; gap: .55rem; }
.bar-row { display: flex; align-items: center; gap: .75rem; font-size: .8rem; }
.bar-label { width: 120px; flex-shrink: 0; color: var(--t-mid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 6px; background: rgba(255,255,255,.07); border-radius: 3px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 3px; background: var(--accent, #00D26A); transition: width .6s ease; }
.bar-count { width: 40px; text-align: right; color: var(--t-low); flex-shrink: 0; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .dash-shell { grid-template-columns: 1fr; grid-template-rows: 56px auto 1fr; }
  .dash-sidebar { display: none; }
  .dash-sidebar.open { display: block; position: fixed; inset: 56px 0 0 0; z-index: 50; background: #0d0d14; }
  .dash-topbar { gap: .5rem; }
  .hamburger { display: flex; flex-direction: column; gap: 4px; cursor: pointer; padding: .4rem; }
  .hamburger span { display: block; width: 20px; height: 2px; background: var(--t-hi); border-radius: 1px; }
  .dash-main { padding: 1.25rem; }
}
@media (min-width: 901px) { .hamburger { display: none; } }

/* ═══════════════════════════════════════════════════════════════
   v1.1 additions — Light theme · Theme toggle · Lang selector
   ═══════════════════════════════════════════════════════════════ */

/* Light theme overrides for dashboards */
[data-theme="light"] .dash-shell   { background: #EFF1F6; color: #0D1117; }
[data-theme="light"] .dash-topbar  { background: rgba(239,241,246,.95); border-color: rgba(0,0,0,.08); }
[data-theme="light"] .dash-sidebar { background: rgba(255,255,255,.75); border-color: rgba(0,0,0,.08); }
[data-theme="light"] .nav-item     { color: #566075; }
[data-theme="light"] .nav-item:hover { background: rgba(0,0,0,.04); color: #0D1117; }
[data-theme="light"] .nav-item.active { background: rgba(0,210,106,.08); color: #00a052; }
[data-theme="light"] .stat-card,
[data-theme="light"] .card         { background: rgba(255,255,255,.88); border-color: rgba(0,0,0,.07); }
[data-theme="light"] th            { color: #8B95A8; border-color: rgba(0,0,0,.07); }
[data-theme="light"] td            { color: #0D1117; border-color: rgba(0,0,0,.04); }
[data-theme="light"] tr:hover td   { background: rgba(0,0,0,.02); }
[data-theme="light"] input[type=text],
[data-theme="light"] input[type=email],
[data-theme="light"] input[type=number],
[data-theme="light"] input[type=tel],
[data-theme="light"] input[type=password],
[data-theme="light"] select,
[data-theme="light"] textarea      { background: rgba(0,0,0,.045); border-color: rgba(0,0,0,.1); color: #0D1117; }
[data-theme="light"] select option { background: #fff; color: #0D1117; }
[data-theme="light"] .login-gate   { background: #EFF1F6; }
[data-theme="light"] .login-card   { background: rgba(255,255,255,.9); border-color: rgba(0,0,0,.09); }
[data-theme="light"] .toast        { background: rgba(255,255,255,.97); border-color: rgba(0,0,0,.1); color: #0D1117; }
[data-theme="light"] .btn-sm       { background: rgba(0,0,0,.06); color: #0D1117; }
[data-theme="light"] .btn-sm:hover { background: rgba(0,0,0,.1); }
[data-theme="light"] .copy-key     { background: rgba(0,0,0,.04); border-color: rgba(0,0,0,.08); }
[data-theme="light"] .dash-sidebar.open { background: #f5f7fc; }

/* Theme toggle for topbar */
.dash-theme-toggle {
  width: 32px; height: 32px; flex-shrink: 0;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px; font-size: .95rem; line-height: 1;
  display: grid; place-items: center; cursor: pointer;
  transition: all .15s;
}
.dash-theme-toggle:hover { background: rgba(255,255,255,.13); transform: rotate(20deg); }
[data-theme="light"] .dash-theme-toggle { background: rgba(0,0,0,.05); border-color: rgba(0,0,0,.1); }
[data-theme="light"] .dash-theme-toggle:hover { background: rgba(0,0,0,.1); }

/* Language selector for topbar */
.dash-lang-wrap { position: relative; flex-shrink: 0; }
.dash-lang-select {
  padding: .3rem .45rem; padding-right: 1.3rem;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px; color: rgba(255,255,255,.6);
  font-size: .75rem; font-weight: 600; font-family: 'Space Grotesk', sans-serif;
  outline: none; cursor: pointer; -webkit-appearance: none; appearance: none;
  transition: all .15s;
}
.dash-lang-select:focus { border-color: var(--accent, #00D26A); color: #fff; }
.dash-lang-wrap::after {
  content: '▾'; position: absolute; right: .4rem; top: 50%;
  transform: translateY(-50%); pointer-events: none;
  color: rgba(255,255,255,.4); font-size: .55rem;
}
[data-theme="light"] .dash-lang-select { background: rgba(0,0,0,.05); border-color: rgba(0,0,0,.1); color: #566075; }
[data-theme="light"] .dash-lang-select option { background: #fff; color: #0D1117; }
[data-theme="light"] .dash-lang-wrap::after { color: #8B95A8; }

/* Better mobile stats grid */
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: .65rem; }
  .stat-value  { font-size: 1.5rem; }
  .section-title { font-size: 1.25rem; }
  .dash-main { padding: 1rem; }
  .form-row  { flex-direction: column; }
  .modules-grid { grid-template-columns: 1fr; }
  .table-wrap { font-size: .75rem; }
  th, td { padding: .5rem .65rem; }
}
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
}
