/* =========================================================
   TutorIA SaaS — Portal Cliente
   Modo Light / Dark automático con CSS custom properties
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Tokens — DARK (default) ─────────────────────────────── */
:root {
  --tp-bg:         #070a11;
  --tp-surface:    #0d1120;
  --tp-surface2:   #141928;
  --tp-border:     rgba(255,255,255,.09);
  --tp-border2:    rgba(255,255,255,.04);
  --tp-text:       #e4e8f5;
  --tp-text2:      #bcc3db;
  --tp-muted:      #6b738f;
  --tp-accent:     #7c6bf5;
  --tp-accent2:    #11d9b5;
  --tp-red:        #f04060;
  --tp-orange:     #f5874a;
  --tp-green:      #11c47e;
  --tp-blue:       #4096f5;
  --tp-yellow:     #f5c518;
  --tp-input-bg:   #181e2c;
  --tp-input-text: #e4e8f5;
  --tp-shadow:     0 8px 40px rgba(0,0,0,.55);
  --tp-shadow-sm:  0 2px 12px rgba(0,0,0,.4);
  --tp-card-grad:  linear-gradient(135deg,#1a1040 0%,#0d1a30 100%);
  --tp-code-bg:    #0d1120;
  --tp-code-text:  #11d9b5;
  --tp-sidebar-bg: #0d1120;
  --tp-r:          14px;
  --tp-r-sm:       9px;
  --tp-font:       'Syne', sans-serif;
  --tp-mono:       'JetBrains Mono', monospace;
  --sidebar-w:     240px;
}

/* ── Tokens — LIGHT ──────────────────────────────────────── */
@media (prefers-color-scheme: light) {
  :root {
    --tp-bg:         #f0f2f8;
    --tp-surface:    #ffffff;
    --tp-surface2:   #f5f7fc;
    --tp-border:     rgba(0,0,0,.1);
    --tp-border2:    rgba(0,0,0,.05);
    --tp-text:       #111827;
    --tp-text2:      #374151;
    --tp-muted:      #6b7280;
    --tp-accent:     #5b4de0;
    --tp-accent2:    #0aaa8f;
    --tp-red:        #dc2626;
    --tp-orange:     #ea580c;
    --tp-green:      #16a34a;
    --tp-blue:       #2563eb;
    --tp-yellow:     #ca8a04;
    --tp-input-bg:   #f9fafb;
    --tp-input-text: #111827;
    --tp-shadow:     0 8px 32px rgba(0,0,0,.12);
    --tp-shadow-sm:  0 2px 8px rgba(0,0,0,.08);
    --tp-card-grad:  linear-gradient(135deg,#ede9ff 0%,#e0f2fe 100%);
    --tp-code-bg:    #f1f5f9;
    --tp-code-text:  #0a7a68;
    --tp-sidebar-bg: #ffffff;
  }
}

/* ── Manual override classes (toggled by JS button) ────────── */
#tutoria-portal.tp-light {
  --tp-bg:         #f0f2f8;
  --tp-surface:    #ffffff;
  --tp-surface2:   #f5f7fc;
  --tp-border:     rgba(0,0,0,.1);
  --tp-border2:    rgba(0,0,0,.05);
  --tp-text:       #111827;
  --tp-text2:      #374151;
  --tp-muted:      #6b7280;
  --tp-accent:     #5b4de0;
  --tp-accent2:    #0aaa8f;
  --tp-red:        #dc2626;
  --tp-orange:     #ea580c;
  --tp-green:      #16a34a;
  --tp-blue:       #2563eb;
  --tp-yellow:     #ca8a04;
  --tp-input-bg:   #f9fafb;
  --tp-input-text: #111827;
  --tp-shadow:     0 8px 32px rgba(0,0,0,.12);
  --tp-shadow-sm:  0 2px 8px rgba(0,0,0,.08);
  --tp-card-grad:  linear-gradient(135deg,#ede9ff 0%,#e0f2fe 100%);
  --tp-code-bg:    #f1f5f9;
  --tp-code-text:  #0a7a68;
  --tp-sidebar-bg: #ffffff;
}

#tutoria-portal.tp-dark {
  --tp-bg:         #070a11;
  --tp-surface:    #0d1120;
  --tp-surface2:   #141928;
  --tp-border:     rgba(255,255,255,.09);
  --tp-text:       #e4e8f5;
  --tp-text2:      #bcc3db;
  --tp-muted:      #6b738f;
  --tp-input-bg:   #181e2c;
  --tp-input-text: #e4e8f5;
  --tp-shadow:     0 8px 40px rgba(0,0,0,.55);
  --tp-card-grad:  linear-gradient(135deg,#1a1040 0%,#0d1a30 100%);
  --tp-code-bg:    #0d1120;
  --tp-code-text:  #11d9b5;
  --tp-sidebar-bg: #0d1120;
}

/* ── Base ────────────────────────────────────────────────── */
#tutoria-portal * { box-sizing: border-box; margin: 0; padding: 0; }

#tutoria-portal {
  font-family: var(--tp-font);
  color: var(--tp-text);
  background: var(--tp-bg);
  min-height: 500px;
  transition: background .3s, color .3s;
  position: relative;
}

/* ── Theme toggle button ─────────────────────────────────── */
.tp-theme-toggle {
  position: absolute;
  top: 16px; right: 16px;
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: 100px;
  padding: 6px 14px;
  font-family: var(--tp-font);
  font-size: 12px;
  font-weight: 700;
  color: var(--tp-muted);
  cursor: pointer;
  z-index: 10;
  transition: all .2s;
  display: flex; align-items: center; gap: 6px;
}
.tp-theme-toggle:hover { color: var(--tp-text); border-color: var(--tp-accent); }

/* ── Login ───────────────────────────────────────────────── */
.tp-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 520px;
  padding: 40px 20px;
}
.tp-login__box {
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-r);
  padding: 44px 40px;
  width: 100%; max-width: 460px;
  box-shadow: var(--tp-shadow);
  animation: tp-fadeIn .3s ease;
}
@keyframes tp-fadeIn { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }

