/* ===== Reset & Variables ================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #08080e;
  --bg2:         #0f0f1a;
  --bg3:         #141424;
  --surface:     rgba(255,255,255,.04);
  --surface-h:   rgba(255,255,255,.07);
  --border:      rgba(255,255,255,.08);
  --border-h:    rgba(245,197,24,.35);

  --gold:        #F5C518;
  --gold-dim:    #c9a014;
  --gold-glow:   rgba(245,197,24,.18);
  --gold-glow2:  rgba(245,197,24,.06);

  --text:        #e8e8f0;
  --text-dim:    #848499;
  --text-muted:  #4a4a60;

  --success:     #22c55e;
  --error:       #ef4444;
  --info:        #60a5fa;
  --warn:        #f59e0b;

  --radius:      14px;
  --radius-sm:   8px;
  --radius-lg:   20px;

  --transition:  .2s cubic-bezier(.4,0,.2,1);
  --transition-s:.35s cubic-bezier(.4,0,.2,1);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== Scrollbar =========================================================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(245,197,24,.25); border-radius: 99px; }

/* ===== Typography ========================================================== */
h1,h2,h3,h4 { line-height: 1.25; letter-spacing: -.02em; }
p { line-height: 1.65; }

/* ===== Animated Background Blobs ========================================== */
.bg-blobs {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
}
.bg-blobs span {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .35;
  animation: blobFloat 18s ease-in-out infinite;
}
.bg-blobs span:nth-child(1) {
  width: 600px; height: 600px;
  background: radial-gradient(circle, #7c3aed44, transparent 70%);
  top: -200px; left: -150px;
  animation-duration: 20s;
}
.bg-blobs span:nth-child(2) {
  width: 500px; height: 500px;
  background: radial-gradient(circle, var(--gold-glow), transparent 70%);
  top: 30%; right: -180px;
  animation-duration: 15s;
  animation-delay: -6s;
}
.bg-blobs span:nth-child(3) {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #1d4ed844, transparent 70%);
  bottom: -120px; left: 30%;
  animation-duration: 22s;
  animation-delay: -11s;
}
@keyframes blobFloat {
  0%,100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(40px, -30px) scale(1.06); }
  66%      { transform: translate(-25px, 20px) scale(.95); }
}

/* ===== Glass Card ========================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover { border-color: var(--border-h); box-shadow: 0 0 30px var(--gold-glow2); }
.card-body { padding: 24px; }
.card-body-lg { padding: 32px; }

/* ===== Buttons ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none; cursor: pointer;
  font-size: .875rem; font-weight: 600; font-family: inherit;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: rgba(255,255,255,.08); opacity: 0;
  transition: opacity var(--transition);
}
.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(.97); }

.btn-gold {
  background: linear-gradient(135deg, #F5C518, #e0a800);
  color: #0a0805;
  box-shadow: 0 4px 20px rgba(245,197,24,.3);
}
.btn-gold:hover { box-shadow: 0 6px 28px rgba(245,197,24,.45); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-h);
  color: var(--gold);
}
.btn-outline:hover { background: var(--gold-glow2); }

.btn-ghost {
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-h); }

.btn-tg {
  background: #2AABEE;
  color: #fff;
  box-shadow: 0 4px 18px rgba(42,171,238,.3);
}
.btn-tg:hover { box-shadow: 0 6px 26px rgba(42,171,238,.45); }

.btn-lg { padding: 13px 28px; font-size: 1rem; border-radius: var(--radius-sm); }
.btn-full { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }

/* ===== Inputs ============================================================== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .8rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }

.input {
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: .9rem; font-family: inherit; color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input::placeholder { color: var(--text-muted); }
.input:focus { border-color: var(--gold-dim); box-shadow: 0 0 0 3px var(--gold-glow2); }

/* ===== Badge / Chip ======================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px;
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
}
.badge-gold  { background: rgba(245,197,24,.15); color: var(--gold); border: 1px solid rgba(245,197,24,.3); }
.badge-vip   { background: linear-gradient(135deg,rgba(124,58,237,.25),rgba(245,197,24,.15)); color: #c4b5fd; border: 1px solid rgba(167,139,250,.35); }
.badge-free  { background: rgba(255,255,255,.06); color: var(--text-dim); border: 1px solid var(--border); }
.badge-thuong{ background: rgba(96,165,250,.12); color: var(--info); border: 1px solid rgba(96,165,250,.25); }
.badge-admin { background: linear-gradient(135deg,rgba(239,68,68,.2),rgba(245,197,24,.15)); color: #fca5a5; border: 1px solid rgba(239,68,68,.35); }

/* ===== Tabs ================================================================ */
.tabs { display: flex; gap: 4px; background: rgba(255,255,255,.04); border-radius: var(--radius-sm); padding: 4px; }
.tab {
  flex: 1; padding: 8px 14px; border-radius: 6px;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-dim); font-size: .85rem; font-weight: 600; font-family: inherit;
  transition: all var(--transition);
}
.tab.active { background: var(--bg3); color: var(--gold); box-shadow: 0 0 12px var(--gold-glow2); }
.tab:not(.active):hover { color: var(--text); }

