/* =====================================================================
   KILATOTP — Tema terang (dashboard ala "KilatOtp")
   Font: Inter. Layout: sidebar putih + topbar + strip info.
   Dibangun di atas Bootstrap 5.3 (class & ID lama tetap dipakai).
   ===================================================================== */

:root {
  --bg: #f9f9fc;
  --surface: #ffffff;
  --surface-2: #f4f4f8;
  --border: #e8e8ef;
  --border-strong: #d9d9e3;
  --text: #0f0f1a;
  --text-soft: #4b5563;
  --text-faint: #6b7280;

  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-soft: #ede9fe;
  --accent-ink: #6d28d9;

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 56px;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 16, 40, 0.04);

  --bs-primary: var(--accent);
  --bs-primary-rgb: 124, 58, 237;
  --bs-link-color: var(--accent-ink);
  --bs-link-color-rgb: 109, 40, 217;
  --bs-link-hover-color: #5b21b6;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
  --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--bs-body-font-family);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
a { text-decoration: none; }
.text-muted { color: var(--text-faint) !important; }

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

.content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: var(--sidebar-w);
  transition: margin-left 0.2s ease;
}

/* --------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  transition: width 0.2s ease, transform 0.25s ease;
}

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  flex-shrink: 0;
}
.sidebar-brand a, .topbar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
}
.brand-mark { flex-shrink: 0; display: block; }
.brand-text { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); white-space: nowrap; }
.brand-text span { color: var(--accent); }
.sidebar-close { background: none; border: 0; color: var(--text-faint); font-size: 1.1rem; padding: 4px; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  margin-bottom: 1px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-link > i:first-child { font-size: 18px; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-link:hover { background: var(--surface-2); color: var(--text); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent-ink); }
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 4px;
  bottom: 4px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}

.sidebar-divider {
  margin: 14px 12px 6px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  white-space: nowrap;
}

.sb-chevron { margin-left: auto; font-size: 12px; color: var(--text-faint); transition: transform 0.2s ease; }
.sb-group.open .sb-chevron { transform: rotate(180deg); }
.sb-sub { display: none; padding: 2px 0 4px 40px; }
.sb-group.open .sb-sub { display: block; }
.sb-sublink {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-faint);
  white-space: nowrap;
}
.sb-sublink:hover { background: var(--surface-2); color: var(--text); }
.sb-sublink.active { color: var(--accent-ink); font-weight: 500; }

.sidebar-footer { border-top: 1px solid var(--border); padding: 10px 12px; flex-shrink: 0; }
.sb-collapse-btn { margin: 0; }
.kbd-hint { margin-left: auto; display: inline-flex; gap: 4px; }
.kbd-hint kbd {
  background: var(--surface);
  color: var(--text-faint);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
  box-shadow: none;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 26, 0.45);
  z-index: 1030;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.sidebar-overlay.is-visible { opacity: 1; visibility: visible; }

/* Sidebar diciutkan (desktop) */
@media (min-width: 992px) {
  .sb-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
  .sb-collapsed .content-wrapper { margin-left: var(--sidebar-w-collapsed); }
  .sb-collapsed .sidebar-brand { padding: 0 20px; }
  .sb-collapsed .brand-text,
  .sb-collapsed .sidebar-link > span,
  .sb-collapsed .sb-chevron,
  .sb-collapsed .sb-sub,
  .sb-collapsed .kbd-hint { display: none !important; }
  .sb-collapsed .sidebar-link { padding: 0; justify-content: center; }
  .sb-collapsed .sidebar-divider { height: 1px; margin: 12px 14px; font-size: 0; background: var(--border); }
  .sb-collapsed .sidebar-link.active::before { left: -12px; }
}

