/* =============================================================================
   NovaToons - Estilos Globales
   styles.css
   Diseño moderno, fluido, con temas Claro/Oscuro y estética Manga/Webtoon
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. Variables CSS y Temas (Claro y Oscuro)
   ----------------------------------------------------------------------------- */
:root {
  /* Paleta Base (Modo Claro) */
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f1f5f9;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #6366f1;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;

  --accent: #ec4899;
  --accent-hover: #db2777;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* Estética Cómic / Manga */
  --panel-bg: #1e293b;
  --panel-border: #0f172a;
  --bubble-bg: #ffffff;
  --bubble-border: #1e293b;
  --bubble-text: #0f172a;
  --bubble-tail: #ffffff;
  
  --narration-bg: #fef08a;
  --narration-border: #eab308;
  --narration-text: #713f12;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-panel: 0 8px 30px rgba(0, 0, 0, 0.2);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-comic: 'Bangers', 'Impact', system-ui, sans-serif;
}

/* Modo Oscuro Nativo */
[data-theme="dark"] {
  --bg-body: #0b0f19;
  --bg-surface: #111827;
  --bg-surface-alt: #1f2937;
  --bg-card: #182234;
  --border-color: #374151;
  --border-focus: #818cf8;

  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-inverse: #0f172a;

  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-light: #1e1b4b;

  --accent: #f472b6;
  --accent-hover: #ec4899;

  --panel-bg: #030712;
  --panel-border: #374151;
  --bubble-bg: #ffffff;
  --bubble-border: #111827;
  --bubble-text: #111827;
  --bubble-tail: #ffffff;

  --narration-bg: #372f10;
  --narration-border: #854d0e;
  --narration-text: #fef08a;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
  --shadow-panel: 0 8px 30px rgba(0, 0, 0, 0.6);
}

/* -----------------------------------------------------------------------------
   2. Reset y Tipografía Base
   ----------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.2s ease;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* -----------------------------------------------------------------------------
   3. Encabezado y Navegación
   ----------------------------------------------------------------------------- */