.tp-login__logo {
  font-size: 26px; font-weight: 800;
  color: var(--tp-accent);
  margin-bottom: 22px;
  display: flex; align-items: center; gap: 8px;
}
.tp-login__box h2 {
  font-size: 22px; font-weight: 800;
  color: var(--tp-text);
  margin-bottom: 6px;
}
.tp-muted { color: var(--tp-muted); font-size: 13px; }

/* ── Dashboard layout ────────────────────────────────────── */
.tp-dashboard {
  display: flex;
  min-height: 600px;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.tp-sidebar {
  width: var(--sidebar-w);
  background: var(--tp-sidebar-bg);
  border-right: 1px solid var(--tp-border);
  display: flex; flex-direction: column;
  padding: 0 0 16px;
  position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
  flex-shrink: 0;
  box-shadow: 2px 0 12px rgba(0,0,0,.06);
  transition: background .3s;
}
.tp-sidebar__brand {
  font-size: 19px; font-weight: 800;
  color: var(--tp-accent);
  padding: 22px 20px 20px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--tp-border);
  margin-bottom: 12px;
}

/* Nav */
.tp-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; flex: 1; }
.tp-nav__item {
  background: none; border: none;
  text-align: left;
  padding: 10px 14px;
  border-radius: var(--tp-r-sm);
  font-family: var(--tp-font); font-size: 13px; font-weight: 600;
  color: var(--tp-muted);
  cursor: pointer;
  transition: all .15s;
  display: flex; align-items: center; gap: 8px;
}
.tp-nav__item:hover { background: var(--tp-surface2); color: var(--tp-text); }
.tp-nav__item.active {
  background: rgba(91,77,224,.12);
  color: var(--tp-accent);
}

