/* ==========================================================================
   VISOR DE LIBROS DE AVIACIÓN - DISEÑO ADAPTADO A IPAD 10 (HORIZONTAL Y VERTICAL)
   ========================================================================== */

:root {
  /* Paleta Light (Día) */
  --bg-primary: #f8f9fa;
  --bg-surface: #ffffff;
  --bg-sidebar: #ededf0;
  --text-main: #1c1d1f;
  --text-muted: #5c6066;
  --accent-color: #0055b8;
  --border-color: #e2e4e8;
  --card-bg: #f1f4f8;

  /* Tipografía y Espaciado de Lectura */
  --font-reading: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Georgia", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  --line-height-book: 1.75;
  --max-reading-width: 760px;
}

/* Modo Sepia */
[data-theme="sepia"] {
  --bg-primary: #f4ebd9;
  --bg-surface: #fbf0d9;
  --bg-sidebar: #e9deb9;
  --text-main: #3b3226;
  --text-muted: #726553;
  --accent-color: #8c4a00;
  --border-color: #e0d1b1;
  --card-bg: #eee0c5;
}

/* Modo Oscuro */
[data-theme="dark"] {
  --bg-primary: #121315;
  --bg-surface: #1c1e22;
  --bg-sidebar: #16181c;
  --text-main: #e1e4e8;
  --text-muted: #9da5b4;
  --accent-color: #4d9fff;
  --border-color: #2d3139;
  --card-bg: #252830;
}

/* Escalado de Fuente */
[data-font-size="small"]  { --font-base: 16px; }
[data-font-size="medium"] { --font-base: 19px; }
[data-font-size="large"]  { --font-base: 22px; }
[data-font-size="xlarge"] { --font-base: 25px; }

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-reading);
  font-size: var(--font-base);
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ==========================================================================
   BARRA SUPERIOR (HEADER)
   ========================================================================== */
.top-bar {
  height: 60px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 20;
  flex-shrink: 0;
}

.bar-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.book-title {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-main);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
}

.reading-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-ctrl {
  font-family: var(--font-ui);
  font-weight: 600;
  background-color: var(--card-bg);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 14px;
  min-height: 40px;
  cursor: pointer;
}

.theme-selector {
  display: flex;
  gap: 8px;
  background-color: var(--card-bg);
  padding: 4px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.theme-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}

.theme-light { background-color: #ffffff; border-color: #ccc; }
.theme-sepia { background-color: #f4ebd9; border-color: #d8c8a8; }
.theme-dark  { background-color: #1c1e22; border-color: #444; }

/* ==========================================================================
   ESTRUCTURA PRINCIPAL Y SIDEBAR
   ========================================================================== */
.main-body {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
}

.sidebar {
  width: 320px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-header h2 {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Desplegable de Selección de Libro */
.book-dropdown {
  width: 100%;
  padding: 10px 36px 10px 12px;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.book-dropdown:focus {
  border-color: var(--accent-color);
}

.book-dropdown option {
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-weight: 500;
}

.chapter-nav {
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 16px 20px;
  border: none;
  background: none;
  color: var(--text-main);
  text-align: left;
  font-family: var(--font-ui);
  cursor: pointer;
  border-left: 4px solid transparent;
  transition: background-color 0.2s;
}

.nav-item:active, .nav-item.active {
  background-color: var(--bg-surface);
  border-left-color: var(--accent-color);
}

.nav-item .cap-num {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-color);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.nav-item .cap-title {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.3;
}

.sidebar-overlay {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 90;
}

/* Mensajes de estado vacío */
.empty-msg {
  font-family: var(--font-ui);
  color: var(--text-muted);
  text-align: center;
  margin-top: 50px;
  font-size: 1.1rem;
}

/* ==========================================================================
   CANVAS DE LECTURA (LIBRO)
   ========================================================================== */
.content-container {
  flex: 1;
  overflow-y: auto;
  padding: 40px 20px;
  display: flex;
  justify-content: center;
  -webkit-overflow-scrolling: touch;
}

.reading-canvas {
  width: 100%;
  max-width: var(--max-reading-width);
  line-height: var(--line-height-book);
  padding-bottom: 80px;
}

/* Estilos de contenido tipográfico del libro */
.reading-canvas h1.book-chapter-title {
  font-family: var(--font-ui);
  font-size: 2.2em;
  font-weight: 800;
  margin-bottom: 25px;
  line-height: 1.2;
  color: var(--text-main);
  border-bottom: 2px solid var(--accent-color);
  padding-bottom: 15px;
}

.reading-canvas h2 {
  font-family: var(--font-ui);
  font-size: 1.5em;
  font-weight: 700;
  margin: 40px 0 18px 0;
  color: var(--accent-color);
}

.reading-canvas h3 {
  font-family: var(--font-ui);
  font-size: 1.2em;
  font-weight: 600;
  margin: 25px 0 12px 0;
  color: var(--text-main);
}

.reading-canvas p {
  margin-bottom: 20px;
  text-align: justify;
  hyphens: auto;
}

.reading-canvas ul, .reading-canvas ol {
  margin: 0 0 25px 25px;
}

.reading-canvas li {
  margin-bottom: 12px;
}

/* Tarjetas para Fórmulas / Datos Numéricos / Destacados */
.info-card {
  background-color: var(--card-bg);
  border-left: 4px solid var(--accent-color);
  border-radius: 0 12px 12px 0;
  padding: 18px 22px;
  margin: 25px 0;
}

.info-card h4 {
  font-family: var(--font-ui);
  margin-bottom: 8px;
  color: var(--accent-color);
}

.step-list {
  list-style: none;
  counter-reset: step-counter;
  padding-left: 0 !important;
}

.step-list li {
  counter-increment: step-counter;
  position: relative;
  padding-left: 45px;
  margin-bottom: 18px;
}

.step-list li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 2px;
  width: 30px;
  height: 30px;
  background-color: var(--accent-color);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 0.85em;
  font-weight: 700;
}

.acronym-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin: 25px 0;
}

.acronym-item {
  background-color: var(--card-bg);
  padding: 10px 15px;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 0.9em;
}

.acronym-item strong {
  color: var(--accent-color);
}

/* ==========================================================================
   MEDIA QUERIES ESPECÍFICAS PARA IPAD 10 (VERTICAL Y HORIZONTAL)
   ========================================================================== */

/* iPad 10 Horizontal (Landscape ~1024px+ ancho) */
@media screen and (min-width: 1024px) and (orientation: landscape) {
  .sidebar {
    position: relative;
    transform: none !important;
  }
  .btn-icon#toggle-sidebar {
    display: none;
  }
  .content-container {
    padding: 50px 60px;
  }
}

/* iPad 10 Vertical (Portrait ~820px ancho) y pantallas menores */
@media screen and (max-width: 1023px) {
  .sidebar {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    transform: translateX(-100%);
    box-shadow: 4px 0 15px rgba(0,0,0,0.15);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.show {
    display: block;
  }
  .content-container {
    padding: 30px 24px;
  }
}