/* =========================================================
   ASNESIA DESIGN SYSTEM
   Dark, developer-facing, "live API" aesthetic.
   Mobile-first & responsive: phones (Android/iOS), tablets, desktop.
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  --bg: #0b1120;
  --bg-glow: radial-gradient(ellipse at 50% 0%, rgba(99, 102, 241, 0.10) 0%, transparent 60%);
  --surface: #0f172a;
  --surface-2: #1e293b;
  --border: rgba(99, 102, 241, 0.12);
  --border-soft: rgba(99, 102, 241, 0.06);

  --primary: #6366f1;
  --primary-600: #4f46e5;
  --primary-light: #818cf8;
  --primary-lighter: #a5b4fc;

  --accent: #f59e0b;
  --accent-600: #d97706;
  --success: #34d399;
  --danger: #ef4444;
  --danger-light: #fca5a5;

  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-faint: #475569;

  --font-display: 'Space Grotesk', 'Inter', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, Consolas, monospace;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;

  --nav-h: 60px;
  --bottom-nav-h: 64px;
  --container-w: 1200px;

  --shadow-glow: 0 8px 32px rgba(99, 102, 241, 0.08);
}

/* ---------- Reset ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  background-image: var(--bg-glow);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.01em; }
table { width: 100%; border-collapse: collapse; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* ---------- Layout shells ---------- */
.page-main {
  max-width: var(--container-w);
  margin: 0 auto;
  padding: 24px 20px calc(var(--bottom-nav-h) + 24px + env(safe-area-inset-bottom, 0px));
  width: 100%;
}
@media (min-width: 900px) {
  .page-main { padding: 32px 24px 56px; }
}

.animate-in { animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.65; } }
.vip-glow { animation: pulse 2.2s infinite; }

/* ---------- Top nav (desktop) ---------- */
.glass { background: rgba(15, 23, 42, 0.88); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-bottom: 1px solid var(--border-soft); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
@media (min-width: 768px) { .topbar { padding: 0 24px; } }

.brand {
  font-size: 17px;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--primary-light);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.topbar-links { display: none; align-items: center; gap: 2px; }
@media (min-width: 900px) { .topbar-links { display: flex; } }

.nav-item {
  color: var(--text-dim);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: rgba(99, 102, 241, 0.08); color: var(--primary-light); }
.nav-item.active { background: rgba(99, 102, 241, 0.14); color: var(--primary-light); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid var(--border-soft);
  text-decoration: none;
  transition: border-color 0.15s ease;
}
.user-chip:hover { border-color: var(--border); }
.user-avatar-sm {
  width: 30px; height: 30px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
}
.user-avatar-sm.placeholder {
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
}
.user-chip-meta { line-height: 1.15; }
.user-chip-name { font-size: 13px; font-weight: 600; }

.icon-btn {
  color: var(--text-faint);
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: rgba(99, 102, 241, 0.08); color: var(--primary-light); }

/* ---------- Bottom nav (mobile / Android app style) ---------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  display: flex;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-soft);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 900px) { .bottom-nav { display: none; } }

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 600;
  min-width: 0;
}
.bottom-nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bottom-nav-item.active { color: var(--primary-light); }
.bottom-nav-item svg { flex-shrink: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border-radius: 10px; font-weight: 600; font-size: 14px;
  border: none; cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  text-decoration: none; line-height: 1.2;
}
.btn:active { transform: scale(0.98); }
.btn-primary, .btn-primary.input-field { background: linear-gradient(135deg, var(--primary), var(--primary-600)); color: #fff; }
.btn-primary:hover { box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35); }
.btn-ghost { background: rgba(99, 102, 241, 0.08); color: var(--primary-light); }
.btn-ghost:hover { background: rgba(99, 102, 241, 0.15); }
.btn-vip { background: linear-gradient(135deg, var(--accent), var(--accent-600)); color: #1e1b4b; }
.btn-vip:hover { box-shadow: 0 8px 24px rgba(245, 158, 11, 0.35); }
.btn-danger { background: linear-gradient(135deg, var(--danger), #dc2626); color: #fff; }
.btn-danger:hover { box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 12.5px; }
.btn-icon-only { padding: 8px; background: none; border: none; cursor: pointer; }

/* ---------- Cards / surfaces ---------- */
.glass-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.6), rgba(30, 41, 59, 0.3));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.15s ease;
}
.glass-card:hover { border-color: var(--border); box-shadow: var(--shadow-glow); }
.card-pad { padding: 20px; }
@media (min-width: 768px) { .card-pad { padding: 24px; } }
.card-pad-lg { padding: 28px; }
@media (min-width: 768px) { .card-pad-lg { padding: 40px; } }

