/* ============================================================
   PromoNet — base.css
   Variables, tipografía y componentes compartidos.
   NO modificar para cambios de una sola vista.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,300&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg:           #0a0c10;
  --bg2:          #111318;
  --bg3:          #1a1d24;
  --border:       #1f2330;
  --border2:      #2a2f3d;
  --text:         #e8eaf0;
  --text2:        #8b909e;
  --text3:        #555a6a;
  --accent:       #00d4aa;
  --accent2:      #00b08a;
  --accent-glow:  rgba(0,212,170,0.12);
  --gold:         #f5b731;
  --gold-bg:      rgba(245,183,49,0.10);
  --red:          #f05252;
  --red-bg:       rgba(240,82,82,0.10);
  --blue:         #5b8af5;
  --blue-bg:      rgba(91,138,245,0.10);
  --r:            10px;
  --r2:           6px;
  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --sidebar-w:    220px;
  --topbar-h:     56px;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
input, select, textarea { font-family: var(--font-body); }

/* ── Typography ─────────────────────────────────────────── */
h1 { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
h2 { font-family: var(--font-display); font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-family: var(--font-display); font-size: 14px; font-weight: 700; }

/* ── App Shell ──────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: none;
  z-index: 100;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo .wordmark {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.sidebar-logo .wordmark span { color: var(--accent); }
.sidebar-logo .role-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(0,212,170,0.25);
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 6px;
}

.sidebar-user {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-user .user-name { font-size: 13px; font-weight: 600; }
.sidebar-user .user-code { font-size: 11px; color: var(--text3); margin-top: 2px; }

.nav-section {
  padding: 14px 20px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text2);
  border-left: 2px solid transparent;
  transition: all .15s;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.025); }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-glow); }
.nav-item .nav-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* ── Main content ───────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 32px;
  min-height: 100vh;
}

/* ── Page header ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-header-left {}
.page-subtitle { color: var(--text2); font-size: 13px; margin-top: 4px; }
.page-header-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ── Section divider ────────────────────────────────────── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 18px;
  color: var(--text3);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}
.section-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
}
.card-sm { padding: 14px 16px; }
.card-dashed {
  background: none;
  border: 1px dashed var(--border2);
  border-radius: var(--r);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .2s;
}
.card-dashed:hover { border-color: var(--accent); }

/* ── Stats grid ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.stat-card.green::before  { background: var(--accent); }
.stat-card.gold::before   { background: var(--gold); }
.stat-card.blue::before   { background: var(--blue); }
.stat-card.red::before    { background: var(--red); }
.stat-icon   { font-size: 20px; margin-bottom: 10px; }
.stat-val    { font-family: var(--font-display); font-size: 26px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.stat-label  { color: var(--text2); font-size: 12px; margin-top: 4px; }
.stat-change { font-size: 11px; margin-top: 6px; color: var(--accent); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--r2);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
  line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #000; }
.btn-primary:hover:not(:disabled) { background: var(--accent2); }
.btn-outline  { background: none; border: 1px solid var(--border2); color: var(--text2); }
.btn-outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-ghost    { background: none; border: none; color: var(--text2); padding: 6px 10px; }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: rgba(255,255,255,0.05); }
.btn-danger   { background: var(--red-bg); border: 1px solid rgba(240,82,82,0.3); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: rgba(240,82,82,0.18); }
.btn-wa       { background: #1b8a4e; color: #fff; }
.btn-wa:hover:not(:disabled) { background: #176e3f; }
.btn-sm       { padding: 6px 12px; font-size: 12px; }
.btn-lg       { padding: 13px 28px; font-size: 15px; }
.btn-block    { width: 100%; }
.btn-loading  { opacity: 0.7; pointer-events: none; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group    { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.form-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--r2);
  color: var(--text);
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 13.5px;
  transition: border-color .15s;
  outline: none;
  line-height: 1.4;
}
.form-input:focus   { border-color: var(--accent); }
.form-input::placeholder { color: var(--text3); }
.form-input:disabled { opacity: 0.5; cursor: not-allowed; }
select.form-input   { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--text3); margin-top: 5px; }
.form-error { font-size: 11px; color: var(--red); margin-top: 5px; }

.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── Table ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); }
table       { width: 100%; border-collapse: collapse; }
thead tr    { border-bottom: 1px solid var(--border); }
th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
  background: var(--bg2);
  white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.015); }
.td-muted { color: var(--text2); font-size: 12px; margin-top: 2px; }

/* ── Chips / Badges ─────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.chip-green { background: rgba(0,212,170,0.12); color: var(--accent); }
.chip-gold  { background: var(--gold-bg);        color: var(--gold); }
.chip-red   { background: var(--red-bg);         color: var(--red); }
.chip-blue  { background: var(--blue-bg);        color: var(--blue); }
.chip-gray  { background: rgba(255,255,255,0.06); color: var(--text2); }

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
  display: flex;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--r2);
  font-size: 13px;
  border: 1px solid;
  line-height: 1.5;
}
.alert-icon { flex-shrink: 0; font-size: 16px; }
.alert-warn    { background: rgba(245,183,49,0.07); border-color: rgba(245,183,49,0.22); color: var(--gold); }
.alert-info    { background: rgba(91,138,245,0.07); border-color: rgba(91,138,245,0.22); color: var(--blue); }
.alert-success { background: rgba(0,212,170,0.07); border-color: rgba(0,212,170,0.22); color: var(--accent); }
.alert-danger  { background: var(--red-bg);          border-color: rgba(240,82,82,0.22); color: var(--red); }

/* ── Modals ─────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(4px);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { transform: translateY(14px); opacity: 0; } }
.modal-sm  { max-width: 400px; }
.modal-lg  { max-width: 680px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 { font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Search box ─────────────────────────────────────────── */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--r2);
  padding: 7px 13px;
}
.search-box:focus-within { border-color: var(--accent); }
.search-box input {
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  width: 200px;
}
.search-box input::placeholder { color: var(--text3); }

