/* ── RESET ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ── VARIABLES ──────────────────────────────────────────────────────────────── */
:root {
  /* Colores */
  --color-red:     #dc2626;
  --color-red-2:   #ef4444;
  --color-blue:    #3b82f6;
  --color-green:   #10b981;
  --color-yellow:  #f59e0b;
  --color-purple:  #8b5cf6;

  /* Fondos */
  --bg:      #0f1117;
  --bg-2:    #1a1f2e;
  --bg-3:    #222836;
  --surface: #1e2538;
  --border:  #2d3748;

  /* Texto */
  --text:    #e2e8f0;
  --text-2:  #94a3b8;
  --text-3:  #64748b;

  /* Acento principal — rojo YouTube */
  --accent:  #dc2626;

  /* Tipografía */
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;

  /* Espaciado */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  /* Bordes */
  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 16px;

  /* Sombras */
  --shadow:    0 4px 20px rgba(0,0,0,.5);
  --shadow-sm: 0 2px 8px  rgba(0,0,0,.35);

  /* Sidebar */
  --sidebar-w: 220px;

  /* Transición */
  --t: 150ms ease;
}

/* ── BASE ───────────────────────────────────────────────────────────────────── */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: .9375rem;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
}

img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

::-webkit-scrollbar       { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

/* ── APP LAYOUT (sidebar + main) ────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100dvh;
}

/* ── SIDEBAR ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transform: translateX(-100%);
  transition: transform .25s ease;
  overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }

@media (min-width: 900px) {
  .sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    transform: none;
    flex-shrink: 0;
  }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.sidebar-brand-name {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.sidebar-brand-name span { color: var(--accent); }

.sidebar-nav {
  flex: 1;
  padding: var(--sp-4) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.nav-section-title {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-3);
  padding: var(--sp-3) var(--sp-2) var(--sp-1);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 9px var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: .875rem;
  font-weight: 500;
  transition: background var(--t), color var(--t);
  position: relative;
}
.nav-link:hover { background: var(--bg-3); color: var(--text); }
.nav-link.active {
  background: rgba(220,38,38,.15);
  color: var(--color-red-2);
  font-weight: 600;
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-link-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-link-text { flex: 1; }

.sidebar-footer {
  padding: var(--sp-4) var(--sp-3);
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  color: var(--text-2);
}
.sidebar-avatar {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* ── MAIN CONTENT ───────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

@media (min-width: 900px) {
  .main-content { margin-left: 0; }
}

/* ── TOP BAR ────────────────────────────────────────────────────────────────── */
.topbar {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--sp-4);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.menu-toggle {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  padding: var(--sp-2);
  border-radius: var(--radius-sm);
}
.menu-toggle span {
  display: block;
  width: 20px; height: 2px;
  background: var(--text-2);
  border-radius: 2px;
  transition: var(--t);
}
@media (min-width: 900px) { .menu-toggle { display: none; } }

/* ── PAGE CONTENT ───────────────────────────────────────────────────────────── */
.page {
  flex: 1;
  padding: var(--sp-5) var(--sp-4);
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}
@media (min-width: 768px) { .page { padding: var(--sp-6); } }

.page-header {
  margin-bottom: var(--sp-6);
}
.page-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.page-subtitle {
  font-size: .875rem;
  color: var(--text-2);
  margin-top: var(--sp-1);
}

/* ── OVERLAY ────────────────────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }
@media (min-width: 900px) { .sidebar-overlay { display: none !important; } }

/* ── CARDS ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
}
.card-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-3);
  margin-bottom: var(--sp-4);
}

/* Stat cards grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}
@media (min-width: 640px)  { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--stat-color, var(--accent));
}
.stat-card-icon {
  font-size: 1.5rem;
  opacity: .8;
}
.stat-card-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.stat-card-label {
  font-size: .75rem;
  color: var(--text-2);
}

/* ── FORMULARIOS ────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--sp-4); }
.form-label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: var(--sp-2);
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: .9375rem;
  outline: none;
  transition: border-color var(--t);
  -webkit-appearance: none;
  appearance: none;
  min-height: 44px;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus { border-color: var(--accent); }
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-3); }
.form-textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.form-hint {
  font-size: .7rem;
  color: var(--text-3);
  margin-top: var(--sp-1);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-3);
}
@media (min-width: 640px) {
  .form-row { grid-template-columns: 1fr 1fr; }
  .form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
}

/* Select con flecha custom */
.form-select-wrap { position: relative; }
.form-select-wrap::after {
  content: '▾';
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
  font-size: .75rem;
}

/* ── BOTONES ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
  min-height: 44px;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }

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

.btn-blue {
  background: var(--color-blue);
  color: #fff;
}
.btn-blue:hover { filter: brightness(1.1); }

.btn-green {
  background: var(--color-green);
  color: #fff;
}
.btn-danger {
  background: rgba(220,38,38,.15);
  color: var(--color-red-2);
  border: 1px solid rgba(220,38,38,.3);
}
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: .8125rem; min-height: 36px; }
.btn-lg { padding: 13px 24px; font-size: 1rem; }
.btn-full { width: 100%; }

.btn-loading { pointer-events: none; opacity: .7; }

/* ── BADGES / STATUS ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .8;
}
.badge-pending    { background: rgba(100,116,139,.15); color: #94a3b8; }
.badge-procesando,
.badge-processing { background: rgba(245,158,11,.15);  color: #f59e0b; }
.badge-done,
.badge-completado { background: rgba(16,185,129,.15);  color: #10b981; }
.badge-error      { background: rgba(220,38,38,.15);   color: #ef4444; }
.badge-enviando,
.badge-borrador   { background: rgba(59,130,246,.15);  color: #60a5fa; }

/* ── TABLA RESPONSIVA ───────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  background: var(--bg-3);
  color: var(--text-3);
  padding: 10px 14px;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-3); }

.td-truncate {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── TOAST ──────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  opacity: 0;
  visibility: hidden;
  padding: 10px 22px;
  border-radius: 30px;
  font-size: .8125rem;
  font-weight: 600;
  z-index: 9999;
  /* ocultar: fade + slide inmediato, luego visibility off al terminar la transición */
  transition: transform .25s ease, opacity .25s ease, visibility 0s linear .25s;
  white-space: nowrap;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
  /* mostrar: visibility on inmediato, luego fade + slide */
  transition: transform .25s ease, opacity .25s ease, visibility 0s linear 0s;
}
.toast.toast-ok     { background: var(--color-green); color: #fff; }
.toast.toast-error  { background: var(--color-red-2); color: #fff; }
.toast.toast-warn   { background: var(--color-yellow); color: #1a1a1a; }

/* ── LOGIN PAGE ─────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
}
.login-box {
  width: 100%;
  max-width: 460px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-8) var(--sp-6);
  box-shadow: var(--shadow);
}
.login-logo {
  text-align: center;
  margin-bottom: var(--sp-6);
}
.login-logo-icon {
  width: 56px; height: 56px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto var(--sp-3);
}
.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
}
.login-logo h1 span { color: var(--accent); }
.login-logo p {
  font-size: .8rem;
  color: var(--text-3);
  margin-top: var(--sp-1);
}
.login-footer-link {
  text-align: center;
  margin-top: var(--sp-4);
  font-size: .8125rem;
  color: var(--text-2);
}
.login-footer-link a { color: var(--color-blue); font-weight: 600; }
.login-footer-link a:hover { text-decoration: underline; }

/* ── ALERT / INFO BOX ───────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  padding: var(--sp-3) var(--sp-4);
  font-size: .8125rem;
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
}
.alert-error   { background: rgba(220,38,38,.1);  border: 1px solid rgba(220,38,38,.25); color: #fca5a5; }
.alert-success { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.25); color: #6ee7b7; }
.alert-info    { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.25); color: #93c5fd; }
.alert-warn    { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.25); color: #fde68a; }
.alert.hidden  { display: none; }

/* ── UPLOAD DROP ZONE ───────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: var(--sp-10) var(--sp-6);
  text-align: center;
  transition: border-color var(--t), background var(--t);
  cursor: pointer;
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(220,38,38,.05);
}
.drop-zone-icon { font-size: 2.5rem; margin-bottom: var(--sp-3); opacity: .5; }
.drop-zone-text { color: var(--text-2); font-size: .9rem; }
.drop-zone-hint { font-size: .75rem; color: var(--text-3); margin-top: var(--sp-2); }

/* ── PROGRESS BAR ───────────────────────────────────────────────────────────── */
.progress-wrap {
  background: var(--bg-3);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width .4s ease;
}

/* ── EMPTY STATE ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px var(--sp-5);
  color: var(--text-3);
}
.empty-state-icon { font-size: 3rem; margin-bottom: var(--sp-3); opacity: .4; }
.empty-state h3   { font-size: 1rem; color: var(--text-2); margin-bottom: var(--sp-2); }
.empty-state p    { font-size: .875rem; }

/* ── UTILIDADES ─────────────────────────────────────────────────────────────── */
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.divider  { border: none; border-top: 1px solid var(--border); margin: var(--sp-5) 0; }
.mt-4     { margin-top: var(--sp-4); }
.mt-6     { margin-top: var(--sp-6); }
.mb-4     { margin-bottom: var(--sp-4); }
.mb-6     { margin-bottom: var(--sp-6); }
.flex     { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2    { gap: var(--sp-2); }
.gap-3    { gap: var(--sp-3); }
.gap-4    { gap: var(--sp-4); }
.text-sm  { font-size: .875rem; }
.text-xs  { font-size: .75rem; }
.text-muted { color: var(--text-2); }
.text-red   { color: var(--color-red-2); }
.text-green { color: var(--color-green); }
.font-bold  { font-weight: 700; }
.hidden     { display: none !important; }
.w-full     { width: 100%; }

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

/* Fade in */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.fade-in { animation: fadeIn .2s ease; }
