/* =============================================================
   WowCodes Portal — portal.css
   Design tokens mirror shared.css (wowcodes.in)
   ============================================================= */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg: #0d0d0d;
  --bg2: #141414;
  --bg3: #1a1a1a;
  --bg4: #222;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.13);
  --amber: #f0a500;
  --amber-bg: rgba(240,165,0,0.08);
  --amber-bg2: rgba(240,165,0,0.15);
  --teal: #1abc8a;
  --teal-bg: rgba(26,188,138,0.08);
  --text: #f0ede6;
  --text2: #9a9690;
  --text3: #5c5a56;
  --r: 6px;
  --rl: 12px;
}

/* ── Reset / Base ──────────────────────────────────────────── */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: var(--bg2);
}
::-webkit-scrollbar-thumb {
  background: var(--bg4);
  border-radius: 2px;
}

/* =============================================================
   LAYOUT
   ============================================================= */

.portal-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top Bar — a floating rounded pill, same recipe as wowcodes.in's
   own nav.topnav (shared.css), just narrower content. ─────────── */
.portal-topbar {
  position: sticky;
  top: 14px;
  z-index: 100;
  height: 58px;
  margin: 0 20px;
  background: rgba(20,20,20,0.82);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 0.5px solid var(--border2);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.28);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px 0 26px;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-logo {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 18px;
  letter-spacing: 0.01em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
  white-space: nowrap;
}
.topbar-logo img {
  height: 22px;
  width: auto;
  display: block;
  flex-shrink: 0;
}
.brand-tld {
  color: var(--amber);
}

.topbar-badge {
  font-family: 'DM Sans', sans-serif;
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
  background: var(--amber-bg2);
  padding: 3px 9px;
  border-radius: 999px;
  line-height: 1.5;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text2);
}

.topbar-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--amber-bg2);
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
  font-family: 'DM Sans', sans-serif;
  flex-shrink: 0;
}

.topbar-user a {
  color: var(--text3);
  transition: color 0.15s;
  font-size: 12px;
}
.topbar-user a:hover {
  color: var(--text2);
}

/* Mobile menu button — hidden by default, animates to a close (X) via
   aria-expanded, mirroring the hamburger on wowcodes.in's main nav. */
.mobile-menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 36px;
  height: 36px;
  gap: 5px;
  padding: 0;
  background: var(--bg3);
  border: 0.5px solid var(--border2);
  border-radius: var(--r);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.mobile-menu-btn:hover {
  background: var(--bg4);
}
.mobile-menu-btn span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--text2);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s, width 0.2s;
}
.mobile-menu-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.mobile-menu-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; width: 0; }
.mobile-menu-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* ── Body / Sidebar / Main ─────────────────────────────────── */
.portal-body {
  display: flex;
  flex-direction: row;
  height: calc(100vh - 72px);
}

.portal-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg2);
  border-inline-end: 0.5px solid var(--border);
  overflow-y: auto;
  padding: 16px 0;
}

.portal-main {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  background: var(--bg);
}

.sidebar-scrim {
  display: none;
}

/* =============================================================
   SIDEBAR NAV
   ============================================================= */

.sidebar-nav {
  list-style: none;
  padding: 0 12px;
  margin: 0;
}

.sidebar-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text3);
  padding: 16px 8px 6px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
}
.sidebar-section-label:first-child {
  padding-top: 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin: 1px 0;
  border-radius: var(--r);
  font-size: 13px;
  color: var(--text2);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.sidebar-link:hover {
  color: var(--text);
  background: var(--bg3);
}
.sidebar-link.active {
  color: var(--amber);
  background: var(--amber-bg);
  font-weight: 500;
}
.sidebar-link:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: -2px;
}

/* =============================================================
   SIDEBAR — mobile-only head/footer (drawer chrome)
   Hidden on desktop, where the sidebar is always-on and needs
   neither a logo/close row nor a duplicate account footer.
   ============================================================= */

.sidebar-mobile-head,
.sidebar-mobile-footer {
  display: none;
}

.sidebar-mobile-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
}
.sidebar-mobile-logo img {
  height: 20px;
  width: auto;
  display: block;
}

.sidebar-close-btn {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--bg3);
  border: 0.5px solid var(--border2);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.sidebar-close-btn:hover {
  color: var(--text);
  background: var(--bg4);
}

.sidebar-mobile-footer-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text2);
  overflow-wrap: anywhere;
}

.sidebar-mobile-footer-logout {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text3);
  transition: color 0.15s;
}
.sidebar-mobile-footer-logout:hover {
  color: var(--amber);
}

/* =============================================================
   PILLS NAV — horizontal scrollable quick links, mobile only
   ============================================================= */