/* Sidebar user + logout */
.tp-sidebar__user {
  padding: 14px 18px;
  border-top: 1px solid var(--tp-border);
  display: flex; align-items: center; gap: 10px;
  margin-top: auto;
}
.tp-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--tp-accent), var(--tp-accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.tp-plan-badge { font-size: 10px; font-weight: 700; letter-spacing: .5px; color: var(--tp-accent2); text-transform: uppercase; }
.tp-mono-sm { font-size: 11px; font-family: var(--tp-mono); color: var(--tp-muted); }

.tp-logout-btn {
  margin: 8px 14px 0;
  background: none;
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-r-sm);
  color: var(--tp-muted);
  font-family: var(--tp-font); font-size: 12px; font-weight: 600;
  padding: 8px;
  cursor: pointer;
  transition: all .15s;
  width: calc(100% - 28px);
}
.tp-logout-btn:hover { color: var(--tp-red); border-color: var(--tp-red); }

/* ── Main content ────────────────────────────────────────── */
.tp-main { flex: 1; padding: 28px; overflow-y: auto; min-width: 0; }

.tp-tab { display: none; animation: tp-fadeIn .2s ease; }
.tp-tab.active { display: block; }

.tp-tab-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.tp-tab-header h2 { font-size: 21px; font-weight: 800; color: var(--tp-text); }

/* ── Alerts ─────────────────────────────────────────────── */
.tp-alert {
  padding: 12px 16px;
  border-radius: var(--tp-r-sm);
  font-size: 13px; font-weight: 600;
  margin-bottom: 14px;
}
.tp-alert--error { background: rgba(220,38,38,.1);  border: 1px solid rgba(220,38,38,.25);  color: var(--tp-red); }
.tp-alert--warn  { background: rgba(234,88,12,.1);  border: 1px solid rgba(234,88,12,.25);  color: var(--tp-orange); }
.tp-alert--ok    { background: rgba(22,163,74,.1);  border: 1px solid rgba(22,163,74,.25);  color: var(--tp-green); }

/* ── Token card ──────────────────────────────────────────── */
.tp-token-card {
  background: var(--tp-card-grad);
  border: 1px solid rgba(91,77,224,.25);
  border-radius: var(--tp-r);
  padding: 28px;
  margin-bottom: 20px;
  position: relative; overflow: hidden;
  box-shadow: var(--tp-shadow-sm);
}
.tp-token-card::before {
  content: '';
  position: absolute; top: -50px; right: -50px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(91,77,224,.15) 0%, transparent 70%);
  pointer-events: none;
}
.tp-token-card__header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 700; color: var(--tp-muted);
  letter-spacing: .6px; text-transform: uppercase; margin-bottom: 14px;
}
.tp-token-card__numbers {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 16px;
}
.tp-num { font-family: var(--tp-mono); font-size: 36px; font-weight: 700; line-height: 1; color: var(--tp-text); }
.tp-num--muted { font-size: 22px; color: var(--tp-muted); }
.tp-sep { color: var(--tp-muted); font-size: 22px; }

.tp-progress-track {
  height: 8px;
  background: var(--tp-border);
  border-radius: 100px; overflow: hidden; margin-bottom: 10px;
}
.tp-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--tp-accent), var(--tp-accent2));
  border-radius: 100px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.tp-progress-fill--warn   { background: linear-gradient(90deg, var(--tp-orange), var(--tp-red)); }
.tp-progress-fill--danger { background: var(--tp-red); }

.tp-token-card__meta {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--tp-muted);
}
.tp-token-card__meta b { color: var(--tp-text2); }

/* ── Info cards grid ─────────────────────────────────────── */
.tp-info-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px; margin-bottom: 20px;
}
.tp-info-card {
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-r);
  padding: 18px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--tp-shadow-sm);
  transition: background .3s;
}
.tp-info-card__icon { font-size: 24px; }
.tp-info-card__val  { font-size: 17px; font-weight: 800; font-family: var(--tp-mono); color: var(--tp-text); }
.tp-info-card__lbl  { font-size: 11px; color: var(--tp-muted); font-weight: 600; margin-top: 3px; }

