/* ============================================================
   CASHOUT MERCHANT DASHBOARD — Global Styles
   Matches iOS app design: system colors, SF Pro, 12px radius,
   pill buttons, adaptive dark/light mode.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@700;800&display=swap');

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  /* iOS SF Pro stack */
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--label);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.25s, color 0.25s;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; }

/* ── CSS Variables — DARK MODE (default) ───────────────────── */
:root {
  /* Brand */
  --accent:        #A6EDA7;
  --accent-dark:   #85BE86;
  --accent-muted:  rgba(166,237,167,.15);
  --accent-border: rgba(166,237,167,.30);

  /* Backgrounds — matches iOS dark system colors */
  --bg:         #000000;
  --surface:    #1C1C1E;
  --surface-2:  #2C2C2E;
  --surface-3:  #3A3A3C;

  /* Separators/Borders */
  --border:     rgba(84,84,88,.65);
  --border-2:   rgba(84,84,88,.50);

  /* Labels — matches iOS UIColor.label family */
  --label:      #FFFFFF;
  --label-2:    rgba(235,235,245,.60);   /* ~#8D8D93 */
  --label-3:    rgba(235,235,245,.30);   /* ~#636366 */
  --label-4:    rgba(235,235,245,.18);

  /* System colors (dark) */
  --red:        #FF453A;
  --orange:     #FF9F0A;
  --yellow:     #FFD60A;
  --blue:       #0A84FF;
  --green:      #30D158;

  /* Shadows (subtle in dark mode) */
  --shadow:     0 2px 12px rgba(0,0,0,.5);
  --shadow-sm:  0 1px 4px rgba(0,0,0,.4);

  /* Shape */
  --radius-sm:   8px;
  --radius:      12px;
  --radius-lg:   16px;
  --radius-pill: 100px;

  /* Layout */
  --sidebar-w: 260px;
  --transition: 0.2s ease;

  /* Aliases used by existing HTML (keep these pointing to the vars above) */
  --mint:         var(--accent);
  --mint-dim:     var(--accent-dark);
  --mint-muted:   var(--accent-muted);
  --mint-border:  var(--accent-border);
  --text:         var(--label);
  --text-2:       var(--label-2);
  --text-3:       var(--label-3);
  --radius-lg:    16px;
}

/* ── CSS Variables — LIGHT MODE ─────────────────────────────── */
@media (prefers-color-scheme: light) {
  :root { --is-light: 1; }
}
/* Also applied when the JS toggle sets data-theme="light" on <html> */
[data-theme="light"] {
  --bg:         #F2F2F7;
  --surface:    #FFFFFF;
  --surface-2:  #F2F2F7;
  --surface-3:  #E5E5EA;

  --border:     rgba(60,60,67,.12);
  --border-2:   rgba(60,60,67,.20);

  --label:      #000000;
  --label-2:    rgba(60,60,67,.60);    /* ~#636366 */
  --label-3:    rgba(60,60,67,.30);    /* ~#AEAEB2 */
  --label-4:    rgba(60,60,67,.18);

  --red:        #FF3B30;
  --orange:     #FF9500;
  --yellow:     #FFCC00;
  --blue:       #007AFF;
  --green:      #34C759;

  --shadow:     0 2px 12px rgba(0,0,0,.10);
  --shadow-sm:  0 1px 4px rgba(0,0,0,.08);

  /* In light mode the accent stays green for brand consistency
     but we also expose --label-accent for text that should be black */
  --accent:         #34A535;   /* slightly deeper for contrast on white */
  --accent-dark:    #2A8A2B;
  --accent-muted:   rgba(52,165,53,.10);
  --accent-border:  rgba(52,165,53,.25);

  --mint:         var(--accent);
  --mint-dim:     var(--accent-dark);
  --mint-muted:   var(--accent-muted);
  --mint-border:  var(--accent-border);
  --text:         var(--label);
  --text-2:       var(--label-2);
  --text-3:       var(--label-3);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:         #F2F2F7;
    --surface:    #FFFFFF;
    --surface-2:  #F2F2F7;
    --surface-3:  #E5E5EA;
    --border:     rgba(60,60,67,.12);
    --border-2:   rgba(60,60,67,.20);
    --label:      #000000;
    --label-2:    rgba(60,60,67,.60);
    --label-3:    rgba(60,60,67,.30);
    --label-4:    rgba(60,60,67,.18);
    --red:        #FF3B30;
    --orange:     #FF9500;
    --yellow:     #FFCC00;
    --blue:       #007AFF;
    --green:      #34C759;
    --shadow:     0 2px 12px rgba(0,0,0,.10);
    --shadow-sm:  0 1px 4px rgba(0,0,0,.08);
    --accent:         #34A535;
    --accent-dark:    #2A8A2B;
    --accent-muted:   rgba(52,165,53,.10);
    --accent-border:  rgba(52,165,53,.25);
    --mint:         var(--accent);
    --mint-dim:     var(--accent-dark);
    --mint-muted:   var(--accent-muted);
    --mint-border:  var(--accent-border);
    --text:         var(--label);
    --text-2:       var(--label-2);
    --text-3:       var(--label-3);
  }
}

