/* ─── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:           #0a0a0a;
  --bg-card:      #111111;
  --bg-elevated:  #161616;
  --bg-input:     #0f0f0f;
  --border:       #1e1e1e;
  --border-hover: #2e2e2e;
  --text:         #ebebeb;
  --text-muted:   #888888;
  --text-dim:     #555555;
  --primary:      #C4512A;
  --primary-dark: #a8441f;
  --primary-glow: rgba(196,81,42,0.15);
  /* Terracota fijo del logo de marca — a diferencia de --primary, las páginas de
     detalle con tema propio (taller/consultoría/oportunidad) lo sobreescriben vía
     applyTema() para adaptar botones/acentos al color del contenido; --brand-accent
     nunca se toca, así "SOBERANOS" en el topbar/cabecera siempre es el mismo terracota
     de marca, tenga o no tema aplicado la página. */
  --brand-accent: #C4512A;
  --danger:       #ef4444;
  --danger-bg:    rgba(239,68,68,0.1);
  --success:      #22c55e;
  --success-bg:   rgba(34,197,94,0.1);
  --warning:      #f59e0b;
  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 4px 16px rgba(0,0,0,0.5);
  --transition:   0.18s ease;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  height: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ─────────────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100%;
}

.sidebar {
  width: 240px;
  height: 100%;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .brand-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--primary);
  line-height: 1.2;
}

.sidebar-brand .brand-sub {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  margin-top: 2px;
}

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

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  line-height: 1;
  transition: color var(--transition), background var(--transition);
  border-left: none;
}

