/* ==========================================================================
   VISOR Y LECTOR DE LIBROS ELECTRÓNICOS - FIJATE TOOLS
   Estilos Principales, Biblioteca y Sistema de Diseño
   ========================================================================== */

:root {
  --bg-app: #0d1117;
  --bg-card: rgba(22, 27, 34, 0.85);
  --bg-card-hover: rgba(33, 38, 45, 0.95);
  --border-color: rgba(240, 246, 252, 0.1);
  --border-color-hover: rgba(240, 246, 252, 0.25);
  
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.25);

  --accent-purple: #8b5cf6;
  --accent-amber: #f59e0b;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-app-theme="light"] {
  --bg-app: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: #ffffff;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-color-hover: rgba(0, 0, 0, 0.18);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ==========================================================================
   CABECERA PRINCIPAL
   ========================================================================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
}

[data-app-theme="light"] .app-header {
  background: rgba(248, 250, 252, 0.85);
}

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

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-text h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-text span {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.btn-back-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.btn-back-tools:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-color-hover);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.privacy-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #34d399;
  font-size: 0.78rem;
  font-weight: 600;
}

/* Botones universales */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-color-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
}

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

/* ==========================================================================
   VISTA DE BIBLIOTECA (SHELF VIEW)
   ========================================================================== */

.library-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  width: 100%;
}

.library-hero {
  text-align: center;
  margin-bottom: 2.5rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.9rem;
  border-radius: 9999px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: #60a5fa;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero-title {
  font-family: 'Outfit', sans-serif;
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-app-theme="light"] .hero-title {
  background: linear-gradient(135deg, #0f172a, #334155);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 680px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Zona de Carga / Drag & Drop */
.dropzone {
  border: 2px dashed var(--border-color-hover);
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  margin-bottom: 3rem;
  position: relative;
  overflow: hidden;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary-color);
  background: rgba(59, 130, 246, 0.05);
  transform: translateY(-2px);
}

.dropzone-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.2rem;
}

.dropzone-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.dropzone-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.dropzone-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Barra de herramientas de biblioteca (Buscador, filtro y contador) */
.shelf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.shelf-title-group {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.shelf-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
}

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

.shelf-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.shelf-search-input {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  outline: none;
  width: 240px;
  transition: border-color var(--transition-fast);
}

.shelf-search-input:focus {
  border-color: var(--primary-color);
}

.btn-kindle-export {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.btn-kindle-export svg {
  color: var(--accent-amber);
}

/* Cuadrícula de libros (Estantería digital) */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.75rem;
}

.book-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-normal);
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.book-card:hover {
  transform: translateY(-6px);
  border-color: var(--border-color-hover);
  box-shadow: var(--shadow-md);
}

.book-cover-wrapper {
  position: relative;
  aspect-ratio: 1 / 1.45;
  background: #181d26;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.book-card:hover .book-cover-img {
  transform: scale(1.04);
}

.book-cover-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  text-align: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1e293b, #0f172a);
}

.book-cover-placeholder svg {
  color: var(--primary-color);
  margin-bottom: 0.75rem;
}

.book-cover-placeholder .placeholder-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
  color: #f1f5f9;
}

.book-cover-placeholder .placeholder-author {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 0.4rem;
}

/* Distintivos en la portada */
.book-format-badge {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.book-sample-badge {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.9);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* Barra de progreso sobre la portada */
.book-progress-bar-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: rgba(0, 0, 0, 0.4);
}

.book-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  transition: width 0.3s ease;
}

/* Información inferior de la tarjeta */
.book-info-panel {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.book-title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-author {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-meta-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.book-card-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.book-card:hover .book-card-actions {
  opacity: 1;
}

.book-action-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.book-action-btn.btn-kindle-book:hover {
  color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.12);
}

.book-action-btn.btn-delete-book:hover {
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.12);
}

/* Estado Vacío de Biblioteca */
.empty-library {
  text-align: center;
  padding: 3rem 1rem;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-xl);
}

.empty-library svg {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.empty-library h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.empty-library p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

/* Responsividad */
@media (max-width: 768px) {
  .hero-title {
    font-size: 1.85rem;
  }
  .books-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
  .shelf-search-input {
    width: 100%;
  }
  .shelf-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}
