/* ─── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f1117;
  --bg2:      #1a1d27;
  --bg3:      #232735;
  --border:   #2e3347;
  --text:     #e2e4ef;
  --text2:    #8b90a7;
  --accent:   #5c6ef8;
  --accent2:  #7c8bff;
  --green:    #22c55e;
  --red:      #ef4444;
  --yellow:   #f59e0b;
  --radius:   10px;
  --shadow:   0 4px 24px rgba(0,0,0,.4);
}

html { font-size: 16px; line-height: 1.6; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout Helpers ───────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.flex      { display: flex; }
.gap-2     { gap: 8px; }
.gap-3     { gap: 12px; }
.gap-4     { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mt-8  { margin-top: 32px; }
.text-sm   { font-size: .875rem; }
.text-muted { color: var(--text2); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-yellow { color: var(--yellow); }

/* ─── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card-sm { padding: 16px; }

/* ─── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-size: .9rem; font-weight: 500;
  border: none; cursor: pointer; transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover  { opacity: .88; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.btn-primary   { background: var(--accent);  color: #fff; }
.btn-secondary { background: var(--bg3);     color: var(--text); border: 1px solid var(--border); }
.btn-danger    { background: var(--red);     color: #fff; }
.btn-success   { background: var(--green);   color: #fff; }
.btn-sm        { padding: 6px 12px; font-size: .8rem; }

/* ─── Form Controls ────────────────────────────────────────────── */
.form-group       { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: .85rem; color: var(--text2); font-weight: 500; }
input, select, textarea {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; font-size: .9rem; width: 100%;
  outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="file"] { padding: 8px; }
textarea { resize: vertical; min-height: 80px; }

/* ─── Nav ──────────────────────────────────────────────────────── */
.nav {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 12px 0; position: sticky; top: 0; z-index: 100;
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.nav-brand { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.nav-brand span { color: var(--accent2); }
.nav-links { display: flex; gap: 16px; align-items: center; }

/* ─── Table ────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; color: var(--text2); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

/* ─── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 600; letter-spacing: .02em;
}
.badge-pending  { background: #f59e0b22; color: var(--yellow); }
.badge-approved { background: #22c55e22; color: var(--green); }
.badge-rejected { background: #ef444422; color: var(--red); }
.badge-free     { background: #5c6ef822; color: var(--accent2); }
.badge-balance  { background: #22c55e22; color: var(--green); }
.badge-admin    { background: #ef444422; color: var(--red); }
.badge-user     { background: #5c6ef822; color: var(--accent2); }
.badge-banned   { background: #ef444422; color: var(--red); }

/* ─── Alert / Toast ─────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: 8px; font-size: .875rem;
  margin-bottom: 16px; border: 1px solid transparent;
}
.alert-error   { background: #ef444418; border-color: #ef444440; color: #fca5a5; }
.alert-success { background: #22c55e18; border-color: #22c55e40; color: #86efac; }
.alert-info    { background: #5c6ef818; border-color: #5c6ef840; color: #a5b4fc; }

#toast-container {
  position: fixed; bottom: 80px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  padding: 12px 20px; border-radius: 8px; color: #fff; font-size: .875rem;
  max-width: 320px; box-shadow: var(--shadow); animation: fadeInUp .2s ease;
}
.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }
.toast-info    { background: var(--accent); }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 500; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; max-width: 480px; width: 90%;
  box-shadow: var(--shadow);
}
.modal h3 { margin-bottom: 16px; font-size: 1.1rem; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ─── Auth Pages ────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 20px;
}
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-card .subtitle { color: var(--text2); margin-bottom: 24px; font-size: .9rem; }

/* ─── Dashboard ─────────────────────────────────────────────────── */
.dash-header {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 12px 0; margin-bottom: 24px;
}
.dash-header-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.dash-stats { display: flex; gap: 20px; font-size: .85rem; color: var(--text2); }
.dash-stats strong { color: var(--text); }

.page-title { font-size: 1.3rem; font-weight: 600; margin-bottom: 20px; }

/* Message body viewer */
.msg-body {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 16px; margin-top: 12px;
  max-height: 400px; overflow-y: auto; font-size: .875rem;
  line-height: 1.7; white-space: pre-wrap; word-break: break-word;
}
.msg-html { white-space: normal; }

/* Inbox row expand */
.msg-row { cursor: pointer; }
.msg-row:hover td { background: var(--bg3); }
.msg-detail { display: none; background: var(--bg2); }
.msg-detail.open { display: table-row; }
.msg-detail td { padding: 0 12px 12px; }

/* ─── Landing ───────────────────────────────────────────────────── */
.hero {
  text-align: center; padding: 80px 20px 60px;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 800; margin-bottom: 16px; }
.hero h1 span { color: var(--accent2); }
.hero p  { font-size: 1.1rem; color: var(--text2); max-width: 500px; margin: 0 auto 32px; }
.hero-btns { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; padding: 40px 0; }
.feature-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.feature-card h3 { margin-bottom: 8px; }
.feature-card p  { color: var(--text2); font-size: .9rem; }
.feature-icon { font-size: 1.8rem; margin-bottom: 12px; }

/* ─── Admin ─────────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--bg2); border-right: 1px solid var(--border);
  padding: 20px 0; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand { font-size: 1rem; font-weight: 700; padding: 0 20px 20px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.sidebar-brand span { color: var(--red); font-size: .7rem; vertical-align: super; }
.sidebar a { display: block; padding: 10px 20px; color: var(--text2); font-size: .875rem; }
.sidebar a:hover, .sidebar a.active { background: var(--bg3); color: var(--text); text-decoration: none; }
.admin-main { flex: 1; padding: 28px; overflow-x: hidden; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card .stat-val { font-size: 2rem; font-weight: 700; }
.stat-card .stat-lbl { color: var(--text2); font-size: .8rem; margin-top: 4px; }

/* ─── WhatsApp widget ───────────────────────────────────────────── */
#wa-widget {
  position: fixed; bottom: 20px; right: 20px; z-index: 1000;
}
#wa-btn {
  width: 56px; height: 56px; border-radius: 50%;
  background: #25D366; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(37,211,102,.4);
  transition: transform .2s, box-shadow .2s;
}
#wa-btn:hover { transform: scale(1.1); box-shadow: 0 6px 28px rgba(37,211,102,.5); }
#wa-dismiss {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg3); border: 1px solid var(--border);
  cursor: pointer; font-size: .7rem; display: flex;
  align-items: center; justify-content: center; color: var(--text2);
}
#wa-dismiss:hover { color: var(--text); }

/* ─── Responsive ────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .sidebar { display: none; }
  .nav-links .text-sm { display: none; }
  .dash-stats { flex-wrap: wrap; gap: 8px; }
  .hero-btns { flex-direction: column; align-items: center; }
}