/* --------------------------------------------------------------
   Topbar + strip info
   -------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-toggle { background: none; border: 0; color: var(--text); font-size: 1.5rem; line-height: 1; padding: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.pop-wrap { position: relative; }
.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: 8px;
  color: var(--text-soft); font-size: 18px;
}
.icon-btn:hover { background: var(--surface-2); }
.user-btn {
  display: flex; align-items: center; gap: 9px;
  background: none; border: 0; border-radius: 8px;
  padding: 4px 6px; color: var(--text);
}
.user-btn:hover { background: var(--surface-2); }
.user-btn > i { font-size: 12px; color: var(--text-faint); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 11px; font-weight: 600;
}
.user-name { font-size: 14px; font-weight: 500; }

.pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(16, 16, 40, 0.12);
  padding: 6px;
  display: none;
  z-index: 1050;
}
.pop.show { display: block; }
.pop-title { padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.pop-user .pop-title { text-transform: none; font-size: 13px; color: var(--text); letter-spacing: 0; }
.pop-empty { padding: 6px 10px 12px; color: var(--text-faint); font-size: 13px; }
.pop-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text-soft); font-size: 14px;
}
.pop-item:hover { background: var(--surface-2); color: var(--text); }
.pop-item.text-danger { color: #dc2626 !important; }
.pop-item.text-danger:hover { background: #fef2f2; }

.info-strip {
  display: flex;
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 41px;
  padding: 0 24px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.info-strip::-webkit-scrollbar { display: none; }
.info-item { font-size: 12.5px; color: var(--text-faint); padding-right: 12px; margin-right: 12px; border-right: 1px solid var(--border-strong); line-height: 14px; }
.info-item:last-child { border-right: 0; margin-right: 0; }
.info-item b { color: var(--text); font-size: 13px; font-weight: 600; margin-left: 3px; }

.app-flash { padding: 16px 24px 0; }
.app-flash .alert { margin-bottom: 0; }
.app-main { padding: 24px; flex: 1; width: 100%; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); width: 272px; }
  .sidebar.is-open { transform: translateX(0); box-shadow: 0 0 40px rgba(15, 15, 26, 0.25); }
  .content-wrapper { margin-left: 0; }
  .topbar { padding: 0 14px; }
  .info-strip { padding: 0 14px; }
  .app-flash { padding: 12px 14px 0; }
  .app-main { padding: 16px 14px; }
}

/* --------------------------------------------------------------
   Halaman: judul + dashboard
   -------------------------------------------------------------- */