/* ---------- Forms ---------- */
.input-field {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 10px;
  padding: 13px 16px;
  color: var(--text);
  width: 100%;
  font-size: 15px; /* >=16px avoids iOS zoom; kept close for visual match */
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.input-field:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15); }
.input-field::placeholder { color: var(--text-faint); }
.field-label {
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 6px; display: flex; align-items: center; gap: 6px;
}
.field-group { display: flex; flex-direction: column; gap: 16px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .form-grid-2 { grid-template-columns: 1fr; } }

select.input-field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--radius-full); font-size: 11px; font-weight: 700; letter-spacing: 0.02em; }
.badge-vip { background: rgba(245, 158, 11, 0.16); color: var(--accent); }
.badge-free { background: rgba(99, 102, 241, 0.1); color: var(--primary-light); }
.badge-admin { background: rgba(239, 68, 68, 0.14); color: #f87171; }
.badge-active { background: rgba(52, 211, 153, 0.12); color: var(--success); }
.badge-inactive { background: rgba(239, 68, 68, 0.1); color: var(--danger-light); }

/* ---------- Typography helpers ---------- */
.stat-value {
  font-family: var(--font-display);
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.page-title { font-size: clamp(22px, 5vw, 28px); font-weight: 700; }
.page-sub { font-size: 13.5px; color: var(--text-muted); margin-top: 4px; }
.section-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.mono { font-family: var(--font-mono); }
.endpoint-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--primary-light);
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 2px 8px;
  display: inline-block;
}

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 8px; }
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-error { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.2); color: var(--danger-light); }
.alert-success { background: rgba(52, 211, 153, 0.1); border: 1px solid rgba(52, 211, 153, 0.2); color: var(--success); }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { font-size: 13px; }
.data-table th { text-align: left; padding: 10px 8px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.data-table th.center, .data-table td.center { text-align: center; }
.data-table th.right, .data-table td.right { text-align: right; }
.data-table tr { border-bottom: 1px solid var(--border-soft); }
.data-table td { padding: 10px 8px; }

/* ---------- Grids ---------- */
.grid-auto-sm { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.grid-auto-md { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.grid-auto-lg { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.profile-layout { display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: start; }
@media (max-width: 760px) { .profile-layout { grid-template-columns: 1fr; } }

/* ---------- Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
}
.modal-overlay.open { display: flex; }
@media (min-width: 640px) { .modal-overlay { align-items: center; padding: 20px; } }
.modal-box {
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  border-radius: 20px 20px 0 0;
}
@media (min-width: 640px) { .modal-box { padding: 32px; border-radius: var(--radius-lg); } }

/* ---------- Misc ---------- */
.hairline { border: none; border-top: 1px solid var(--border-soft); margin: 24px 0; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.hide-mobile { display: none; }
@media (min-width: 640px) { .hide-mobile { display: initial; } }
.show-mobile { display: initial; }
@media (min-width: 640px) { .show-mobile { display: none; } }

.site-footer { padding-bottom: calc(24px + var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 900px) { .site-footer { padding-bottom: 24px; } }
