/* ═══════════════════════════════════════════════════════════
   DwinPayment v3.0 — main.css
   White-background design · Barlow + Prompt · 3D icons
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,400&family=Prompt:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Background */
  --bg:          #f0f4f8;
  --bg2:         #e8edf3;
  --surface:     #ffffff;
  --surface2:    #f7f9fc;

  /* Cards (dark navy — kept from design reference) */
  --card:        #0d1b2a;
  --card2:       #0f2035;
  --card3:       #162840;
  --card-border: rgba(255,255,255,0.07);

  /* Brand */
  --navy:        #0c2340;
  --teal:        #06b6d4;
  --violet:      #7c3aed;
  --indigo:      #4f46e5;
  --cyan:        #22d3ee;
  --purple:      #a855f7;

  /* Gradients */
  --grad-main:   linear-gradient(135deg,#7c3aed,#06b6d4);
  --grad-gold:   linear-gradient(135deg,#f59e0b,#fbbf24);
  --grad-green:  linear-gradient(135deg,#10b981,#34d399);
  --grad-red:    linear-gradient(135deg,#ef4444,#f87171);
  --grad-card:   linear-gradient(145deg,#0f2035,#0d1b2a);

  /* Status */
  --success:     #10b981;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --info:        #06b6d4;

  /* Text */
  --text:        #0c2340;
  --text2:       #4a6280;
  --muted:       #8ba4bf;
  --text-on-dark:#e2eaf4;
  --muted-dark:  #7a96b4;

  /* Layout */
  --sidebar-w:   240px;
  --header-h:    58px;
  --radius:      14px;
  --radius-sm:   8px;
  --radius-lg:   20px;

  /* Shadows */
  --shadow-sm:   0 2px 8px rgba(12,35,64,0.08);
  --shadow:      0 4px 20px rgba(12,35,64,0.12);
  --shadow-lg:   0 8px 40px rgba(12,35,64,0.18);
  --shadow-card: 0 8px 32px rgba(0,0,0,0.35);

  /* Fonts */
  --font-display: 'Prompt', sans-serif;
  --font-body:    'Barlow', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124,58,237,0.25); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(124,58,237,0.45); }

/* ── Screen Layers (role/auth/2fa/seed/kyc) ────────────────── */
.screen-layer {
  position: fixed; inset: 0;
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 50; overflow-y: auto;
  background: var(--bg);
}
.screen-layer.active { display: flex; }

/* ── App Shell ─────────────────────────────────────────────── */
#app-shell {
  position: fixed; inset: 0;
  z-index: 100; display: none;
  flex-direction: column;
}
#app-shell.active { display: flex; }

/* ── App Header ────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid rgba(12,35,64,0.08);
  display: flex; align-items: center;
  gap: 10px; padding: 0 16px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0; position: relative; z-index: 200;
}

.hamburger-btn {
  width: 36px; height: 36px;
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
  border-radius: var(--radius-sm); padding: 6px;
  transition: background .2s;
}
.hamburger-btn:hover { background: var(--bg2); }
.hamburger-btn span {
  display: block; width: 18px; height: 2px;
  background: var(--navy); border-radius: 2px; transition: .3s;
}

.header-brand { display: flex; align-items: center; gap: 8px; margin-right: 4px; }
.header-logo { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.header-brand-text {
  font-family: var(--font-display);
  font-weight: 700; font-size: 17px; color: var(--navy);
  letter-spacing: .5px;
}

.header-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  padding: 3px 9px; border-radius: 99px;
  font-family: var(--font-mono);
}
.badge-network { background: rgba(6,182,212,.12); color: var(--teal); }
.badge-polygon { background: rgba(130,71,229,.12); color: #8247e5; }
.role-tag { background: rgba(124,58,237,.12); color: var(--violet); }
.role-tag.admin { background: rgba(245,158,11,.12); color: var(--warning); }

.header-security { display: flex; gap: 5px; margin-left: auto; }
.sec-indicator {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px rgba(16,185,129,.6);
  animation: secPulse 2s ease-in-out infinite;
}
.sec-indicator:nth-child(2) { animation-delay: .4s; }
.sec-indicator:nth-child(3) { animation-delay: .8s; }

.header-user {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 6px 10px; border-radius: var(--radius-sm);
  transition: background .2s;
}
.header-user:hover { background: var(--bg2); }
.header-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--grad-main);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
}
.header-user-info { display: flex; flex-direction: column; }

/* ── App Body ──────────────────────────────────────────────── */
.app-body {
  display: flex; flex: 1; overflow: hidden;
  position: relative;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid rgba(12,35,64,0.07);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  flex-shrink: 0;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}

.sidebar-header {
  padding: 16px 14px 10px;
  border-bottom: 1px solid rgba(12,35,64,0.06);
}
.sidebar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg2); border-radius: var(--radius-sm);
  padding: 7px 12px;
}
.sidebar-search input {
  flex: 1; background: none; border: none; outline: none;
  font-family: var(--font-body); font-size: 12px;
  color: var(--text); placeholder-color: var(--muted);
}
.sidebar-search-icon { font-size: 13px; opacity: .5; }

