/* =========================================
   MarkBase Bonus Admin — Global Styles
   ========================================= */

:root {
  --bg-base:       #060d1f;
  --bg-card:       #0d1a2e;
  --bg-card2:      #111e33;
  --bg-hover:      #162040;
  --bg-input:      #0b1528;
  --border:        #1e2d4a;
  --border-active: #7c3aed;
  --text-primary:  #e2e8f0;
  --text-muted:    #7b8eab;
  --text-faint:    #3d5275;
  --accent:        #7c3aed;
  --accent-hover:  #6d28d9;
  --accent-soft:   rgba(124,58,237,.18);
  --green:         #10b981;
  --green-soft:    rgba(16,185,129,.15);
  --blue:          #3b82f6;
  --blue-soft:     rgba(59,130,246,.15);
  --gold:          #f59e0b;
  --gold-soft:     rgba(245,158,11,.15);
  --red:           #ef4444;
  --red-soft:      rgba(239,68,68,.15);

  --header-h:      56px;
  --sidebar-w:     240px;
  --sidebar-coll:  60px;
  --radius:        10px;
  --radius-lg:     14px;
  --transition:    .17s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ======= AUTH SCREEN ======= */
#auth-screen {
  position: fixed; inset: 0;
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #12063a 0%, #060d1f 70%);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 380px;
  text-align: center;
  box-shadow: 0 32px 80px rgba(0,0,0,.5);
}

.auth-logo {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 0 32px rgba(124,58,237,.4);
}

.auth-card h2 {
  font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 10px;
}

.auth-card p {
  color: var(--text-muted); font-size: 13px; margin-bottom: 28px; line-height: 1.5;
}

.btn-auth {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  text-decoration: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600; font-size: 14px;
  box-shadow: 0 4px 16px rgba(124,58,237,.4);
  transition: var(--transition);
}

.btn-auth:hover { background: linear-gradient(135deg, #6d28d9, #4338ca); }

/* ======= ADMIN BANNER ======= */
#admin-banner {
  display: none;
  background: linear-gradient(90deg, #7c3aed, #4f46e5);
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  color: rgba(255,255,255,.85);
  padding: 5px 0;
}

/* ======= HEADER ======= */
#app-header {
  position: sticky; top: 0; z-index: 200;
  height: var(--header-h);
  background: rgba(6,13,31,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 24px;
}

.header-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
  font-size: 16px; font-weight: 700; color: var(--text-primary);
  letter-spacing: -.02em;
}

.header-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  box-shadow: 0 0 10px rgba(124,58,237,.6);
}

.header-nav {
  display: flex; gap: 4px; flex: 1;
}

.header-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
  transition: var(--transition);
}

.header-nav a:hover { color: var(--text-primary); background: var(--bg-hover); }

.header-account { position: relative; }

.account-trigger {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  color: var(--text-primary);
  transition: var(--transition);
}

.account-trigger:hover { border-color: var(--border-active); background: var(--bg-hover); }

.trigger-avatar, .avatar-lg {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.avatar-lg { width: 38px; height: 38px; font-size: 14px; }

.trigger-info { text-align: left; min-width: 0; }

.trigger-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.trigger-email { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }

.account-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none;
  transform: translateY(-6px);
  transition: var(--transition);
  z-index: 400;
}

.account-dropdown.open { opacity: 1; pointer-events: auto; transform: translateY(0); }

.dropdown-section {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.dropdown-section:last-child { border-bottom: none; }

.dropdown-user {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 6px;
}

.dropdown-user-info { min-width: 0; }
.dropdown-user-info .name { font-size: 13px; font-weight: 600; }
.dropdown-user-info .email { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.dropdown-menu { list-style: none; }

.dropdown-menu li a,
.dropdown-menu li button {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 13px;
  background: none;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.dropdown-menu li a:hover,
.dropdown-menu li button:hover { background: var(--bg-hover); }

.dropdown-menu li button.danger { color: var(--red); }

.badge-external {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-faint);
  background: var(--border);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ======= APP LAYOUT ======= */
#app-layout {
  display: flex;
  height: calc(100vh - var(--header-h));
}

.layout-inner {
  display: flex;
  width: 100%;
  overflow: hidden;
}

/* ======= SIDEBAR ======= */
#app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 8px;
}

#app-sidebar::-webkit-scrollbar { width: 4px; }
#app-sidebar::-webkit-scrollbar-track { background: transparent; }
#app-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-section { margin-bottom: 8px; }

.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-faint);
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}

.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item svg { flex-shrink: 0; }

/* ======= MAIN ======= */
#app-main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 32px 64px;
}