.nav-link:hover { color: var(--text); background: var(--bg-elevated); text-decoration: none; }
.nav-link.active {
  color: var(--primary);
  border-left: 2px solid var(--primary);
  background: var(--primary-glow);
}
.nav-section-label {
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--primary);
  padding: 16px 20px 6px 22px;
  user-select: none;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-user {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-legal {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 20px 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.sidebar-legal a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.sidebar-legal a:hover {
  color: var(--primary);
}
.sidebar-legal span {
  opacity: 0.4;
}

.public-footer {
  text-align: center;
  padding: 24px 0 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  gap: 12px;
  align-items: center;
}
.public-footer a {
  color: var(--text-muted);
  text-decoration: none;
}
.public-footer a:hover {
  color: var(--primary);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

.main-header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

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

.main-content {
  flex: 1;
  padding: 32px;
}

/* ─── Topbar del portal de cliente ──────────────────────────────────────────────
   Barra superior de portal/index.html (logo + saldo + persona). Se comparte con
   js/portal-close-btn.js, que reutiliza .topbar/.topbar-brand tal cual en las 6
   páginas de detalle (perfil/afiliación/taller/consultoría/instancia/oportunidad),
   sin el saldo ni el botón de persona — mismo marcado/estilo, no una versión
   propia. */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}
/* font-family fija (no font-family:inherit): en taller.html/consultoria.html
   applyTema() sobreescribe body{font-family} con la tipografía de cuerpo del
   tema de contenido (p.ej. 'Inter' por defecto) — sin esta declaración propia
   el logo heredaría esa fuente y divergiría de index.html en letter-spacing/
   tamaño real, aunque el color ya esté fijado con --brand-accent. */
.topbar-brand {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.topbar-spacer { flex: 1; }

/* ─── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

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

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

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

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

.stat-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-value.accent { color: var(--primary); }

/* Content grid for portal */
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color var(--transition), transform var(--transition);
  cursor: pointer;
}

.content-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.content-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.badge-icon-img { width: 13px; height: 13px; object-fit: contain; flex-shrink: 0; border-radius: 2px; }

.badge-taller      { background: rgba(196,81,42,0.15);  color: var(--primary); }
.badge-recurso     { background: rgba(34,197,94,0.1);   color: var(--success); }
.badge-membresia   { background: rgba(245,158,11,0.1);  color: var(--warning); }
.badge-consultoria { background: rgba(59,130,246,0.12); color: #3b82f6; border: 1px solid rgba(59,130,246,0.25); }

/* ─── Combobox reutilizable (js/combobox.js) ──────────────────────────────────
   Desplegable oscuro con todas las opciones + buscador integrado para listas largas.
   Sustituye visualmente a un <select> ya existente (Combobox.enhance). */
.cb-wrap { position: relative; }
.cb-native-hidden { display: none !important; }

.cb-trigger {
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cb-trigger.cb-disabled { opacity: 0.5; cursor: not-allowed; }
.cb-trigger-open { border-color: var(--primary); }

/* position:fixed + left/top/width calculados en JS (positionPanel en combobox.js) — el
   panel cuelga de <body>, no de .cb-wrap, para escapar de cualquier ancestro con
   overflow:hidden/auto (p.ej. el .modal con scroll de admin/contenidos.html). */
.cb-panel {
  display: none;
  position: fixed;
  z-index: 2000;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  overflow: hidden;
}
.cb-panel.open { display: block; }

.cb-search-wrap { padding: 8px; border-bottom: 1px solid var(--border); }
.cb-search {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 7px 10px;
  outline: none;
}
.cb-search:focus { border-color: var(--primary); }

.cb-list { max-height: 220px; overflow-y: auto; }
.cb-option {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; font-size: 13px; cursor: pointer;
}
.cb-option:hover, .cb-option.cb-active { background: var(--bg-hover, rgba(255,255,255,0.04)); }
.cb-option.cb-selected { color: var(--text); }
.cb-option-disabled { color: var(--text-dim); cursor: not-allowed; }
.cb-check { color: var(--primary); font-weight: 700; flex-shrink: 0; }
.cb-empty { padding: 10px 12px; font-size: 13px; color: var(--text-muted); }

/* ─── Widget "Contenidos sugeridos" (js/contenido-sugerencias.js) ────────────── */
.sug-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

/* ─── Widget "Contenidos sugeridos" del portal (js/contenido-sugerencias-portal.js) ──
   Formato tarjeta: toda la tarjeta navega a la página del contenido (su "landing" en
   sentido amplio, vía rutaContenido()) — sin botón de compra directa. ── */
.sug-portal-heading {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-dim);
  padding: 10px 16px 6px;
}
.sug-portal-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; cursor: pointer; transition: background 0.15s;
}
.sug-portal-item:hover { background: var(--bg-elevated); }
.sug-portal-img {
  width: 44px; height: 44px; border-radius: 6px; object-fit: cover;
  flex-shrink: 0; background: var(--bg-elevated);
}
.sug-portal-img-placeholder { background: var(--border); }
.sug-portal-tipo-icon { width: 18px; height: 18px; object-fit: contain; flex-shrink: 0; }
.sug-portal-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sug-portal-title {
  color: var(--text); line-height: 1.35; font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sug-portal-price { font-size: 12px; color: var(--text-muted); }
.sug-portal-owned { font-size: 11px; font-weight: 600; color: #4ade80; }

/* ─── Modal de compra genérico del portal (usado por el widget de sugeridos y por
   portal/index.html; portal/taller.html y portal/oportunidad.html lo comparten vía el widget) ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  width: 100%; max-width: 440px; padding: 32px;
  transform: translateY(12px); transition: transform 0.2s;
}
.modal-backdrop.open .modal-box { transform: translateY(0); }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal-close-btn { background: none; border: none; cursor: pointer; color: var(--text-dim); padding: 0; font-size: 20px; line-height: 1; }

.content-card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.content-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text); }

.btn-danger  { background: var(--danger-bg); color: var(--danger); border-color: rgba(239,68,68,0.2); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-full { width: 100%; }

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
  appearance: none;
}

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

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

/* ─── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

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

tbody td {
  padding: 12px 16px;
  color: var(--text);
  vertical-align: middle;
}

td.muted { color: var(--text-muted); }

/* ─── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-admin    { background: var(--primary-glow); color: var(--primary); }
.badge-cliente  { background: rgba(34,197,94,0.1); color: var(--success); }
.badge-recurso  { background: rgba(34,197,94,0.1); color: var(--success); }
.badge-taller-t { background: var(--primary-glow); color: var(--primary); }
.badge-membresia-t { background: rgba(245,158,11,0.1); color: var(--warning); }
.badge-oportunidad-t { background: rgba(139,92,246,0.12); color: #8b5cf6; }
.badge-oportunidad   { background: rgba(139,92,246,0.12); color: #8b5cf6; border: 1px solid rgba(139,92,246,0.25); }

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  transform: translateY(8px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

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

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  transition: color var(--transition), background var(--transition);
}

.modal-close:hover { color: var(--text); background: var(--bg-input); }

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ─── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

.alert.show { display: block; }
.alert-error   { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(34,197,94,0.2); }

/* ─── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-dim);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.empty-state-text {
  font-size: 13px;
}

/* ─── File Uploader ──────────────────────────────────────────────────────────── */
.fu-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  cursor: default;
}
.fu-dropzone.drag-over {
  border-color: var(--primary);
  background: var(--bg-elevated);
}
.fu-progress-bar-track {
  background: var(--bg-elevated);
  border-radius: 4px;
  height: 4px;
  overflow: hidden;
}
.fu-progress-bar-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.1s linear;
}
.fu-usage {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.fu-usage-bar-track {
  background: var(--bg-elevated);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin: 4px 0;
}

/* ─── Utility ────────────────────────────────────────────────────────────────── */
.flex       { display: flex; }
.flex-gap   { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 13px; }
.hidden     { display: none !important; }

/* ─── Spinner ────────────────────────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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