/* =====================================================================
   Trustbundle - Core Stylesheet
   Professional blue fintech theme. Light theme default, dark via
   [data-theme="dark"] on <html>, toggled from app.js and persisted
   through /api/save-theme.
   ===================================================================== */

:root {
  --primary: #1e3a5f;
  --primary-light: #2c5282;
  --primary-dark: #142a45;
  --accent: #2b6cb0;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;

  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #64748b;
  --sidebar-width: 260px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.12);
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #16213a;
  --border: #2d3f5c;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  transition: background 0.2s ease, color 0.2s ease;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0 0 0.5em; color: var(--text); }
p { margin: 0 0 1em; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* -------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-light { background: var(--surface-alt); color: var(--text); border-color: var(--border); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn .fa-spinner { display: none; }
.btn.loading .fa-spinner { display: inline-block; }
.btn.loading .btn-label { opacity: 0.7; }

/* -------------------------------------------------------------------
   Forms
   ------------------------------------------------------------------- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; color: var(--text); }
.form-control, select.form-control, textarea.form-control {
  width: 100%;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}
.form-control.is-invalid { border-color: var(--danger); }
.form-hint { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12.5px; color: var(--danger); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.input-group { position: relative; }
.required::after { content: " *"; color: var(--danger); }

/* -------------------------------------------------------------------
   Cards
   ------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.card-title { font-size: 17px; font-weight: 700; margin: 0; }

/* -------------------------------------------------------------------
   Alerts
   ------------------------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  margin-bottom: 18px;
  font-size: 14px;
  position: relative;
}
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
[data-theme="dark"] .alert-success { background: #06281c; color: #6ee7b7; }
[data-theme="dark"] .alert-error { background: #2a1010; color: #fca5a5; }
[data-theme="dark"] .alert-info { background: #0f2138; color: #93c5fd; }
[data-theme="dark"] .alert-warning { background: #2a2008; color: #fcd34d; }
.alert-close { margin-left: auto; background: none; border: none; cursor: pointer; color: inherit; opacity: 0.6; font-size: 16px; }
.alert-close:hover { opacity: 1; }

/* -------------------------------------------------------------------
   Badges
   ------------------------------------------------------------------- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; text-transform: capitalize; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-in_progress, .badge-processing { background: #dbeafe; color: #1e40af; }
.badge-completed, .badge-success { background: #d1fae5; color: #065f46; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-credit { background: #d1fae5; color: #065f46; }
.badge-debit { background: #fee2e2; color: #991b1b; }

/* -------------------------------------------------------------------
   Result cards (verification/telecom outputs)
   ------------------------------------------------------------------- */
.result-card { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-top: 20px; }
.result-photo { width: 110px; height: 130px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 14px; }
.result-field-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 2px; }
.result-field-value { font-weight: 600; }

/* -------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.table th, table.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.table th { color: var(--text-muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
table.table tbody tr:hover { background: var(--surface-alt); }

/* -------------------------------------------------------------------
   Public site header/footer (main layout)
   ------------------------------------------------------------------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; color: var(--primary); }
.brand i { color: var(--accent); }
.site-nav { display: flex; gap: 22px; align-items: center; }
.hero { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); color: #fff; padding: 80px 0 60px; }
.hero h1 { color: #fff; font-size: 40px; max-width: 700px; }
.hero p { color: rgba(255,255,255,0.85); font-size: 17px; max-width: 600px; }
.hero-actions { display: flex; gap: 14px; margin-top: 24px; flex-wrap: wrap; }
/* flexbox + flex-basis instead of CSS Grid auto-fill/minmax - some
   low-end/data-saving mobile browsers common among Nigerian users
   (Opera Mini, older Android WebViews) render grid auto-fill/minmax
   incorrectly and collapse every tile onto a single line. Flex-wrap
   degrades safely everywhere and gives the same visual result. */
.services-grid { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 30px; }
.service-tile { flex: 1 1 230px; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-align: left; transition: transform 0.15s ease, box-shadow 0.15s ease; display: block; }
.service-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); text-decoration: none; }
.service-tile i { font-size: 26px; color: var(--accent); margin-bottom: 10px; }
.service-tile h3 { font-size: 15px; margin: 6px 0 4px; color: var(--text); }
.service-tile p { font-size: 13px; color: var(--text-muted); margin: 0; }
.site-footer { background: var(--primary-dark); color: rgba(255,255,255,0.7); padding: 40px 0; margin-top: 60px; font-size: 13.5px; }
.site-footer a { color: #fff; }

/* -------------------------------------------------------------------
   Auth pages
   ------------------------------------------------------------------- */
.auth-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.auth-box { width: 100%; max-width: 420px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 36px; }
.auth-box .brand { justify-content: center; margin-bottom: 20px; }
.auth-box h1 { font-size: 21px; text-align: center; }
.auth-box .subtitle { text-align: center; color: var(--text-muted); font-size: 13.5px; margin-bottom: 24px; }
.auth-footer-link { text-align: center; margin-top: 18px; font-size: 13.5px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-google { background: var(--surface); border: 1px solid var(--border); color: var(--text); }

/* -------------------------------------------------------------------
   Dashboard shell
   ------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-width);
  background: var(--primary);
  color: #fff;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.25s ease;
}
.sidebar .brand { color: #fff; padding: 22px 20px; font-size: 19px; }
.sidebar-nav { padding: 10px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 8px; color: rgba(255,255,255,0.75);
  font-size: 14px; font-weight: 500; margin-bottom: 2px;
}
.sidebar-nav a i { width: 18px; text-align: center; }
.sidebar-nav a:hover, .sidebar-nav a.active { background: rgba(255,255,255,0.12); color: #fff; text-decoration: none; }
.sidebar-section-label { padding: 16px 14px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: rgba(255,255,255,0.45); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 90; }
.sidebar-overlay.show { display: block; }

.main-content { margin-left: var(--sidebar-width); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 40; }
.topbar-left { display: flex; align-items: center; gap: 14px; }
.sidebar-toggle, .mobile-nav-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.icon-btn { position: relative; background: var(--surface-alt); border: 1px solid var(--border); width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text); }
.icon-btn .dot { position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: none; }
.icon-btn.has-unread .dot { display: block; }
.page-content { padding: 26px; flex: 1; }

/* Dropdowns */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 240px; display: none; z-index: 60; overflow: hidden; }
.dropdown-menu.show { display: block; }
.dropdown-menu a, .dropdown-item { display: flex; align-items: center; gap: 10px; padding: 11px 16px; color: var(--text); font-size: 13.5px; cursor: pointer; }
.dropdown-menu a:hover, .dropdown-item:hover { background: var(--surface-alt); text-decoration: none; }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.notif-item.unread { background: var(--surface-alt); }
.notif-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Dashboard "Recent Notifications" card — Android-style list on every device */
.dash-notif-item { display: flex; align-items: flex-start; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.dash-notif-item:last-child { border-bottom: none; }
.dash-notif-item.unread { background: var(--surface-alt); }
.dash-notif-icon { width: 36px; height: 36px; border-radius: 50%; background: rgba(43,108,176,0.12); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.dash-notif-item.unread .dash-notif-icon { background: var(--accent); color: #fff; }
.dash-notif-body { flex: 1; min-width: 0; }
.dash-notif-title { font-size: 13.5px; font-weight: 600; }
.dash-notif-msg { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* Dashboard "Recent Transactions" card — table on desktop, Android-style list on phones */
.tx-mobile-list { display: none; }
.tx-mobile-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.tx-mobile-item:last-child { border-bottom: none; }
.tx-mobile-icon { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; background: rgba(43,108,176,0.12); color: var(--accent); }
.tx-mobile-icon.badge-success, .tx-mobile-icon.badge-completed { background: #d1fae5; color: #065f46; }
.tx-mobile-icon.badge-pending { background: #fef3c7; color: #92400e; }
.tx-mobile-icon.badge-failed { background: #fee2e2; color: #991b1b; }
.tx-mobile-body { flex: 1; min-width: 0; }
.tx-mobile-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tx-mobile-service { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-mobile-amount { font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.tx-mobile-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 3px; }
.tx-mobile-ref { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) {
  .tx-desktop-view { display: none; }
  .tx-mobile-list { display: block; }
}

/* Stat tiles */
/* flex-wrap instead of grid auto-fit/minmax - see the note on .services-grid above. */
.stats-grid { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 26px; }
.stat-card { flex: 1 1 200px; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 46px; height: 46px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; background: rgba(43,108,176,0.12); color: var(--accent); flex-shrink: 0; }
.stat-value { font-size: 22px; font-weight: 800; }
.stat-label { font-size: 12.5px; color: var(--text-muted); }

.wallet-card { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); color: #fff; border-radius: 14px; padding: 26px; }
.wallet-card .label { color: rgba(255,255,255,0.75); font-size: 13px; }
.wallet-card .amount { font-size: 32px; font-weight: 800; margin: 6px 0 16px; }
.va-block { background: rgba(255,255,255,0.12); border-radius: 10px; padding: 14px 16px; font-size: 13.5px; }
.va-block .va-number { font-size: 18px; font-weight: 700; letter-spacing: 0.03em; }

.quick-amounts { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 18px; }
.quick-amount-btn { padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-alt); cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--text); }
.quick-amount-btn.active, .quick-amount-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tab-btn { padding: 12px 18px; background: none; border: none; border-bottom: 2px solid transparent; font-weight: 600; font-size: 14px; color: var(--text-muted); cursor: pointer; }
.tab-btn.active { color: var(--primary); border-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.55); display: none; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal-box { background: var(--surface); border-radius: 14px; max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 26px; box-shadow: var(--shadow-lg); }
.modal-close { float: right; background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }

/* Pagination */
.pagination { display: flex; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 8px 13px; border-radius: 6px; border: 1px solid var(--border); font-size: 13px; color: var(--text); }
.pagination a:hover { background: var(--surface-alt); text-decoration: none; }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Directors dynamic list (CAC) */
.director-row { border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 14px; position: relative; }
.director-row .remove-director { position: absolute; top: 10px; right: 10px; background: none; border: none; color: var(--danger); cursor: pointer; }

/* Loader */
.page-loader { position: fixed; inset: 0; background: rgba(255,255,255,0.75); display: none; align-items: center; justify-content: center; z-index: 999; }
[data-theme="dark"] .page-loader { background: rgba(15,23,42,0.75); }
.page-loader.show { display: flex; }
.spinner { width: 42px; height: 42px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Welcome popup */
.welcome-popup .modal-box { text-align: center; }
.welcome-popup i { font-size: 40px; color: var(--accent); margin-bottom: 14px; }

/* Utility */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 12px; } .mb-2 { margin-bottom: 12px; }
.d-flex { display: flex; } .align-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.upload-hint { font-size: 12px; color: var(--text-muted); }

/* Admin layout tweaks */
.admin-shell .sidebar { background: var(--primary-dark); }

/* -------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------- */
@media (max-width: 991px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .hero h1 { font-size: 30px; }
  .site-nav .nav-links { display: none; }
}
@media (max-width: 600px) {
  .page-content { padding: 16px; }
  .auth-box { padding: 26px; }
  .stats-grid .stat-card { flex-basis: calc(50% - 8px); }
  .topbar { padding: 0 14px; }
  .topbar-left strong { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
  .topbar-actions { gap: 8px; }
  .icon-btn { width: 34px; height: 34px; }
  .card { padding: 16px; }
  .wallet-card { padding: 18px; }
  .wallet-card .amount { font-size: 26px; }
  .services-grid { gap: 12px; margin-top: 20px; }
  .service-tile { flex-basis: calc(50% - 6px); padding: 14px; }
  .stats-grid { gap: 10px; }
}
