/* =====================================================================
   Mobile-first overrides for NxT API Shop
   - Single hamburger drawer for both user & admin nav
   - Removes inline buttons / desktop sidebars
   - Polishes dashboard cards, tables, charts for small screens
   ===================================================================== */

/* ---------- Base / scrolling ---------- */
html, body { -webkit-text-size-adjust: 100%; }
body.no-scroll { overflow: hidden; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(180deg, rgba(12,14,24,0.92), rgba(12,14,24,0.78));
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}
[data-theme="light"] .topbar {
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,0.85));
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto;
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.topbar .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
.topbar .brand-name { font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em; }

/* Hamburger button (the only nav control on every page) */
.hamburger {
  position: relative;
  width: 44px; height: 44px;
  display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
  background: linear-gradient(135deg, rgba(124,92,255,.16), rgba(34,211,238,.10));
  border: 1px solid var(--border, rgba(255,255,255,.12));
  border-radius: 12px;
  cursor: pointer; color: inherit;
}
.hamburger span {
  display: block; width: 20px; height: 2px; border-radius: 2px;
  background: currentColor; transition: transform .25s ease, opacity .2s ease;
}
.hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.hamburger .dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #f43f5e; box-shadow: 0 0 0 2px rgba(12,14,24,.9);
}

/* ---------- Drawer ---------- */
.drawer {
  position: fixed; inset: 0; z-index: 100;
  pointer-events: none;
}
.drawer.open { pointer-events: auto; }
.drawer-scrim {
  position: absolute; inset: 0;
  background: rgba(4,6,12,.55);
  backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .25s ease;
}
.drawer.open .drawer-scrim { opacity: 1; }

.drawer-panel {
  position: absolute; top: 0; right: 0;
  width: min(360px, 92vw); height: 100%;
  background: linear-gradient(180deg, #11142a 0%, #0a0c18 100%);
  border-left: 1px solid var(--border, rgba(255,255,255,.08));
  box-shadow: -20px 0 60px rgba(0,0,0,.45);
  transform: translateX(105%);
  transition: transform .32s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom);
}
[data-theme="light"] .drawer-panel {
  background: linear-gradient(180deg, #ffffff 0%, #f5f6fb 100%);
  color: #0d1020;
}
.drawer.open .drawer-panel { transform: translateX(0); }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,.08));
  position: sticky; top: 0;
  background: inherit;
}
.drawer-close {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--border, rgba(255,255,255,.12));
  background: transparent; color: inherit;
  font-size: 22px; line-height: 1; cursor: pointer;
}

.drawer-user {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center; gap: 12px;
  padding: 14px 16px;
  margin: 12px;
  border: 1px solid var(--border, rgba(255,255,255,.10));
  background: linear-gradient(135deg, rgba(124,92,255,.10), rgba(34,211,238,.06));
  border-radius: 14px;
}
.drawer-user .avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary,#7c5cff), var(--accent,#22d3ee));
  color: white; font-weight: 700;
}
.drawer-user .who .name { font-weight: 600; font-size: .95rem; }
.drawer-user .who .meta { font-size: .75rem; opacity: .65; }
.drawer-user .bal {
  font-weight: 700; font-size: .9rem;
  background: rgba(255,255,255,.06);
  padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--border, rgba(255,255,255,.10));
}