/* ── Tier bar ───────────────────────────────────────────── */
.tier-bar { background: var(--bg3); border-radius: 20px; height: 6px; overflow: hidden; }
.tier-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 20px; transition: width .5s ease; }

/* ── Plan cards (selector) ──────────────────────────────── */
.plan-card {
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}
.plan-card:hover    { border-color: rgba(0,212,170,0.4); }
.plan-card.selected { border-color: var(--accent); background: var(--accent-glow); }
.plan-card .plan-name     { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.plan-card .plan-price    { font-family: var(--font-display); font-size: 22px; font-weight: 800; color: var(--accent); }
.plan-card .plan-original { font-size: 12px; color: var(--text3); text-decoration: line-through; }
.plan-card .plan-duration { font-size: 12px; color: var(--text2); margin-top: 4px; }
.plan-card .plan-cost     { font-size: 11px; color: var(--text2); margin-top: 6px; }
.plan-best {
  position: absolute;
  top: -10px; right: 10px;
  background: var(--gold);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
  letter-spacing: 0.05em;
}

/* ── Key display ────────────────────────────────────────── */
.key-display {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--r2);
  padding: 16px 20px;
  text-align: center;
}
.key-display .key-code {
  font-family: 'Courier New', monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent);
}
.key-display .key-meta { font-size: 12px; color: var(--text2); margin-top: 6px; }

/* ── WhatsApp message preview ───────────────────────────── */
.msg-preview {
  background: #075e54;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  color: #fff;
}
.msg-preview-label {
  font-size: 10px;
  color: var(--text3);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* ── 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(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r2);
  padding: 12px 18px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  animation: toastIn .25s ease;
  pointer-events: all;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--accent); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.warn    { border-left: 3px solid var(--gold); }
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } }

/* ── Loading spinner ────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,12,16,0.7);
  backdrop-filter: blur(2px);
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
}
.loading-overlay.active { display: flex; }

/* ── Utility classes ────────────────────────────────────── */
.flex            { display: flex; }
.flex-col        { flex-direction: column; }
.items-center    { align-items: center; }
.items-start     { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.flex-1          { flex: 1; }
.flex-wrap       { flex-wrap: wrap; }
.gap-4  { gap: 4px; }  .gap-6  { gap: 6px; }  .gap-8  { gap: 8px; }
.gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.gap-20 { gap: 20px; } .gap-24 { gap: 24px; }
.mt-4  { margin-top: 4px; }   .mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }  .mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }  .mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.text-sm    { font-size: 12px; }
.text-xs    { font-size: 11px; }
.text-muted { color: var(--text2); }
.text-dim   { color: var(--text3); }
.text-accent{ color: var(--accent); }
.text-gold  { color: var(--gold); }
.text-red   { color: var(--red); }
.font-mono  { font-family: 'Courier New', monospace; }
.font-bold  { font-weight: 600; }
.text-center{ text-align: center; }
.text-right { text-align: right; }
.w-full     { width: 100%; }
.hidden     { display: none !important; }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Hamburger button ───────────────────────────────────── */
.hamburger {
  display: none;
  position: fixed;
  top: 14px; left: 16px;
  z-index: 200;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r2);
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  cursor: pointer; flex-direction: column; gap: 5px;
  padding: 0;
}
.hamburger span {
  display: block; width: 18px; height: 2px;
  background: var(--text2); border-radius: 2px;
  transition: all .25s;
}
.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ── Tarjetas móvil (portal promotor) ──────────────────── */
.mobile-card-list { display: none; }

@media (max-width: 768px) {
  /* Sidebar */
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 150;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }
  .sidebar.open { transform: translateX(0); }

  /* Hamburger visible */
  .hamburger { display: flex; }

  /* Main */
  .main-content { margin-left: 0; padding: 64px 16px 20px; }

  /* Forms */
  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Grids */
  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  /* Typography */
  h1 { font-size: 19px; }

  /* Tablas admin: scroll horizontal */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap table { min-width: 600px; }

  /* Portal promotor: ocultar tabla, mostrar tarjetas */
  .mobile-hide-table { display: none !important; }
  .mobile-card-list  { display: flex; flex-direction: column; gap: 10px; }

  /* Page header en móvil */
  .page-header { flex-wrap: wrap; gap: 12px; }
  .page-header-actions { flex-wrap: wrap; }

  /* Modal */
  .modal { padding: 20px 16px; }
  .modal-lg { max-width: 100%; }
}