/* ===== Toast =============================================================== */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--bg3);
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  font-size: .85rem; font-weight: 500;
  animation: toastIn .3s cubic-bezier(.4,0,.2,1);
  max-width: 340px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast.success { border-color: rgba(34,197,94,.35); color: var(--success); }
.toast.error   { border-color: rgba(239,68,68,.35);  color: var(--error); }
.toast.info    { border-color: rgba(96,165,250,.35); color: var(--info); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Terminal Log ======================================================== */
.terminal {
  background: #060610;
  border: 1px solid rgba(245,197,24,.15);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: .78rem;
  line-height: 1.7;
  color: #a8ff78;
  min-height: 180px;
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.terminal .t-info    { color: #60a5fa; }
.terminal .t-success { color: #86efac; }
.terminal .t-warn    { color: #fbbf24; }
.terminal .t-error   { color: #f87171; }
.terminal .t-dim     { color: #4a4a60; }
.terminal-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.terminal-dot {
  width: 8px; height: 8px; border-radius: 50%;
  animation: termPulse 1.5s ease-in-out infinite;
}
.terminal-dot.running { background: var(--gold); }
.terminal-dot.success { background: var(--success); animation: none; }
.terminal-dot.fail    { background: var(--error);   animation: none; }
@keyframes termPulse {
  0%,100% { opacity: 1; box-shadow: 0 0 0 0 currentColor; }
  50%      { opacity: .6; box-shadow: 0 0 0 4px transparent; }
}

/* ===== Stat Cards ========================================================== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 12px; }
.stat-card {
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.stat-card:hover { border-color: var(--border-h); transform: translateY(-2px); }
.stat-card .stat-label { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; color: var(--gold); }
.stat-card .stat-sub   { font-size: .75rem; color: var(--text-dim); margin-top: 2px; }

/* ===== Progress bar ======================================================== */
.progress-wrap { background: rgba(255,255,255,.06); border-radius: 99px; overflow: hidden; height: 6px; }
.progress-bar  {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  border-radius: 99px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}

/* ===== Table =============================================================== */
.tbl { width: 100%; border-collapse: collapse; font-size: .84rem; }
.tbl th { color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; font-size: .72rem; font-weight: 600; padding: 0 12px 10px; text-align: left; }
.tbl td { padding: 10px 12px; border-top: 1px solid var(--border); color: var(--text-dim); }
.tbl tr:hover td { background: rgba(255,255,255,.03); color: var(--text); }
.tbl .amount { color: var(--success); font-weight: 600; }

/* ===== QR Panel ============================================================ */
.qr-img {
  width: 180px; height: 180px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-h);
  display: block;
  image-rendering: pixelated;
  box-shadow: 0 0 26px var(--gold-glow2);
}

/* ===== Loading spinner ===================================================== */
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(245,197,24,.2);
  border-top-color: var(--gold);
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Fade-in animation =================================================== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp .5s cubic-bezier(.4,0,.2,1) both; }
.fade-up-d1 { animation-delay: .08s; }
.fade-up-d2 { animation-delay: .16s; }
.fade-up-d3 { animation-delay: .24s; }
.fade-up-d4 { animation-delay: .32s; }

/* ===== Gold shine text ===================================================== */
.gold-text {
  background: linear-gradient(135deg, #F5C518 0%, #ffd95a 40%, #c9a014 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gold-border-glow {
  border-color: rgba(245,197,24,.4) !important;
  box-shadow: 0 0 24px var(--gold-glow), inset 0 0 12px var(--gold-glow2);
}

/* ===== Divider ============================================================= */
.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-muted); font-size: .78rem;
}
.divider::before,.divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ===== Utility ============================================================= */
.flex   { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.gap-6  { gap: 24px; }
.grid   { display: grid; }
.mt-1   { margin-top: 4px; }
.mt-2   { margin-top: 8px; }
.mt-3   { margin-top: 12px; }
.mt-4   { margin-top: 16px; }
.mt-6   { margin-top: 24px; }
.mt-8   { margin-top: 32px; }
.mb-4   { margin-bottom: 16px; }
.mb-6   { margin-bottom: 24px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .75rem; }
.text-dim { color: var(--text-dim); }
.text-muted { color: var(--text-muted); }
.text-gold  { color: var(--gold); }
.text-success { color: var(--success); }
.text-error   { color: var(--error); }
.hidden { display: none !important; }
.relative { position: relative; }
.z-content { position: relative; z-index: 1; }

/* ===== Responsive ========================================================== */
@media (max-width: 640px) {
  .card-body, .card-body-lg { padding: 18px; }
  .btn-lg { padding: 12px 20px; font-size: .9rem; }

  /* Better touch targets */
  .btn { min-height: 44px; }
  .input { min-height: 44px; font-size: 16px; } /* 16px prevents iOS zoom */
  .tab  { min-height: 40px; }

  /* Prevent horizontal overflow */
  body { overflow-x: hidden; }
  .card { margin-left: 0; margin-right: 0; }

  /* Tables scroll horizontally */
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl { min-width: 320px; }

  /* Stat grid */
  .stat-grid { gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.15rem; }

  /* Toast */
  .toast { font-size: .82rem; padding: 10px 14px; max-width: calc(100vw - 32px); }
}

@media (max-width: 400px) {
  .input { font-size: 15px; }
  .btn-lg { padding: 11px 16px; font-size: .85rem; }
}