.drawer-section-title {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted, #98a2b8);
  padding: 14px 20px 6px;
  font-weight: 700;
}
.drawer-section-title.admin-title {
  color: var(--accent, #22d3ee);
  border-top: 1px dashed var(--border, rgba(255,255,255,.08));
  margin-top: 6px;
}
.drawer-subtitle {
  font-size: .72rem; font-weight: 600;
  color: var(--muted, #98a2b8);
  padding: 10px 20px 4px;
  opacity: .85;
}

.drawer-list { list-style: none; margin: 0; padding: 0 8px; }
.drawer-list li { margin: 0; }
.drawer-list a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  color: inherit; text-decoration: none;
  font-size: .94rem; font-weight: 500;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.drawer-list a:hover { background: rgba(255,255,255,.04); }
.drawer-list a.active {
  background: linear-gradient(135deg, rgba(124,92,255,.18), rgba(34,211,238,.10));
  color: #fff;
}
[data-theme="light"] .drawer-list a.active { color: #1a1d3a; }
.drawer-list a .badge {
  margin-left: auto;
  background: #f43f5e; color: #fff; font-size: .7rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; font-style: normal;
}
.drawer-list a .bullet {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted, #98a2b8); flex: 0 0 6px;
  margin-left: 4px;
}
.drawer-list a.active .bullet { background: var(--accent, #22d3ee); }

.drawer-foot {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--border, rgba(255,255,255,.08));
  display: grid; gap: 8px;
}
.drawer-foot .row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(255,255,255,.10));
  background: rgba(255,255,255,.03);
  color: inherit; text-decoration: none;
  font-weight: 600; font-size: .9rem;
  cursor: pointer; width: 100%;
}
.drawer-foot .row.danger {
  color: #f43f5e;
  border-color: rgba(244,63,94,.30);
  background: rgba(244,63,94,.08);
}

/* ---------- Layout ---------- */
.layout, .layout-single {
  display: block;
  grid-template-columns: 1fr;
  gap: 0;
}
.layout > aside.sidebar { display: none !important; }

/* Hide any leftover desktop nav rendered in legacy pages */
.nav, .nav-links, .nav-actions, .menu-btn, .icon-btn { display: none !important; }
.topbar .brand,
.drawer .brand,
.footer .brand { display: inline-flex !important; }

/* Hide leftover legacy admin-drawer button & drawer (we replaced it) */
#admin-menu-btn, #admin-drawer { display: none !important; }

/* ---------- Container ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
main { padding-bottom: 28px; }

/* ---------- Cards / Stats ---------- */
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 540px) { .grid-4 { gap: 14px; } }
@media (min-width: 760px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

.stat {
  position: relative;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border, rgba(255,255,255,.08));
  background:
    radial-gradient(120% 80% at var(--mx,50%) var(--my,0%), rgba(124,92,255,.10), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
  overflow: hidden;
}
.stat .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted,#98a2b8); font-weight: 700; }
.stat .value { font-size: 1.4rem; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.stat .delta { font-size: .72rem; color: var(--muted,#98a2b8); margin-top: 4px; }

.card {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border, rgba(255,255,255,.08));
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
}
.card h3 { font-size: 1.05rem; letter-spacing: -.01em; }
.card-sub { font-size: .8rem; color: var(--muted,#98a2b8); }

.chart-box { position: relative; height: clamp(180px, 50vw, 280px); }

/* ---------- Tables on mobile ---------- */
.table-wrap { overflow-x: auto; border-radius: 12px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tbl th, table.tbl td { text-align: left; padding: 10px 12px; }
table.tbl thead th {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted,#98a2b8); border-bottom: 1px solid var(--border, rgba(255,255,255,.08));
}
table.tbl tbody tr { border-bottom: 1px solid var(--border, rgba(255,255,255,.05)); }

@media (max-width: 700px) {
  table.tbl thead { display: none; }
  table.tbl, table.tbl tbody, table.tbl tr, table.tbl td { display: block; width: 100%; }
  table.tbl tr {
    border: 1px solid var(--border, rgba(255,255,255,.08));
    border-radius: 14px; padding: 6px 4px; margin-bottom: 10px;
    background: rgba(255,255,255,.02);
  }
  table.tbl td {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px dashed var(--border, rgba(255,255,255,.06));
  }
  table.tbl td:last-child { border-bottom: none; }
  table.tbl td::before {
    content: attr(data-label);
    font-size: .7rem; text-transform: uppercase; letter-spacing: .5px;
    color: var(--muted,#98a2b8); font-weight: 700;
    margin-right: 12px; flex: 0 0 auto;
  }
}

/* ---------- Footer ---------- */
.footer {
  margin-top: 32px;
  border-top: 1px solid var(--border, rgba(255,255,255,.08));
  padding: 24px 0 32px;
  font-size: .9rem;
}
.footer-grid {
  display: grid; gap: 22px;
  grid-template-columns: 1fr;
}
@media (min-width: 700px) { .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; } }
.footer h4 { margin: 0 0 10px; font-size: .85rem; letter-spacing: .3px; }
.footer a { display: block; margin: 6px 0; color: var(--muted,#98a2b8); text-decoration: none; }
.footer a:hover { color: inherit; }
.footer-desc { margin: 0; max-width: 380px; line-height: 1.6; color: var(--muted,#98a2b8); }
.footer-bottom {
  border-top: 1px solid var(--border, rgba(255,255,255,.08));
  margin-top: 22px; padding-top: 16px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  color: var(--muted,#98a2b8); font-size: .82rem;
}

/* ---------- Auth screens ---------- */
.auth-wrap {
  min-height: calc(100vh - 70px);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}
.auth-card {
  width: 100%; max-width: 420px;
  position: relative; overflow: hidden;
  padding: 24px;
  border-radius: 20px;
}

/* ---------- Headings ---------- */
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }

/* ---------- Reveal anim ---------- */
.reveal { opacity: 0; transform: translateY(8px); transition: opacity .5s ease, transform .5s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Wider screens: keep mobile feel ---------- */
@media (min-width: 900px) {
  .topbar-inner { padding: 14px 24px; }
  .container { padding: 0 24px; }
}