/* ── Prediction card ─────────────────────────────────────── */
.tp-prediction-card {
  background: rgba(10,170,143,.07);
  border: 1px solid rgba(10,170,143,.2);
  border-radius: var(--tp-r); padding: 16px 20px; margin-bottom: 20px;
}
.tp-prediction-card__title { font-weight: 700; font-size: 13px; margin-bottom: 6px; color: var(--tp-text); }
.tp-prediction-card__body  { font-size: 13px; color: var(--tp-text2); }
.tp-prediction-card__body b { color: var(--tp-accent2); }

/* ── Generic card ────────────────────────────────────────── */
.tp-card {
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-r);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--tp-shadow-sm);
  transition: background .3s;
}
.tp-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 16px; color: var(--tp-text); }

/* ── Status badge ────────────────────────────────────────── */
.tp-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 100px;
  font-size: 11px; font-weight: 700; letter-spacing: .4px;
}
.tp-status--active    { background: rgba(22,163,74,.12);    color: var(--tp-green); }
.tp-status--expired   { background: rgba(234,88,12,.12);    color: var(--tp-orange); }
.tp-status--cancelled { background: rgba(107,114,128,.12);  color: var(--tp-muted); }
.tp-status--blocked   { background: rgba(220,38,38,.12);    color: var(--tp-red); }
.tp-status--expiring  { background: rgba(202,138,4,.12);    color: var(--tp-yellow); }
.tp-status--suspended { background: rgba(202,138,4,.12);    color: var(--tp-yellow); }
.tp-status--active::before {
  content: ''; width: 6px; height: 6px;
  background: var(--tp-green); border-radius: 50%;
  animation: tp-pulse 1.5s ease infinite;
}
@keyframes tp-pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.5;transform:scale(1.35)} }

/* ── Copy / API ──────────────────────────────────────────── */
.tp-copy-group { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }

.tp-input {
  background: var(--tp-input-bg) !important;
  color: var(--tp-input-text) !important;
  border: 1px solid var(--tp-border) !important;
  border-radius: var(--tp-r-sm) !important;
  padding: 10px 14px !important;
  font-family: var(--tp-mono) !important;
  font-size: 13px !important;
  width: 100%;
  outline: none;
  transition: border-color .15s, background .3s;
}
.tp-input:focus { border-color: var(--tp-accent) !important; box-shadow: 0 0 0 3px rgba(91,77,224,.12) !important; }

.tp-copy-btn, .tp-eye-btn {
  background: var(--tp-surface2);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-r-sm);
  padding: 9px 13px; cursor: pointer;
  font-size: 15px; color: var(--tp-muted);
  transition: all .15s; flex-shrink: 0;
}
.tp-copy-btn:hover, .tp-eye-btn:hover { border-color: var(--tp-accent); color: var(--tp-text); }

.tp-code {
  background: var(--tp-code-bg);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-r-sm);
  padding: 16px;
  font-family: var(--tp-mono); font-size: 12px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-all;
  color: var(--tp-code-text);
  margin-bottom: 10px;
}
.tp-help { font-size: 11px; color: var(--tp-muted); margin-top: 6px; line-height: 1.5; }
.tp-help code {
  background: var(--tp-surface2);
  border: 1px solid var(--tp-border);
  border-radius: 4px; padding: 1px 6px;
  font-family: var(--tp-mono); font-size: 11px;
  color: var(--tp-accent2);
}