.portal-pillsnav {
  display: none;
}

.pillsnav-scroll {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.pillsnav-scroll::-webkit-scrollbar {
  display: none;
}

.pill-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text2);
  background: var(--bg3);
  border: 0.5px solid var(--border2);
  white-space: nowrap;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.pill-link.active {
  color: #000;
  background: var(--amber);
  border-color: var(--amber);
  font-weight: 600;
}

/* =============================================================
   BOTTOM NAV — fixed tab bar, mobile only
   ============================================================= */

.portal-bottomnav {
  display: none;
}

.bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  border: none;
  background: none;
  color: var(--text3);
  font-size: 10px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  border-radius: var(--r);
  transition: color 0.15s;
}
.bn-item svg {
  width: 19px;
  height: 19px;
}
.bn-item.active,
.bn-item[aria-expanded="true"] {
  color: var(--amber);
}
.bn-item:active {
  transform: scale(0.95);
}

/* =============================================================
   PAGE HEADER
   ============================================================= */

.page-header {
  margin-bottom: 28px;
}

.page-title {
  font-family: 'Fraunces', serif;
  font-size: 24px;
  color: var(--text);
  margin: 0;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text2);
  margin-top: 4px;
  margin-bottom: 0;
}

/* =============================================================
   SECTION TITLE
   ============================================================= */

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text3);
  margin-bottom: 12px;
  margin-top: 0;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
}

/* =============================================================
   CARDS
   ============================================================= */

.portal-card {
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: var(--rl);
  padding: 24px;
}

/* Stat Cards */
.stat-card {
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: var(--rl);
  padding: 24px;
}

.stat-value {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-top: 4px;
}

/* =============================================================
   GRIDS
   ============================================================= */

.portal-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.portal-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.portal-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* =============================================================
   TABLES
   ============================================================= */

.portal-table {
  width: 100%;
  border-collapse: collapse;
}

.portal-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  padding: 10px 16px;
  text-align: start;
  border-bottom: 0.5px solid var(--border);
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
}

.portal-table td {
  padding: 12px 16px;
  color: var(--text2);
  font-size: 13px;
  border-bottom: 0.5px solid var(--border);
}

.portal-table tr:hover td {
  background: var(--bg3);
}

/* =============================================================
   FORMS
   ============================================================= */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg3);
  border: 0.5px solid var(--border2);
  border-radius: var(--r);
  padding: 10px 14px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--amber);
  outline: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text3);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-hint {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
}

/* =============================================================
   BUTTONS
   ============================================================= */

.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  border: none;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}

.btn-primary {
  background: var(--amber);
  color: #000;
  border: none;
}
.btn-primary:hover {
  opacity: 0.88;
}

.btn-secondary {
  background: transparent;
  color: var(--text2);
  border: 0.5px solid var(--border2);
}
.btn-secondary:hover {
  background: var(--bg3);
  color: var(--text);
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  border: none;
}
.btn-danger:hover {
  opacity: 0.85;
}

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

/* =============================================================
   BADGES
   ============================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.badge-green {
  background: rgba(26,188,138,0.12);
  color: var(--teal);
}

.badge-amber {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge-red {
  background: rgba(220,38,38,0.12);
  color: #f87171;
}

.badge-gray {
  background: var(--bg4);
  color: var(--text3);
}

/* =============================================================
   ALERTS
   ============================================================= */

.alert {
  padding: 12px 16px;
  border-radius: var(--r);
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.alert-success {
  background: rgba(26,188,138,0.08);
  border: 0.5px solid rgba(26,188,138,0.2);
  color: var(--teal);
}

.alert-error {
  background: rgba(220,38,38,0.08);
  border: 0.5px solid rgba(220,38,38,0.2);
  color: #f87171;
}

.alert-info {
  background: var(--amber-bg);
  border: 0.5px solid rgba(240,165,0,0.2);
  color: var(--amber);
}

/* =============================================================
   WALLET CARDS
   ============================================================= */

.wallet-card {
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: var(--rl);
  padding: 24px;
  border-top: 2px solid var(--border);
}

.wallet-bonus {
  border-top-color: var(--amber);
}

.wallet-earned {
  border-top-color: var(--teal);
}

.wallet-amount {
  font-family: 'Fraunces', serif;
  font-size: 32px;
  color: var(--text);
  line-height: 1.1;
}

.wallet-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-top: 4px;
}

.wallet-note {
  font-size: 11px;
  color: var(--text3);
  margin-top: 6px;
}

/* =============================================================
   EMPTY STATE
   ============================================================= */

.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.empty-title {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  color: var(--text);
  margin: 0;
}

