/* ============================================================
   PGM Publisher — Design System
   ============================================================ */

:root {
  --sidebar-w: 248px;
  --header-h: 60px;

  /* Tamaño de fuente base del proyecto — pedido explícito de Omar
     (2026-10-10): "debes tener un tamaño de fuente base para todo el
     proyecto" — ya existía (era el font-size de <body>, 14px, heredado
     por cualquier texto que no define su propio tamaño), solo que sin
     nombre propio. Ahora es una variable con nombre, y se sube un paso
     (14px→16px) para que se lea más grande en todo el sitio. */
  --font-size-base: 16px;

  /* Colores */
  --sidebar-bg:     #0f172a;
  --sidebar-hover:  #1e293b;
  --sidebar-text:   #94a3b8;
  --sidebar-active: #0891b2;

  --accent:       #0891b2;
  --accent-dark:  #0e7490;
  --accent-light: #e0f2fe;

  --body-bg:  #f1f5f9;
  --card-bg:  #ffffff;
  --border:   #e2e8f0;

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #64748b;

  --status-draft:     #64748b;
  --status-review:    #d97706;
  --status-published: #16a34a;
  --status-rejected:  #dc2626;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);

  /* ── Aliases de compatibilidad ── */
  --surface: var(--card-bg);
  --bg:      var(--body-bg);
  --text:    var(--text-primary);
  --rule:    var(--border);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, 'Inter', 'Segoe UI', sans-serif; font-size: var(--font-size-base); color: var(--text-primary); background: var(--body-bg); line-height: 1.5; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---- Layout ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  /* 100dvh además de 100vh (fallback para navegadores viejos sin soporte de
     dvh): en móvil, 100vh no sigue el alto real visible cuando la barra de
     direcciones del navegador está mostrada/escondida — el drawer quedaba
     más alto o más bajo que la pantalla real, cortando contenido al fondo.
     Mismo fix ya aplicado en asistente.html para el mismo problema. */
  height: 100vh;
  height: 100dvh;
  z-index: 100;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overflow-x: hidden;
  transition: width .18s ease;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: relative;
}
.sidebar-logo a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.sidebar-toggle-btn {
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 15px;
  padding: 4px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.sidebar-toggle-btn:hover { color: #e2e8f0; background: var(--sidebar-hover); }

/* ---- Colapsado: solo íconos ---- */
body.sidebar-collapsed { --sidebar-w: 68px; }
body.sidebar-collapsed .sidebar-logo-text,
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .user-info,
body.sidebar-collapsed #font-size-row {
  display: none;
}
body.sidebar-collapsed .sidebar-logo { flex-direction: column; justify-content: center; padding: 16px 8px; gap: 10px; }
body.sidebar-collapsed .sidebar-logo a { justify-content: center; }
body.sidebar-collapsed .nav-item { justify-content: center; }
body.sidebar-collapsed .user-chip { justify-content: center; }
.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.sidebar-logo-text { line-height: 1.2; }
.sidebar-logo-text strong { display: block; color: #f1f5f9; font-size: 13px; font-weight: 700; letter-spacing: .3px; }
.sidebar-logo-text span  { color: var(--sidebar-text); font-size: 11px; }

.sidebar-section { padding: 16px 12px 8px; }
.sidebar-label { color: var(--text-muted); font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; padding: 0 8px 8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: rgba(8,145,178,.18); color: var(--accent); }
.nav-item i { font-size: 16px; width: 18px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 12px;
  border-top: 1px solid #1e293b;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
}
.user-avatar {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; font-size: 14px;
  flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-name { color: #e2e8f0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: var(--text-muted); font-size: 11px; }
.btn-logout {
  background: none; border: none;
  color: var(--sidebar-text);
  font-size: 18px;
  padding: 4px;
  border-radius: 4px;
  transition: color .15s;
}
.btn-logout:hover { color: #ef4444; }

/* ---- Main content ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0; /* bug real de flexbox, encontrado 2026-09-26: por default un
    ítem flex tiene min-width:auto (NO 0), es decir "nunca encoge por debajo
    del ancho mínimo de su contenido" — cualquier tabla/grid ancho en CUALQUIER
    página (ej. el grid de 2 columnas de /publisher/videos) hacía que esta caja
    se negara a encoger en móvil y se desbordara del layout completo, en vez
    de que el contenido se acomodara. Es la causa raíz real de varios reportes
    de "no se ve bien en móvil" — un fix a nivel global, no por página. */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .18s ease;
}

.topbar {
  height: var(--header-h);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  /* padding-right más generoso: la campanita de notificaciones
     (.notif-bell-wrap, sidebar.js) flota fixed sobre la esquina superior
     derecha en TODAS las páginas, con z-index más alto que el topbar — sin
     este espacio reservado, cualquier botón del topbar pegado a la derecha
     (Nuevo video, Nuevo artículo, Nueva publicación...) queda tapado detrás
     de ella. Antes esto se parchaba página por página (ver asistente.html);
     ahora es global para que no haga falta repetirlo en cada página nueva. */
  padding-right: 76px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 17px; font-weight: 700; color: var(--text-primary); flex: 1; }
.topbar-subtitle { font-size: 12px; color: var(--text-muted); font-weight: 400; margin-left: 8px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.page-body { padding: 18px; flex: 1; }

/* ---- Cards ---- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-title { font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }

/* ---- Stat cards ---- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.teal    { background: #e0f2fe; color: #0891b2; }
.stat-icon.green   { background: #dcfce7; color: #16a34a; }
.stat-icon.amber   { background: #fef3c7; color: #d97706; }
.stat-icon.slate   { background: #f1f5f9; color: #64748b; }
.stat-icon.blue    { background: #dbeafe; color: #2563eb; }
.stat-icon.purple  { background: #ede9fe; color: #7c3aed; }
.stat-icon.red     { background: #fee2e2; color: #dc2626; }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1; margin-bottom: 2px; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  transition: background .15s, opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:not(:disabled):active { transform: scale(.98); }

.btn-primary  { background: var(--accent); color: white; }
.btn-primary:not(:disabled):hover { background: var(--accent-dark); }

.btn-success  { background: #16a34a; color: white; }
.btn-success:not(:disabled):hover { background: #15803d; }

.btn-outline {
  background: white;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:not(:disabled):hover { background: var(--body-bg); }

.btn-danger   { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.btn-danger:not(:disabled):hover { background: #fecaca; }

.btn-tint     { background: var(--accent-light); color: var(--accent); border: 1px solid var(--accent-light); font-weight: 600; }
.btn-tint:not(:disabled):hover { background: #bae6fd; }

.btn-ghost    { background: transparent; color: var(--text-secondary); }
.btn-ghost:not(:disabled):hover { background: var(--body-bg); }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn i  { font-size: 15px; }

.btn-spinner { display: none; }
.btn.loading .btn-spinner { display: inline-block; animation: spin .7s linear infinite; }
.btn.loading .btn-label { opacity: .7; }

/* ---- Status badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-draft     { background: #f1f5f9; color: var(--status-draft); }
.badge-revision  { background: #fef3c7; color: var(--status-review); }
.badge-published { background: #dcfce7; color: var(--status-published); }
.badge-rejected  { background: #fee2e2; color: var(--status-rejected); }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafafa; }
.td-title { color: var(--text-primary); font-weight: 600; max-width: 300px; }
.td-title span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.td-small { font-size: 12px; color: var(--text-muted); }
.td-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* Stats column */
.td-stats { white-space: nowrap; }
.stat-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-muted);
  padding: 2px 7px; border-radius: 20px;
  background: var(--bg-soft); margin: 1px 2px 1px 0;
}
.stat-pill i { font-size: 11px; }

/* Inicio flags column */
.td-flags { white-space: nowrap; text-align: center; }
.flag-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; padding: 2px 7px;
  border-radius: 20px; white-space: nowrap;
}
.flag-destacado { background: #fef3c7; color: #92400e; }
.flag-inicio    { background: #e0f2fe; color: #075985; }
.flag-off       { color: #d1d5db; font-size: 16px; }

/* ---- AI Provider selector (shared: editor + video) ---- */
.proveedor-selector { display: grid; grid-template-columns: 1fr; gap: 6px; }
.proveedor-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--body-bg);
  user-select: none;
}
.proveedor-opt:hover { border-color: #94a3b8; color: var(--text-secondary); }
.proveedor-opt.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.proveedor-icon { font-size: 16px; line-height: 1; }
.proveedor-name { line-height: 1.3; }
.proveedor-name small { font-weight: 400; font-size: 10px; opacity: .8; display: block; }

/* ---- Filter tabs ---- */
.filter-tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.filter-tab {
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
}
.filter-tab:hover { background: white; color: var(--text-secondary); }
.filter-tab.active { background: white; color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--text-primary); }
.form-label .required { color: #ef4444; margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--text-primary);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8,145,178,.12);
}
.form-textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: #dc2626; margin-top: 4px; display: none; }

.form-row { display: grid; gap: 14px; }
.form-row-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.form-row-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }

.checkbox-group { display: flex; gap: 16px; flex-wrap: wrap; }
.checkbox-label { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; user-select: none; }
.checkbox-label input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---- Editor layout ---- */
.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.editor-panel { display: flex; flex-direction: column; gap: 16px; }

.title-input {
  width: 100%;
  font-size: 22px;
  font-weight: 700;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  padding: 0;
  line-height: 1.3;
}
.title-input::placeholder { color: var(--text-muted); }

.editor-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Quill overrides */
.ql-container { font-size: 15px; font-family: inherit; border-radius: 0 0 var(--radius-sm) var(--radius-sm) !important; min-height: 380px; }
.ql-toolbar { border-radius: 0 !important; border-left: none !important; border-right: none !important; border-color: var(--border) !important; }
.ql-container.ql-snow { border-left: none !important; border-right: none !important; border-bottom: none !important; border-color: var(--border) !important; }
.ql-editor { min-height: 380px; line-height: 1.8; }
.ql-editor p { margin-bottom: .7em; }

/* ---- AI Panel ---- */
.ai-panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: calc(var(--header-h) + 20px);
  max-height: calc(100vh - var(--header-h) - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-panel-icon {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, #0891b2, #7c3aed);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.ai-panel-title { font-size: 14px; font-weight: 700; }
.ai-panel-sub   { font-size: 11px; color: var(--text-muted); margin-left: auto; }

.ai-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.ai-tab {
  flex: 1;
  padding: 9px 6px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  transition: all .15s;
  cursor: pointer;
}
.ai-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.ai-tab:hover:not(.active) { color: var(--text-secondary); background: var(--body-bg); }

.ai-tab-content { display: none; flex: 1; overflow-y: auto; padding: 16px; }
.ai-tab-content.active { display: block; }

.ai-result {
  margin-top: 14px;
  background: var(--body-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 12.5px;
  color: var(--text-secondary);
  display: none;
}
.ai-result.show { display: block; }
.ai-result-title { font-weight: 700; color: var(--text-primary); font-size: 13px; margin-bottom: 4px; }
.ai-result-meta  { display: flex; gap: 12px; font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.ai-image-preview {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--body-bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 10px;
  overflow: hidden;
  position: relative;
}
.ai-image-preview img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.ai-image-placeholder { text-align: center; }
.ai-image-placeholder i { font-size: 28px; display: block; margin-bottom: 6px; }

/* ---- Cover image ---- */
/* Bug real corregido (2026-10-09, reportado por Omar): esta variante
   "chica" rompía su propia proporción con un alto fijo de 110px sin
   relación con el ancho real de la tarjeta — terminaba viéndose MUCHO
   más aplanada (~2.7:1 o más) que el 16:9 real que usa el modal "Ajustar
   encuadre" y el artículo publicado, dando la sensación de "poca altura"
   y de que el encuadre elegido no coincidía con lo que se veía aquí.
   Ahora hereda el mismo aspect-ratio:16/9 de .cover-preview — se ve más
   alta, pero exactamente en la misma proporción en todos lados. */
.cover-preview-sm {
  max-width: 420px;
}
.cover-preview-sm .cover-preview-label i { font-size: 18px; margin-bottom: 2px; }
.cover-preview-sm .cover-preview-label span { font-size: 11px; }

.cover-preview {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--body-bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: border-color .15s;
}
.cover-preview:hover { border-color: var(--accent); }
.cover-preview img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.cover-preview-label { text-align: center; pointer-events: none; z-index: 1; }
.cover-preview-label i { font-size: 24px; display: block; margin-bottom: 5px; }
.cover-preview-label span { font-size: 12px; }

/* ---- Editor save bar ---- */
.editor-topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 10px 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.editor-topbar-back { color: var(--text-muted); font-size: 13px; display: flex; align-items: center; gap: 5px; }
.editor-topbar-back:hover { color: var(--accent); }
.editor-topbar-status { font-size: 12px; color: var(--text-muted); }
.editor-topbar-status.saved  { color: #16a34a; }
.editor-topbar-status.saving { color: var(--accent); }

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1e293b;
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideUp .25s ease;
  min-width: 280px;
  max-width: 380px;
}
.toast i { font-size: 16px; flex-shrink: 0; }
.toast.toast-success i { color: #4ade80; }
.toast.toast-error   i { color: #f87171; }
.toast.toast-info    i { color: #60a5fa; }
.toast.hide { animation: slideDown .2s ease forwards; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: all .2s;
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal {
  background: white;
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: scale(.95);
  transition: transform .2s;
}
.modal-overlay.show .modal { transform: scale(1); }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.modal-body  { color: var(--text-secondary); font-size: 14px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
/* Botón "X" para cerrar un modal, esquina superior derecha — ya existía
   repetido en video.html (y ahora dashboard.html/editor.html lo necesitan
   también), se consolida aquí para no duplicarlo página por página.
   `.modal` no necesita position:relative explícito: su `transform:scale()`
   ya lo convierte en el contenedor de posicionamiento de este botón
   absolute (comportamiento estándar de CSS con cualquier transform !=none). */
.modal-x-close {
  position: absolute; top: 10px; right: 10px;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 15px; line-height: 1;
  transition: background .15s, color .15s;
}
.modal-x-close:hover { background: var(--body-bg); color: var(--text); }

/* ---- Login ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.login-logo-icon {
  width: 44px; height: 44px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: white;
}
.login-logo-text strong { display: block; font-size: 18px; font-weight: 800; color: var(--text-primary); }
.login-logo-text span   { font-size: 12px; color: var(--text-muted); }
.login-title { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login-sub   { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; display: block; margin-bottom: 12px; opacity: .4; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }

/* ---- Loader ---- */
.page-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 14px;
  color: var(--text-muted);
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ---- Word count / char count ---- */
.char-count { font-size: 11px; color: var(--text-muted); text-align: right; margin-top: 3px; }
.char-count.warn { color: var(--status-review); }
.char-count.over { color: var(--status-rejected); }

/* ---- Destination toggle ---- */
.destination-row {
  display: flex;
  gap: 10px;
}
.dest-toggle {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--body-bg);
  position: relative;
  user-select: none;
}
.dest-toggle input[type=checkbox] { position: absolute; opacity: 0; }
.dest-toggle.checked { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.dest-toggle i { font-size: 18px; }

/* ---- Animations ---- */
@keyframes spin       { to { transform: rotate(360deg); } }
@keyframes slideUp    { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideDown  { to   { transform: translateY(10px); opacity: 0; } }
@keyframes pulse      { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
.animate-pulse        { animation: pulse 1.5s ease infinite; }

/* ---- Divider ---- */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---- Section header ---- */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title  { font-size: 16px; font-weight: 700; }

/* ---- Utilities ---- */
.flex   { display: flex; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.ml-auto{ margin-left: auto; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); font-size: 12px; }

/* form-control alias (Bootstrap compat) */
.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--text-primary);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  font-family: inherit;
  font-size: 14px;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8,145,178,.12);
}

/* ============================================================
   RESPONSIVE — Mobile / Tablet
   ============================================================ */

/* Hamburger toggle button — hidden on desktop */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  width: 36px; height: 36px;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 22px;
  border-radius: 6px;
  flex-shrink: 0;
  padding: 0;
}
.sidebar-toggle:hover { background: var(--body-bg); }

/* Dark overlay behind open sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
}
.sidebar-overlay.show { display: block; }

/* ---- Tablet (≤ 900px) ---- */
@media (max-width: 900px) {
  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(calc(-1 * var(--sidebar-w) - 10px));
    transition: transform .25s ease;
    z-index: 200;
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,.35);
  }

  /* Main content spans full width */
  .main-content { margin-left: 0; }

  /* Show hamburger */
  .sidebar-toggle { display: flex; }

  /* Stats: 2×2 */
  .stats-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }

  /* Table: make scrollable */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Drawer más compacto en móvil — reportado por Omar que "no se alcanza a
     ver todo en vertical": el contenido natural del menú (logo + 5 secciones
     + footer) mide ~1018px de alto, más que el viewport visible de la
     mayoría de teléfonos (~650-750px con la barra de direcciones mostrada) —
     scroll sigue siendo necesario, pero se achica el padding para que quepa
     más de un vistazo y haga falta menos scroll para llegar al pie (créditos/
     usuario/logout). */
  .sidebar-logo { padding: 14px 16px 10px; }
  .sidebar-section { padding: 10px 12px 4px; }
  .nav-item { padding: 7px 10px; margin-bottom: 1px; }
  .sidebar-footer { padding: 10px 12px; }
}

/* ---- Mobile (≤ 640px) ---- */
@media (max-width: 640px) {
  /* Topbar */
  /* padding-right se mantiene reservando espacio para la campanita fixed
     (mismo motivo que en la regla de escritorio de arriba) — su tamaño/
     posición no cambia en móvil, solo el padding izquierdo se achica. */
  .topbar { padding: 0 14px; padding-right: 68px; gap: 8px; }
  .topbar-title { font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-subtitle { display: none; }
  /* Botones del topbar (ej. "Nuevo artículo", "Crear video"): con texto
     completo no caben junto al título en pantallas angostas y desbordaban
     la página completa (encontrado 2026-09-26 revisando /publisher/home) —
     en móvil se dejan solo como ícono. El texto se oculta con font-size:0
     (sin tocar el HTML de cada página) y el ícono recupera su tamaño aparte. */
  .topbar-actions { flex-shrink: 0; }
  .topbar-actions .btn { padding: 8px 10px; font-size: 0; }
  .topbar-actions .btn i { font-size: 15px; }

  /* Editor topbar */
  .editor-topbar { padding: 0 14px; gap: 8px; }
  .editor-topbar-back span { display: none; } /* solo el ícono ← en móvil */

  /* Page body */
  .page-body { padding: 16px 14px; }

  /* Stats — minmax(0,1fr) por la misma razón que .two-col en home.html: un
     track en 1fr a secas nunca encoge por debajo del contenido de la celda
     más ancha. */
  .stats-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .stat-card { padding: 14px 12px; }
  .stat-value { font-size: 22px; }

  /* Card */
  .card-header { flex-wrap: wrap; gap: 8px; }
  .filter-tabs { min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }

  /* Table: hide stats and date on mobile */
  .table-wrap th:nth-child(3),
  .table-wrap td:nth-child(3),
  .table-wrap th:nth-child(4),
  .table-wrap td:nth-child(4),
  .table-wrap th:nth-child(5),
  .table-wrap td:nth-child(5) { display: none; }

  /* Editor layout: stack panels */
  .editor-layout { grid-template-columns: minmax(0, 1fr); }

  /* Form rows: single column */
  .form-row-2 { grid-template-columns: minmax(0, 1fr); }
  .form-row-3 { grid-template-columns: minmax(0, 1fr); }

  /* AI panel full width */
  .ai-panel { min-width: 0; }

  /* Login page */
  .login-box { padding: 28px 20px; margin: 16px; }
}

/* ---- Notificaciones (campanita) ----
   Flotante sobre document.body (inyectada por sidebar.js, presente en todas
   las páginas) — pedido explícito de Omar: el usuario debe poder navegar a
   cualquier página del sitio y enterarse igual cuando su video esté listo,
   sin depender de quedarse en una pestaña específica (eso lo cubre el
   aviso del navegador, aparte). */
.notif-bell-wrap { position: fixed; top: 16px; right: 20px; z-index: 500; }
.notif-bell-btn {
  position: relative; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: white; color: var(--text-secondary);
  font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.notif-bell-btn:hover { border-color: var(--accent); color: var(--accent); }
.notif-bell-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 999px; background: #ef4444; color: #fff; font-size: 10.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid white;
}
.notif-bell-panel {
  position: absolute; top: 48px; right: 0; width: 320px; max-height: 420px;
  background: white; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.15); overflow: hidden; display: flex; flex-direction: column;
}
.notif-bell-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 700;
}
.notif-bell-panel-header button {
  background: none; border: none; color: var(--accent); font-size: 11.5px; font-weight: 600; cursor: pointer;
}
.notif-bell-lista { overflow-y: auto; flex: 1; }
.notif-bell-vacio { padding: 24px 14px; text-align: center; font-size: 12.5px; color: var(--text-muted); }
.notif-bell-item {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 11px 14px;
  border: none; border-bottom: 1px solid var(--border); background: white; cursor: pointer; text-align: left;
  transition: background .15s;
}
.notif-bell-item:hover { background: var(--body-bg); }
.notif-bell-item.no-leido { background: var(--accent-light); }
.notif-bell-item i { font-size: 16px; margin-top: 2px; flex-shrink: 0; }
.notif-bell-ic-ok    { color: #16a34a; }
.notif-bell-ic-error { color: #dc2626; }
.notif-bell-item-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-bell-item-titulo { font-size: 12.5px; font-weight: 700; color: var(--text-primary); }
.notif-bell-item-msg { font-size: 11.5px; color: var(--text-secondary); }
.notif-bell-item-fecha { font-size: 10.5px; color: var(--text-muted); }