.nav-section { padding: 8px 0; }
.nav-section-title {
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 600;
  letter-spacing: 1.2px; color: var(--muted);
  padding: 6px 16px 4px; text-transform: uppercase;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; cursor: pointer;
  border-radius: 0; transition: all .2s;
  font-size: 13px; font-weight: 500;
  color: var(--text2); position: relative;
  margin: 1px 8px; border-radius: var(--radius-sm);
}
.nav-item:hover {
  background: var(--bg2); color: var(--navy);
}
.nav-item.active {
  background: linear-gradient(135deg,rgba(124,58,237,.12),rgba(6,182,212,.08));
  color: var(--violet);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: var(--grad-main);
  border-radius: 0 3px 3px 0;
}
.nav-icon {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.admin-only { display: none; }
.admin-mode .admin-only { display: flex; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 150;
}

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  background: var(--bg); position: relative;
}

.module-container {
  display: none; padding: 20px;
  min-height: 100%;
  animation: fadeIn .3s ease;
}
.module-container.active { display: block; }

/* ── Bottom Tabs ───────────────────────────────────────────── */
.bottom-tabs {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 56px; background: var(--surface);
  border-top: 1px solid rgba(12,35,64,0.08);
  z-index: 200; box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}
.bottom-tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; background: none; border: none;
  cursor: pointer; font-family: var(--font-body);
  font-size: 10px; color: var(--muted);
  transition: color .2s; padding: 0;
}
.bottom-tab.active { color: var(--violet); }
.tab-icon { font-size: 20px; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.card-light {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid rgba(12,35,64,0.08);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px 12px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--card-border);
}
.card-title {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 600;
  color: var(--text-on-dark);
}
.card-title-light {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 600;
  color: var(--navy);
}
.card-body { padding: 16px 20px; }

/* ── Stat Cards ────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.violet::before { background: linear-gradient(90deg,var(--violet),var(--cyan)); }
.stat-card.teal::before   { background: linear-gradient(90deg,var(--teal),#38bdf8); }
.stat-card.green::before  { background: linear-gradient(90deg,var(--success),#34d399); }
.stat-card.amber::before  { background: linear-gradient(90deg,var(--warning),#fbbf24); }
.stat-card.red::before    { background: linear-gradient(90deg,var(--danger),#f87171); }

.stat-label {
  font-size: 11px; font-weight: 500;
  color: var(--muted-dark); letter-spacing: .5px;
  text-transform: uppercase; margin-bottom: 6px;
  font-family: var(--font-mono);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 700;
  color: var(--text-on-dark); line-height: 1;
}
.stat-sub {
  font-size: 11px; color: var(--muted-dark);
  margin-top: 4px; display: flex; align-items: center; gap: 4px;
}
.stat-change-up   { color: var(--success); font-weight: 600; }
.stat-change-down { color: var(--danger); font-weight: 600; }
.stat-icon-wrap {
  position: absolute; right: 16px; top: 16px;
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; border: none; border-radius: var(--radius-sm);
  cursor: pointer; font-family: var(--font-body);
  font-weight: 600; transition: all .2s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--grad-main); color: #fff;
  padding: 10px 20px; font-size: 13px;
  box-shadow: 0 4px 14px rgba(124,58,237,.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(124,58,237,.45); }
.btn-secondary {
  background: var(--bg2); color: var(--navy);
  padding: 10px 20px; font-size: 13px;
  border: 1px solid rgba(12,35,64,.1);
}
.btn-secondary:hover { background: #dce4ee; }
.btn-ghost {
  background: rgba(255,255,255,.08); color: var(--text-on-dark);
  padding: 8px 16px; font-size: 12px;
  border: 1px solid rgba(255,255,255,.1);
}
.btn-ghost:hover { background: rgba(255,255,255,.14); }
.btn-gold {
  background: var(--grad-gold); color: #fff;
  padding: 10px 20px; font-size: 13px;
  box-shadow: 0 4px 14px rgba(245,158,11,.35);
}
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-full { width: 100%; }
.btn-danger {
  background: var(--grad-red); color: #fff;
  padding: 10px 20px; font-size: 13px;
}

/* ── Badges / Chips ────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: .4px;
  padding: 2px 8px; border-radius: 99px;
  font-family: var(--font-mono); text-transform: uppercase;
}
.badge-green  { background: rgba(16,185,129,.15); color: var(--success); }
.badge-red    { background: rgba(239,68,68,.15); color: var(--danger); }
.badge-amber  { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-violet { background: rgba(124,58,237,.15); color: var(--violet); }
.badge-teal   { background: rgba(6,182,212,.15); color: var(--teal); }
.badge-blue   { background: rgba(79,70,229,.15); color: var(--indigo); }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text2); margin-bottom: 6px;
}
.form-input {
  width: 100%; padding: 10px 14px;
  background: var(--bg2); border: 1.5px solid rgba(12,35,64,.1);
  border-radius: var(--radius-sm); outline: none;
  font-family: var(--font-body); font-size: 13px; color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.form-input:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(124,58,237,.12);
}
.form-input-dark {
  width: 100%; padding: 10px 14px;
  background: rgba(255,255,255,.06); border: 1.5px solid rgba(255,255,255,.1);
  border-radius: var(--radius-sm); outline: none;
  font-family: var(--font-body); font-size: 13px; color: var(--text-on-dark);
  transition: border-color .2s;
}
.form-input-dark:focus { border-color: var(--teal); }
.form-select {
  width: 100%; padding: 10px 14px;
  background: var(--bg2); border: 1.5px solid rgba(12,35,64,.1);
  border-radius: var(--radius-sm); outline: none;
  font-family: var(--font-body); font-size: 13px; color: var(--text);
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%234a6280'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  background-size: 8px; padding-right: 30px;
}

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.dwin-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.dwin-table thead th {
  padding: 10px 14px; text-align: left;
  font-family: var(--font-mono); font-size: 10px;
  font-weight: 600; letter-spacing: .8px;
  text-transform: uppercase; color: var(--muted-dark);
  background: rgba(255,255,255,.04);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.dwin-table tbody td {
  padding: 11px 14px; color: var(--text-on-dark);
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.dwin-table tbody tr:hover { background: rgba(255,255,255,.03); }
.dwin-table tbody tr:last-child td { border-bottom: none; }

/* ── Progress / Charts ─────────────────────────────────────── */
.progress-bar-wrap {
  height: 6px; background: rgba(255,255,255,.08);
  border-radius: 99px; overflow: hidden;
}
.progress-bar {
  height: 100%; background: var(--grad-main);
  border-radius: 99px; transition: width .8s ease;
}

