:root {
  /* Variables del diseño ACTUAL */
  --bg-deep: #050505;
  --bg-card: #0f0f12;
  --bg-input: #16161a;
  --primary: #FF5E57;
  --primary-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --text-main: #ffffff;
  --text-muted: #80808a;
  --border: #222226;
  --radius: 12px;
  --font-main: 'Inter', sans-serif;
}

/* =========================================
   1. RESET & BÁSICOS
   ========================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-deep);
  color: var(--text-main);
  overflow-x: hidden;
  line-height: 1.5;
}

a {
  text-decoration: none;
  color: inherit;
  transition: 0.2s;
}

ul {
  list-style: none;
}

button {
  font-family: var(--font-main);
  cursor: pointer;
  border: none;
  outline: none;
  transition: 0.2s;
}

input,
select {
  font-family: var(--font-main);
  outline: none;
}

.page-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 15px;
  min-height: 70vh;
}

/* =========================================
   2. UI ESPECÍFICA DE LA PÁGINA "LISTAS"
   ========================================= */

/* Aviso Info */
.aviso {
  background-color: rgba(59, 130, 246, 0.05);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 15px 20px;
  border-radius: var(--radius);
  margin-bottom: 30px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Contenedor principal de controles (Dropdown, Select, Nuevo) */
.listas-container {
  display: flex;
  align-items: center;
  gap: 15px;
  background-color: var(--bg-card);
  padding: 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* Select de Listas */
.custom-select {
  flex-grow: 1;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  appearance: auto;
  /* Muestra la flecha nativa */
}

.custom-select:focus {
  border-color: var(--primary);
}

/* Botones Generales */
.btn-primary {
  background-color: var(--primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
}

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

.btn-secondary {
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.botones-extra {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
}

/* Menú Dropdown (Opciones) */
.menu-opciones-container {
  position: relative;
}

.vertical-dots {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 15px;
  font-size: 1.2rem;
  font-weight: bold;
}

.vertical-dots:hover {
  background: var(--border);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);
  min-width: 180px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.dropdown-menu button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text-muted);
  padding: 10px;
  border-radius: 6px;
  font-size: 0.9rem;
}

.dropdown-menu button:hover {
  background: var(--bg-input);
  color: var(--text-main);
}

.dropdown-menu button.text-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* =========================================
   3. TÍTULOS DE SECCIÓN
   ========================================= */
.section-title {
  font-size: clamp(20px, 4vw, 24px);
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.section-title::before {
  content: '';
  display: block;
  width: 4px;
  height: 24px;
  background: var(--primary);
  border-radius: 4px;
  box-shadow: 0 0 10px var(--primary);
}

.section-title.title-small {
  font-size: 1.2rem;
  margin-top: 20px;
}

/* =========================================
   4. GRID PRINCIPAL (Mangas de la lista)
   ========================================= */
.manga-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-bottom: 40px;
}

.manga-item {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  position: relative;
  transition: transform 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
}

.manga-item:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.5);
}

.manga-image-container {
  position: relative;
  width: 100%;
  aspect-ratio: 2/3;
  overflow: hidden;
  border-radius: 8px;
  margin-bottom: 12px;
  background: var(--bg-input);
}

.manga-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.manga-item:hover .manga-image-container img {
  transform: scale(1.05);
}

/* Etiquetas generadas por el JS sobre la imagen */
.manga-type {
  position: absolute;
  top: 18px;
  left: 18px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 6px;
  border-radius: 4px;
  color: #fff;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  background-color: #3b82f6;
  /* Default Manga */
}

.manga-type.manhwa {
  background-color: #10b981;
}

.manga-type.manhua {
  background-color: #ef4444;
}

.demography {
  position: absolute;
  bottom: 50px;
  right: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 6px;
  border-radius: 4px;
  color: #fff;
  z-index: 2;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.demography.shounen {
  background-color: #f59e0b;
}

.demography.shoujo {
  background-color: #ec4899;
}

.demography.seinen {
  background-color: #ef4444;
}

.demography.josei {
  background-color: #8b5cf6;
}

/* El título que el JS inyecta dentro de .manga-image-container */
.manga-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 10px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.5) 60%, transparent 100%);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  z-index: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Botón "Quitar" generado por JS */
.delete-manga-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background-color: rgba(239, 68, 68, 0.9);
  color: white;
  border: none;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: bold;
  border-radius: 4px;
  z-index: 10;
  cursor: pointer;
  transition: 0.2s;
}

.delete-manga-btn:hover {
  background-color: var(--danger-hover);
  transform: scale(1.05);
}

/* Información debajo de la imagen */
.manga-info {
  margin-top: auto;
}

.chapter-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--bg-input);
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.chapter-button:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Punto rojo de novedad */
.novelty-circle-inline {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success);
}

/* =========================================
   5. PAGINACIÓN
   ========================================= */
.pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 30px 0;
}

.pagination button {
  background-color: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.pagination button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pagination button.active {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* =========================================
   6. MODALES (Crear Lista / Buscar Manga)
   ========================================= */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.dialog-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 25px;
  width: 100%;
  max-width: 450px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dialog-box h3 {
  margin-bottom: 15px;
  font-size: 1.2rem;
}

/* Modal Crear Lista */
.dialog-box input[type="text"] {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 15px;
}

.dialog-box input[type="text"]:focus {
  border-color: var(--primary);
}

#crear-lista-modal-btn,
#cancel-create-modal-btn {
  width: 48%;
  padding: 10px;
  border-radius: 8px;
  font-weight: 600;
}

#crear-lista-modal-btn {
  background: var(--primary);
  color: white;
  border: none;
}

#cancel-create-modal-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  float: right;
}

/* Modal Búsqueda (Agregar desde Principal) */
.seleccionar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.close-modal-btn {
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  padding: 0 5px;
}

.close-modal-btn:hover {
  color: var(--danger);
}

.manga-list-modal {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 350px;
  overflow-y: auto;
  padding-right: 5px;
}

/* Scrollbar para el modal */
.manga-list-modal::-webkit-scrollbar {
  width: 6px;
}

.manga-list-modal::-webkit-scrollbar-track {
  background: var(--bg-input);
  border-radius: 4px;
}

.manga-list-modal::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.manga-item-select {
  display: flex;
  align-items: center;
  gap: 15px;
  background: var(--bg-input);
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: 0.2s;
}

.manga-item-select:hover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

.manga-thumbnail {
  width: 45px;
  height: 65px;
  object-fit: cover;
  border-radius: 4px;
}

#load-more {
  background: var(--bg-input);
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 10px;
  font-weight: bold;
}

#load-more:hover {
  background: var(--primary);
  color: white;
}

/* =========================================
   7. RESPONSIVE MEDIA QUERIES
   ========================================= */

/* Tablets */
@media (min-width: 640px) {
  .manga-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Laptops */
@media (min-width: 850px) {
  .manga-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .listas-container {
    flex-wrap: nowrap;
  }
}

/* Desktops Large */
@media (min-width: 1024px) {
  .manga-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
  }
}

/* Móviles pequeños */
@media (max-width: 550px) {
  .listas-container {
    flex-direction: column;
    align-items: stretch;
  }

  .menu-opciones-container {
    display: flex;
    width: 100%;
  }

  .vertical-dots {
    width: 100%;
    text-align: center;
  }

  .dropdown-menu {
    width: 100%;
    top: calc(100% + 2px);
  }

  #botones-lista-extra button {
    width: 100%;
  }
}