/* ── Plans grid ──────────────────────────────────────────── */
.tp-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}
.tp-plan-card {
  background: var(--tp-surface);
  border: 2px solid var(--tp-border);
  border-radius: var(--tp-r);
  padding: 24px 20px;
  text-align: center;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.tp-plan-card:hover { border-color: var(--tp-accent); transform: translateY(-3px); box-shadow: var(--tp-shadow); }
.tp-plan-card.current { border-color: var(--tp-accent2); box-shadow: 0 0 28px rgba(10,170,143,.15); }
.tp-plan-card__icon   { font-size: 32px; }
.tp-plan-card h3      { font-size: 17px; font-weight: 800; color: var(--tp-text); }
.tp-plan-card__price  { font-size: 15px; font-weight: 700; color: var(--tp-accent2); }
.tp-plan-card__tokens { font-size: 12px; color: var(--tp-muted); font-family: var(--tp-mono); }
.tp-plan-card__features {
  list-style: none; width: 100%; text-align: left;
  font-size: 12px; color: var(--tp-text2);
  display: flex; flex-direction: column; gap: 5px;
}
.tp-plan-card__features li::before { content: '✓ '; color: var(--tp-green); font-weight: 800; }
.tp-plan-card .current-label {
  font-size: 10px; font-weight: 700; letter-spacing: .6px;
  color: var(--tp-accent2); text-transform: uppercase;
  background: rgba(10,170,143,.1); padding: 3px 10px; border-radius: 100px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.tp-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--tp-r-sm);
  font-family: var(--tp-font); font-size: 13px; font-weight: 700;
  cursor: pointer; border: none; transition: all .15s;
  text-decoration: none; line-height: 1.4;
}
.tp-btn--primary { background: var(--tp-accent); color: #fff; justify-content: center; width: 100%; }
.tp-btn--primary:hover { background: #4a3bc4; color: #fff; }
.tp-btn--full { width: 100%; justify-content: center; }
.tp-btn--upgrade {
  background: rgba(91,77,224,.1); color: var(--tp-accent);
  border: 1px solid rgba(91,77,224,.25); width: 100%; justify-content: center;
}
.tp-btn--upgrade:hover { background: var(--tp-accent); color: #fff; border-color: var(--tp-accent); }

/* ── Tables ─────────────────────────────────────────────── */
.ts-table-wrap { overflow-x: auto; border-radius: var(--tp-r-sm); }
.ts-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ts-table th {
  background: var(--tp-surface2);
  color: var(--tp-muted);
  font-weight: 700; font-size: 10px; letter-spacing: .6px;
  text-transform: uppercase; padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--tp-border);
}
.ts-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--tp-border);
  font-size: 12px; color: var(--tp-text2);
}
.ts-table tr:last-child td { border-bottom: none; }
.ts-table tr:hover td { background: var(--tp-surface2); }
.ts-loading { text-align: center; color: var(--tp-muted); padding: 28px; }

/* ── Form group ──────────────────────────────────────────── */
.tp-form-group { margin-bottom: 18px; }
.tp-form-group label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--tp-muted); margin-bottom: 6px; letter-spacing: .2px;
}

/* ── Scrollbar ──────────────────────────────────────────── */
#tutoria-portal ::-webkit-scrollbar { width: 5px; }
#tutoria-portal ::-webkit-scrollbar-track { background: var(--tp-surface2); }
#tutoria-portal ::-webkit-scrollbar-thumb { background: var(--tp-border); border-radius: 100px; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .tp-dashboard      { flex-direction: column; }
  .tp-sidebar        { width: 100%; height: auto; position: relative; }
  .tp-nav            { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .tp-nav__item      { white-space: nowrap; flex-shrink: 0; }
  .tp-sidebar__user  { display: none; }
  .tp-main           { padding: 16px; }
  .tp-info-grid      { grid-template-columns: 1fr 1fr; }
  .tp-plans-grid     { grid-template-columns: 1fr 1fr; }
  .tp-num            { font-size: 28px; }
}
@media (max-width: 480px) {
  .tp-login__box     { padding: 28px 20px; }
  .tp-info-grid      { grid-template-columns: 1fr; }
  .tp-plans-grid     { grid-template-columns: 1fr; }
  .tp-num            { font-size: 24px; }
}