/* ── Sidebar Layout ─────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 28px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .wordmark {
  font-family: 'Syne', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--label);
}
.sidebar-logo .wordmark span { color: var(--label-3); font-weight: 700; }
.sidebar-logo .tagline {
  font-size: 0.68rem;
  color: var(--label-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 3px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--label-3);
  padding: 14px 20px 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--label-2);
  transition: color var(--transition), background var(--transition);
  border-radius: 0;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
}
.nav-link:hover {
  color: var(--label);
  background: var(--surface-2);
}
.nav-link.active {
  color: var(--accent);
  background: var(--accent-muted);
  font-weight: 600;
}
.nav-link svg { opacity: 0.6; flex-shrink: 0; }
.nav-link.active svg { opacity: 1; color: var(--accent); }

/* Theme toggle button in sidebar */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--label-3);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  margin: 4px 8px 0;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.theme-toggle:hover { color: var(--label-2); background: var(--surface-2); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.sidebar-user { margin-bottom: 12px; }
.sidebar-user #sidebar-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--label);
  display: block;
}
.sidebar-user #sidebar-email {
  font-size: 0.72rem;
  color: var(--label-3);
  display: block;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-signout {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--label-2);
  font-size: 0.82rem;
  font-weight: 500;
  transition: all var(--transition);
}
.btn-signout:hover {
  border-color: var(--red);
  color: var(--red);
  background: rgba(255,59,48,.06);
}

/* ── Main Content ───────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--label);
}
.topbar-sub {
  font-size: 0.78rem;
  color: var(--label-3);
  margin-top: 1px;
}
.topbar-badge {
  font-size: 0.72rem;
  padding: 4px 10px;
  background: var(--accent-muted);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-pill);
  color: var(--accent);
}

.page-content {
  padding: 24px 28px;
  flex: 1;
}

/* ── Cards — matches iOS secondarySystemGroupedBackground ─────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  /* Subtle border only in dark (border already visible in light via shadow) */
  border: 1px solid var(--border);
}
.card-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--label-3);
  margin-bottom: 12px;
}

/* ── Stat Cards ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.stat-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--label-3);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  letter-spacing: -0.03em;
  color: var(--label);
  line-height: 1;
}
.stat-value.mint   { color: var(--accent); }
.stat-value.red    { color: var(--red); }
.stat-value.yellow { color: var(--yellow); }
.stat-delta {
  font-size: 0.72rem;
  color: var(--label-3);
  margin-top: 6px;
}
.stat-delta.up   { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* ── Buttons — matches app: Capsule primary, outlined secondary ─ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  transition: all var(--transition);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #000000;
  border: none;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { filter: brightness(0.94); transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--label-2);
  border: 1px solid var(--border);
}
.btn-secondary:hover { color: var(--label); border-color: var(--border-2); }

.btn-danger {
  background: rgba(255,59,48,.10);
  color: var(--red);
  border: 1px solid rgba(255,59,48,.25);
}
.btn-danger:hover { background: rgba(255,59,48,.18); }

.btn-sm { padding: 6px 14px; font-size: 0.80rem; }

/* ── Form Elements ──────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--label-2);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--label);
  font-size: 0.92rem;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}
.form-input::placeholder { color: var(--label-3); }
select.form-input { cursor: pointer; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--label-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody td {
  padding: 12px 14px;
  color: var(--label-2);
}
tbody td:first-child { color: var(--label); font-weight: 500; }
.mono { font-size: 0.84rem; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.badge-mint   { background: var(--accent-muted); color: var(--accent); border: 1px solid var(--accent-border); }
.badge-yellow { background: rgba(255,204,0,.12); color: var(--yellow); border: 1px solid rgba(255,204,0,.28); }
.badge-red    { background: rgba(255,59,48,.10); color: var(--red);    border: 1px solid rgba(255,59,48,.25); }
.badge-dim    { background: var(--surface-3);    color: var(--label-3); border: 1px solid var(--border); }

/* ── Alert / Toast ──────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: none;
  font-weight: 500;
}
.alert.show      { display: block; }
.alert-error     { background: rgba(255,59,48,.10); border: 1px solid rgba(255,59,48,.25); color: var(--red); }
.alert-success   { background: var(--accent-muted); border: 1px solid var(--accent-border); color: var(--accent); }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--label-3);
}
.empty-state p { font-size: 0.92rem; }

/* ── Grid helpers ───────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 20px; }
.flex   { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8  { gap: 8px; }

/* ── Loading Spinner ────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Divider ────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--label-3); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar { padding: 14px 16px; }
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