#app-main::-webkit-scrollbar { width: 6px; }
#app-main::-webkit-scrollbar-track { background: transparent; }
#app-main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.page { display: none; }
.page.active { display: block; }

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.02em;
  margin-bottom: 6px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ======= BONUS HERO ======= */
.bonus-hero {
  background: linear-gradient(135deg, #3b1d8a 0%, #1e1060 50%, #0d1a2e 100%);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.bonus-hero::before {
  content: '★';
  position: absolute;
  right: 24px; top: 12px;
  font-size: 96px;
  opacity: .06;
  color: #fff;
  line-height: 1;
}

.bonus-hero-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(167,139,250,.7);
  margin-bottom: 8px;
}

.bonus-hero-balance {
  font-size: 40px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.03em;
  margin-bottom: 24px;
  text-shadow: 0 0 40px rgba(124,58,237,.5);
}

.bonus-hero-stats {
  display: flex; gap: 32px;
}

.bonus-hero-stat .label {
  font-size: 11px;
  color: rgba(255,255,255,.45);
  margin-bottom: 4px;
}

.bonus-hero-stat .value {
  font-size: 16px;
  font-weight: 700;
  color: rgba(255,255,255,.85);
}

/* ======= STATS GRID ======= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}

.stat-card:hover { border-color: var(--text-faint); }

.stat-label { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }

.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: 4px;
}

.stat-value.purple { color: var(--accent); }
.stat-value.blue   { color: var(--blue); }
.stat-value.green  { color: var(--green); }
.stat-value.gold   { color: var(--gold); }

.stat-hint { font-size: 11px; color: var(--text-faint); }

/* ======= CARD ======= */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* ======= TABLE ======= */
.table-wrap { overflow-x: auto; }

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

th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
}

/* ======= FORM ======= */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none;
}

.form-input:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-input::placeholder { color: var(--text-faint); }

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237b8eab' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

.form-select option { background: #0d1a2e; }

.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ======= BUTTONS ======= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  box-shadow: 0 2px 12px rgba(124,58,237,.3);
}

.btn-primary:hover { background: linear-gradient(135deg, #6d28d9, #4338ca); }

.btn-secondary {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover { background: var(--bg-hover); border-color: var(--text-faint); }

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

.btn-danger {
  background: var(--red-soft);
  border: 1px solid var(--red);
  color: var(--red);
}

.btn-danger:hover { background: var(--red); color: #fff; }

/* ======= BADGES ======= */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-active   { background: var(--green-soft);  color: var(--green); }
.badge-inactive { background: var(--bg-hover);     color: var(--text-muted); }
.badge-purple   { background: var(--accent-soft);  color: var(--accent); }
.badge-gold     { background: var(--gold-soft);    color: var(--gold); }

/* ======= PROGRAMS / CAMPAIGNS LIST ======= */
.entity-list { display: flex; flex-direction: column; gap: 8px; }

.entity-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  transition: var(--transition);
}

.entity-item:hover { border-color: var(--text-faint); }

.entity-info { flex: 1; min-width: 0; }

.entity-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.entity-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.entity-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ======= LOADING ======= */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-muted);
  font-size: 13px;
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ======= TOAST ======= */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 14px 18px;
  color: var(--text-primary);
  font-size: 13px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(10px);
  animation: toast-in .2s ease forwards;
  max-width: 320px;
}

.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--gold); }

.toast.hide { animation: toast-out .2s ease forwards; }

@keyframes toast-in  { to { opacity:1; transform:translateY(0); } }
@keyframes toast-out { to { opacity:0; transform:translateY(6px); } }

/* ======= CATALOG OVERLAY ======= */
.catalog-overlay {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(6,13,31,.7);
  display: flex; align-items: center; justify-content: center;
}

.catalog-selection-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 420px;
  max-height: 70vh;
  overflow-y: auto;
}

.catalog-selection-panel h4 {
  font-size: 16px; font-weight: 700; margin-bottom: 16px;
}

/* ======= SCROLLBAR (Webkit) ======= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
}

/* ======= RESPONSIVE ======= */
@media (max-width: 768px) {
  .mobile-menu-btn { display: block; }
  .header-nav { display: none; }
  #app-sidebar {
    position: fixed;
    top: var(--header-h);
    left: -100%;
    width: 260px;
    height: calc(100vh - var(--header-h));
    z-index: 999;
    transition: left 0.3s ease;
    box-shadow: 0 16px 48px rgba(0,0,0,.5);
    background: var(--bg-card);
  }
  #app-sidebar.open {
    left: 0;
  }
  .sidebar-label, .nav-item span { display: inline; }
  .nav-item { justify-content: flex-start; }
  .trigger-info { display: none; }
  #app-main { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .bonus-hero-stats { flex-wrap: wrap; gap: 16px; }
}