.page-title { font-size: 20px; font-weight: 600; line-height: 28px; margin: 0 0 26px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0 20px;
  height: 66px;
  min-width: 0;
}
.stat-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-size: 16px; flex-shrink: 0; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.blue   { background: #e0f2fe; color: #0369a1; }
.stat-icon.orange { background: #ffedd5; color: #c2410c; }
.stat-icon.green  { background: #dcfce7; color: #15803d; }
.stat-label { font-size: 14px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value { margin-left: auto; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); white-space: nowrap; }
.stat-value.is-money { font-size: 20px; }

@media (max-width: 1199.98px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px) {
  .stat-grid { gap: 10px; }
  .stat-tile { flex-wrap: wrap; height: auto; padding: 12px 14px; gap: 8px; }
  .stat-label { flex: 1 1 calc(100% - 44px); font-size: 13px; }
  .stat-value { margin-left: 0; font-size: 22px; flex-basis: 100%; }
  .stat-value.is-money { font-size: 18px; }
}

.chart-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 20px;
  margin-bottom: 24px;
}
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.chart-sub { font-size: 13px; color: var(--text-soft); }
.chart-total { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.chart-refresh { width: 32px; height: 32px; display: grid; place-items: center; border: 0; background: none; border-radius: 8px; color: var(--text-faint); font-size: 16px; }
.chart-refresh:hover { background: var(--surface-2); color: var(--text); }
.chart-refresh.is-loading i { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.chart-area { position: relative; width: 100%; height: 290px; touch-action: pan-y; }
.chart-area svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-tip {
  position: absolute; pointer-events: none; display: none;
  background: var(--text); color: #fff; font-size: 12px; line-height: 1.35;
  padding: 6px 9px; border-radius: 7px; white-space: nowrap; z-index: 3;
  transform: translate(-50%, -100%);
}
.chart-tip small { display: block; opacity: 0.7; font-size: 11px; }
@media (max-width: 575.98px) {
  .chart-area { height: 220px; }
  .chart-total { font-size: 24px; }
  .chart-card { padding: 14px 14px 16px; }
}

/* --------------------------------------------------------------
   Kartu & komponen umum
   -------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
}
.card h5 { font-size: 16px; }
.card h5 i { color: var(--accent); margin-right: 4px; }

/* stat-card lama (referral & admin) — versi terang */
.stat-card {
  position: relative;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 14px 20px;
  overflow: hidden;
}
.stat-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.stat-card.bg-2::before { background: #0ea5e9; }
.stat-card.bg-3::before { background: #f97316; }
.stat-card.bg-4::before { background: #22c55e; }
.stat-card .small { color: var(--text-soft); }

/* Tombol */
.btn { font-weight: 500; border-radius: 8px; transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease; }
.btn-primary {
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent-hover);
  --bs-btn-hover-border-color: var(--accent-hover);
  --bs-btn-active-bg: #5b21b6;
  --bs-btn-active-border-color: #5b21b6;
  --bs-btn-disabled-bg: #c4b5fd;
  --bs-btn-disabled-border-color: #c4b5fd;
  --bs-btn-focus-shadow-rgb: 124, 58, 237;
}
.btn-outline-primary {
  --bs-btn-color: var(--accent-ink);
  --bs-btn-border-color: #c4b5fd;
  --bs-btn-hover-bg: var(--accent);
  --bs-btn-hover-border-color: var(--accent);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--accent-hover);
  --bs-btn-active-border-color: var(--accent-hover);
}
.btn-outline-secondary { --bs-btn-color: var(--text-soft); --bs-btn-border-color: var(--border-strong); --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: var(--border-strong); }

/* Form */
.form-control, .form-select {
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
  background-color: var(--surface);
  color: var(--text);
}
.form-control:disabled, .form-select:disabled { background-color: var(--surface-2); color: var(--text-faint); }
.form-label { color: var(--text-soft); font-weight: 500; font-size: 13px; }

/* Tabel */
.table-responsive { border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.table-responsive table { margin-bottom: 0; white-space: nowrap; }
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-border-color: var(--border); font-size: 13.5px; }
.table > :not(caption) > * > * { padding: 0.65rem 0.85rem; }
.table-light, .table-light > * { --bs-table-bg: #f9f9fc; --bs-table-color: var(--text-faint); --bs-table-border-color: var(--border); }
.table-light th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.table-hover > tbody > tr:hover > * { background: #faf8ff; }

.badge { font-weight: 500; letter-spacing: 0.01em; }
.alert { border-radius: 10px; font-size: 14px; }

/* OTP / order card */
.otp-code { font-size: 1.6rem; font-weight: 700; letter-spacing: 3px; color: #16a34a; }
.otp-box { background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 10px; padding: 0.6rem 0.9rem; }
.otp-flash { animation: otpPulse 0.75s ease-out 2; }
@keyframes otpPulse {
  0%   { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.4); background: #dcfce7; }
  100% { box-shadow: 0 0 0 12px rgba(22, 163, 74, 0); background: var(--surface-2); }
}
.action-buttons .btn { flex: 1 1 auto; min-width: 44%; }
@media (min-width: 480px) { .action-buttons .btn { min-width: auto; } }
.copy-btn { cursor: pointer; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--text-faint); margin-top: auto; }

@media (max-width: 575.98px) {
  .btn { min-height: 40px; }
  .otp-code { font-size: 1.3rem; letter-spacing: 2px; }
}

/* --------------------------------------------------------------
   Landing page
   -------------------------------------------------------------- */
.hero-section {
  background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 60%, #8b5cf6 100%);
  border: 0;
  box-shadow: 0 12px 32px rgba(124, 58, 237, 0.25);
}
.hero-section .badge.bg-light { background: rgba(255, 255, 255, 0.18) !important; color: #fff !important; }
.hero-section .btn-light { border: 0; }
.hero-section .btn-outline-light:hover { background: rgba(255, 255, 255, 0.12); }
.hero-phone-mock { width: 220px; height: 400px; background: #0f0a1e; border-radius: 32px; padding: 14px; box-shadow: 0 20px 45px rgba(15, 10, 30, 0.35); }
.hero-phone-screen { background: linear-gradient(160deg, #1e1538, #0f0a1e); height: 100%; border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem; }
.otp-mock { font-size: 2rem; font-weight: 700; letter-spacing: 6px; color: #fff; background: rgba(255, 255, 255, 0.08); border: 1px dashed rgba(255, 255, 255, 0.3); padding: 0.4rem 1rem; border-radius: 10px; }

.stats-strip { display: flex; flex-wrap: wrap; gap: 1.5rem 2.5rem; justify-content: center; padding: 1.1rem 0.5rem; }
.stats-strip .stat-item { text-align: center; min-width: 100px; }
.stats-strip .stat-item .num { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.stats-strip .stat-item .label { font-size: 0.8rem; color: var(--text-faint); }

.usecase-card, .step-card, .feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  height: 100%;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.usecase-card:hover, .step-card:hover, .feature-card:hover { border-color: #c4b5fd; box-shadow: 0 6px 18px rgba(124, 58, 237, 0.08); }
.usecase-card { padding: 1.25rem; text-align: center; }
.step-card { padding: 1.5rem 1.25rem; text-align: center; }
.feature-card { padding: 1.5rem; }
.feature-card p, .step-card p { color: var(--text-faint) !important; }
.step-number { width: 42px; height: 42px; border-radius: 50%; color: #fff; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; margin: 0 auto; }
.section-eyebrow { display: inline-block; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.5rem; }
.cta-section { background: linear-gradient(135deg, #6d28d9 0%, #8b5cf6 100%); box-shadow: 0 12px 32px rgba(124, 58, 237, 0.22); }
.cta-section .btn-light { border: 0; }

@media (max-width: 767.98px) {
  .hero-phone-mock { width: 180px; height: 330px; }
  .otp-mock { font-size: 1.5rem; letter-spacing: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