/* ── Toast ─────────────────────────────────────────────────── */
#dwin-toast-wrap {
  position: fixed; bottom: 70px; right: 20px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.dwin-toast {
  background: var(--card2); color: var(--text-on-dark);
  border-radius: var(--radius-sm); padding: 12px 18px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--teal);
  animation: toastIn .3s ease; max-width: 300px;
}
.dwin-toast.error  { border-left-color: var(--danger); }
.dwin-toast.success{ border-left-color: var(--success); }
.dwin-toast.warn   { border-left-color: var(--warning); }

/* ── User Menu Dropdown ────────────────────────────────────── */
#user-menu-dropdown {
  position: fixed; top: 54px; right: 12px;
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid rgba(12,35,64,.1); box-shadow: var(--shadow-lg);
  min-width: 200px; z-index: 1000; padding: 8px 0;
  display: none;
}
#user-menu-dropdown.open { display: block; animation: fadeIn .2s ease; }
.user-menu-item {
  padding: 10px 16px; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  color: var(--text2); transition: background .15s;
}
.user-menu-item:hover { background: var(--bg2); color: var(--navy); }
.user-menu-divider { height: 1px; background: rgba(12,35,64,.07); margin: 6px 0; }

/* ── Module Header ─────────────────────────────────────────── */
.module-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.module-title {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700; color: var(--navy);
}
.module-subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }
.module-actions { display: flex; gap: 8px; }

/* ── Grid Layouts ──────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill,minmax(280px,1fr)); gap: 16px; }
.flex-row { display: flex; gap: 16px; }
.flex-col { display: flex; flex-direction: column; gap: 16px; }

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeIn   { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }
@keyframes slideIn  { from{transform:translateX(-100%)} to{transform:none} }
@keyframes toastIn  { from{opacity:0;transform:translateX(20px)} to{opacity:1;transform:none} }
@keyframes secPulse { 0%,100%{opacity:1} 50%{opacity:.4} }
@keyframes coinFloat{ 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
@keyframes spin     { to{transform:rotate(360deg)} }
@keyframes pulse    { 0%,100%{opacity:1} 50%{opacity:.5} }
@keyframes shimmer  {
  0%{background-position:-200% 0}
  100%{background-position:200% 0}
}

/* ── Skeleton Loader ───────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,rgba(255,255,255,.04) 25%,rgba(255,255,255,.09) 50%,rgba(255,255,255,.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: var(--radius-sm);
}

/* ── Divider ───────────────────────────────────────────────── */
.divider { height: 1px; background: rgba(255,255,255,.06); margin: 16px 0; }
.divider-light { height: 1px; background: rgba(12,35,64,.07); margin: 16px 0; }

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px; text-align: center;
  color: var(--muted-dark);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: .6; }
.empty-state-text { font-size: 14px; font-weight: 500; }
.empty-state-sub  { font-size: 12px; opacity: .7; margin-top: 4px; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    z-index: 160; transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .sidebar-overlay.open { display: block; }
  .bottom-tabs { display: flex; }
  .main-content { padding-bottom: 56px; }
  .module-container { padding: 14px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .module-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .header-brand-text { display: none; }
}

/* ── Tailwind/Bootstrap compatibility ── */
#app-shell .btn, .screen-layer .btn, .auth-form .btn, .twofa-card .btn, .seed-card .btn { font-family: var(--font-body); }
#app-shell input.form-input, .auth-form input.form-input { font-family: var(--font-body); }