.empty-text {
  font-size: 13px;
  color: var(--text2);
  margin-top: 6px;
  margin-bottom: 0;
}

/* =============================================================
   COPY FIELD
   ============================================================= */

.copy-field {
  display: flex;
  flex-direction: row;
  background: var(--bg3);
  border: 0.5px solid var(--border2);
  border-radius: var(--r);
  overflow: hidden;
}

.copy-field input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 14px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  outline: none;
  min-width: 0;
}

.copy-field button {
  background: var(--bg4);
  border: none;
  border-inline-start: 0.5px solid var(--border);
  color: var(--text2);
  padding: 10px 14px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  font-family: 'DM Sans', sans-serif;
  transition: color 0.15s;
}
.copy-field button:hover {
  color: var(--amber);
}

/* =============================================================
   TOAST
   ============================================================= */

#toast {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  background: var(--bg4);
  border: 0.5px solid var(--border2);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--rl);
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  max-width: 320px;
  line-height: 1.4;
}

#toast.toast-visible {
  opacity: 1;
}

#toast.toast-success {
  border-color: rgba(26,188,138,0.3);
  color: var(--teal);
}

#toast.toast-error {
  border-color: rgba(220,38,38,0.3);
  color: #f87171;
}

/* =============================================================
   UTILITY CLASSES
   ============================================================= */

.text-amber  { color: var(--amber); }
.text-teal   { color: var(--teal); }
.text-muted  { color: var(--text2); }
.text-dim    { color: var(--text3); }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }

.flex {
  display: flex;
  align-items: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gap-8  { gap: 8px; }
.gap-16 { gap: 16px; }

/* =============================================================
   RESPONSIVE — Mobile (≤ 768px)
   ============================================================= */

@media (max-width: 768px) {
  /* Show mobile menu button */
  .mobile-menu-btn {
    display: flex;
  }

  /* Shrink the floating pill a little, same as nav.topnav does at this
     width — and drop the context badge, there's no room to spare. */
  .portal-topbar {
    top: 10px;
    margin: 0 14px;
    height: 56px;
    padding: 0 16px 0 18px;
  }
  .topbar-badge {
    display: none;
  }

  /* Declutter the top bar — name/logout move into the drawer footer,
     the avatar alone is enough of an identity cue up here. */
  .topbar-username,
  .topbar-logout {
    display: none;
  }

  /* Stack body vertically */
  .portal-body {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 66px);
  }

  /* Sidebar becomes a floating rounded drawer, matching the off-canvas
     panel style used by wowcodes.in's own mobile nav (nav.php). */
  .portal-sidebar {
    width: min(300px, 84vw);
    position: fixed;
    top: 12px;
    inset-inline-start: 12px;
    bottom: 12px;
    z-index: 95;
    background: var(--bg2);
    border: 0.5px solid var(--border2);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    transform: translateX(calc(-100% - 24px));
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
  }

  .portal-sidebar.sidebar-open {
    transform: translateX(0);
  }

  .sidebar-mobile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 0.5px solid var(--border);
    flex-shrink: 0;
  }

  .sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px;
  }

  .sidebar-mobile-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    border-top: 0.5px solid var(--border);
    flex-shrink: 0;
  }

  /* Dimmed, blurred backdrop behind the open drawer — the drawer now
     floats above the whole viewport, not just below the top bar. */
  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .portal-sidebar.sidebar-open + .sidebar-scrim {
    opacity: 1;
    pointer-events: all;
  }

  /* Quick-jump pills, sticky right under the top bar */
  .portal-pillsnav {
    display: block;
    position: sticky;
    top: 66px;
    z-index: 80;
    background: rgba(13,13,13,0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 0.5px solid var(--border);
  }

  /* Fixed tab bar along the bottom */
  .portal-bottomnav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 100;
    background: rgba(13,13,13,0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 0.5px solid rgba(240,165,0,0.25);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }

  /* Main area takes full width, leaves room for the bottom nav */
  .portal-main {
    padding: 16px 16px calc(78px + env(safe-area-inset-bottom));
    min-height: calc(100vh - 66px);
  }

  /* Collapse grids to single column */
  .portal-grid-2,
  .portal-grid-3,
  .portal-grid-4 {
    grid-template-columns: 1fr;
  }
}

/* Gateway-selection tabs (checkout.php, credits-checkout.php) */
.gw-tab {
    transition: border 0.15s, background 0.15s, color 0.15s;
    border: 1px solid var(--border2);
    background: transparent;
    color: var(--text2);
}
.gw-tab.active {
    border-color: var(--amber);
    background: var(--amber-bg);
    color: var(--amber);
}