.navbar {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.brand-badge {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-link {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
}

.nav-link:hover, .nav-link.active {
  color: var(--primary);
  background-color: var(--primary-light);
  text-decoration: none;
}

/* Botón de Tema (Claro / Oscuro) */
.theme-toggle-btn {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.theme-toggle-btn:hover {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

/* -----------------------------------------------------------------------------
   4. Estructura Principal y Layout
   ----------------------------------------------------------------------------- */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* Grid de administración */
.admin-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 2rem;
  align-items: start;
}

/* Tarjetas (Cards) */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* -----------------------------------------------------------------------------
   5. Formularios y Botones
   ----------------------------------------------------------------------------- */
.form-group {
  margin-bottom: 1.1rem;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

textarea {
  resize: vertical;
  min-height: 130px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.88rem;
  line-height: 1.5;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #f43f5e);
  color: #ffffff;
}
.btn-accent:hover:not(:disabled) {
  opacity: 0.95;
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.35);
}

.btn-secondary {
  background-color: var(--bg-surface-alt);
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover:not(:disabled) {
  background-color: var(--border-color);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

.button-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* -----------------------------------------------------------------------------
   6. Indicador de Carga (Spinner) y Notificaciones
   ----------------------------------------------------------------------------- */
.spinner-container {
  display: none;
  background-color: var(--bg-surface-alt);
  border: 1px dashed var(--primary);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  margin: 1.5rem 0;
  animation: pulseBg 2s infinite ease-in-out;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
  margin: 0 auto 1rem;
}

.spinner-text {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.spinner-subtext {
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

@keyframes pulseBg {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

/* Alertas */
.alert {
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.alert-success {
  background-color: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.alert-error {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
[data-theme="dark"] .alert-success {
  background-color: #064e3b;
  color: #a7f3d0;
  border-color: #047857;
}
[data-theme="dark"] .alert-error {
  background-color: #7f1d1d;
  color: #fecaca;
  border-color: #b91c1c;
}

/* -----------------------------------------------------------------------------
   7. Tarjetas de Previsualización de Escenas (Admin)
   ----------------------------------------------------------------------------- */
.scenes-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.scene-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.scene-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.scene-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}

.scene-number-badge {
  background-color: var(--primary);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
}

.prompt-box {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin-bottom: 0.85rem;
  font-size: 0.88rem;
}

.prompt-label {
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.narration-box-admin {
  background-color: var(--narration-bg);
  color: var(--narration-text);
  border-left: 3px solid var(--narration-border);
  padding: 0.6rem 0.85rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  font-size: 0.88rem;
  margin-bottom: 0.85rem;
}

.dialogue-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dialogue-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.88rem;
}

.dialogue-speaker {
  font-weight: 700;
  color: var(--text-main);
  background-color: var(--bg-surface-alt);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  white-space: nowrap;
}

/* -----------------------------------------------------------------------------
   8. Lector Público de Manga/Webtoon (index.html)
   ----------------------------------------------------------------------------- */
.webtoon-viewport {
  max-width: 780px;
  margin: 0 auto;
  padding: 1rem 0;
}

.webtoon-panel {
  position: relative;
  background-color: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: var(--radius-md);
  margin-bottom: 2rem;
  overflow: hidden;
  box-shadow: var(--shadow-panel);
}

.panel-frame {
  position: relative;
  min-height: 480px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem;
  background-size: cover;
  background-position: center;
}

/* Efecto de viñeta manga con degradado */
.panel-gradient-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15,23,42,0.4) 0%, rgba(15,23,42,0.2) 50%, rgba(15,23,42,0.7) 100%);
  pointer-events: none;
}

.panel-scene-watermark {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 1px;
  z-index: 2;
  text-transform: uppercase;
}

/* Cuadro de Narración Cómic */
.comic-narration {
  position: relative;
  z-index: 3;
  align-self: flex-start;
  max-width: 85%;
  background-color: var(--narration-bg);
  border: 2px solid var(--narration-border);
  color: var(--narration-text);
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-style: italic;
  font-weight: 500;
  box-shadow: 2px 3px 0px rgba(0, 0, 0, 0.35);
  margin-bottom: 1.5rem;
}

/* Globos de Diálogo Cómic (Speech Bubbles) */
.dialogue-bubbles-wrapper {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
}

.comic-bubble {
  position: relative;
  max-width: 78%;
  background-color: var(--bubble-bg);
  border: 2.5px solid var(--bubble-border);
  color: var(--bubble-text);
  padding: 0.8rem 1.2rem;
  border-radius: 18px;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: 2px 4px 0px rgba(0, 0, 0, 0.4);
}

/* Colocación alternada de personajes */
.bubble-left {
  align-self: flex-start;
  margin-left: 0.5rem;
}

.bubble-right {
  align-self: flex-end;
  margin-right: 0.5rem;
  text-align: right;
}

/* Cola o rabillo del globo de diálogo */
.bubble-left::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 24px;
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 2px solid transparent;
  border-top: 12px solid var(--bubble-bg);
}

.bubble-left::before {
  content: '';
  position: absolute;
  bottom: -15px;
  left: 22px;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 3px solid transparent;
  border-top: 15px solid var(--bubble-border);
}

.bubble-right::after {
  content: '';
  position: absolute;
  bottom: -12px;
  right: 24px;
  width: 0;
  height: 0;
  border-right: 12px solid transparent;
  border-left: 2px solid transparent;
  border-top: 12px solid var(--bubble-bg);
}

.bubble-right::before {
  content: '';
  position: absolute;
  bottom: -15px;
  right: 22px;
  width: 0;
  height: 0;
  border-right: 14px solid transparent;
  border-left: 3px solid transparent;
  border-top: 15px solid var(--bubble-border);
}

.bubble-character {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.2rem;
}

.bubble-text {
  line-height: 1.4;
}

/* Drawer / Acordeón para ver el prompt visual en el lector */
.panel-prompt-drawer {
  background-color: rgba(15, 23, 42, 0.95);
  color: #e2e8f0;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--panel-border);
  font-size: 0.82rem;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.panel-prompt-drawer strong {
  color: #38bdf8;
  white-space: nowrap;
}

/* -----------------------------------------------------------------------------
   9. Cabecera de la Serie / Selector de Capítulos (Lector)
   ----------------------------------------------------------------------------- */
.series-hero {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.series-cover {
  width: 120px;
  height: 170px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  background-color: var(--bg-surface-alt);
}

.series-info {
  flex: 1;
}

.series-category {
  display: inline-block;
  background-color: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.4rem;
}

.series-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
}

.series-synopsis {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 1rem;
}

.chapter-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

/* -----------------------------------------------------------------------------
   10. Media Queries Responsivas
   ----------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .navbar {
    padding: 0.75rem 1rem;
  }

  .nav-container {
    flex-wrap: wrap;
  }

  .series-hero {
    flex-direction: column;
    text-align: center;
  }

  .series-cover {
    width: 140px;
    height: 190px;
  }

  .panel-frame {
    min-height: 400px;
    padding: 1rem;
  }

  .button-group {
    flex-direction: column;
  }
}

/* -----------------------------------------------------------------------------
   11. Pantalla de Inicio de Sesión (Login) y Estado de Usuario
   ----------------------------------------------------------------------------- */
.login-wrapper {
  max-width: 440px;
  margin: 3rem auto;
  padding: 0 1rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.2rem 2rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.login-header {
  text-align: center;
  margin-bottom: 1.8rem;
}

.login-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.login-header p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

.password-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.password-toggle-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  padding: 0.2rem;
}

