/* =========================================================================
   BIBLIOTECA DE NEGOCIOS — estilos
   Estética: limpia y aireada (tipo Apple Books) + color en portadas/infografías
   ========================================================================= */

:root {
  --bg: #ffffff;
  --bg-side: #f7f7f9;
  --ink: #1a1c22;
  --ink-soft: #5b6472;
  --line: #e9ebf0;
  --shadow: 0 10px 30px rgba(20, 24, 40, 0.10);
  --shadow-book: 0 14px 28px rgba(20, 24, 40, 0.18);
  --radius: 16px;
  --sidebar-w: 264px;
}

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; min-height: 100vh; }

/* ===================== Sidebar ===================== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { color: #7C5CFC; font-size: 18px; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.2px; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; margin-bottom: 18px;
}
.search-box:focus-within { border-color: #c9cdfa; box-shadow: 0 0 0 3px rgba(124,92,252,0.12); }
.search-ico { width: 16px; height: 16px; color: #9aa1ad; flex-shrink: 0; }
.search-box input { border: none; outline: none; font-size: 14px; width: 100%; background: transparent; color: var(--ink); }

.nav { flex: 1; overflow-y: auto; }
.nav-section {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px;
  color: #9aa1ad; font-weight: 600; margin: 16px 10px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; cursor: pointer;
  padding: 9px 10px; border-radius: 9px; font-size: 14px;
  color: var(--ink-soft); font-family: inherit; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: #eeeff3; }
.nav-item.active { background: #ececff; color: #1a1c22; font-weight: 600; }
.nav-item .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.nav-item .count { margin-left: auto; font-size: 12px; color: #a4abb6; }

.user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid var(--line); margin-top: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #2a2d3a; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.3; }
.user-meta strong { font-size: 13px; }
.user-meta span { font-size: 12px; color: #9aa1ad; }

/* ===================== Contenido ===================== */
.content { flex: 1; min-width: 0; }
.view { padding: 40px 48px 80px; max-width: 1180px; }

.lib-head { margin-bottom: 28px; }
#lib-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 52px; font-weight: 700; letter-spacing: -1px; line-height: 1;
}
.lib-sub { color: var(--ink-soft); font-size: 15px; margin-top: 10px; }

/* ===================== Estantería ===================== */
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 40px 30px;
}
.book { cursor: pointer; }
.book-cover {
  position: relative; aspect-ratio: 300 / 450; border-radius: 4px 8px 8px 4px;
  overflow: hidden; box-shadow: var(--shadow-book);
  border-left: 3px solid rgba(0,0,0,0.14);
  transition: transform 0.22s cubic-bezier(.2,.7,.2,1), box-shadow 0.22s;
}
.book-cover svg { width: 100%; height: 100%; display: block; }
.book:hover .book-cover { transform: translateY(-6px) rotate(-0.6deg); box-shadow: 0 22px 40px rgba(20,24,40,0.26); }
.book-cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, rgba(255,255,255,0.28), transparent 42%); pointer-events: none; }

.book-meta { padding: 12px 2px 0; }
.book-title { font-size: 14px; font-weight: 600; line-height: 1.25; }
.book-author { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }
.progress { height: 3px; background: #e7e9ef; border-radius: 2px; margin-top: 9px; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 2px; }

.cat-group { margin-bottom: 44px; }
.cat-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.cat-group-head .dot { width: 11px; height: 11px; border-radius: 50%; }
.cat-group-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.cat-group-head .n { font-size: 13px; color: #9aa1ad; }

.empty { color: var(--ink-soft); font-size: 15px; padding: 40px 0; }

/* ===================== Detalle ===================== */
.back-btn {
  display: inline-flex; align-items: center; gap: 7px; background: none; border: none;
  color: var(--ink-soft); font-size: 14px; cursor: pointer; font-family: inherit;
  padding: 6px 0; margin-bottom: 24px;
}
.back-btn:hover { color: var(--ink); }

.detail-hero { display: flex; gap: 40px; align-items: flex-start; margin-bottom: 44px; }
.detail-hero .hero-cover { width: 220px; flex-shrink: 0; border-radius: 4px 10px 10px 4px; overflow: hidden; box-shadow: var(--shadow-book); border-left: 4px solid rgba(0,0,0,0.14); }
.detail-hero .hero-cover svg { width: 100%; display: block; }
.hero-info { padding-top: 8px; }
.cat-tag {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600;
  padding: 5px 12px; border-radius: 100px; margin-bottom: 16px;
}
.cat-tag .dot { width: 8px; height: 8px; border-radius: 50%; }
.hero-info h1 { font-family: "Fraunces", Georgia, serif; font-size: 40px; font-weight: 700; letter-spacing: -0.8px; line-height: 1.05; }
.hero-info .subtitle { color: var(--ink-soft); font-size: 16px; margin-top: 8px; }
.hero-info .author { font-size: 14.5px; margin-top: 14px; font-weight: 500; }
.hero-info .meta-row { display: flex; gap: 18px; margin-top: 14px; font-size: 13px; color: var(--ink-soft); }
.hero-hook {
  font-family: "Fraunces", Georgia, serif; font-size: 21px; font-style: italic; line-height: 1.4;
  margin-top: 22px; padding-left: 18px; border-left: 3px solid;
}

.section { margin-bottom: 46px; }
.section > h3 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: #9aa1ad;
  font-weight: 700; margin-bottom: 18px; display: flex; align-items: center; gap: 10px;
}
.section > h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.summary-text { font-size: 16.5px; line-height: 1.7; color: #2c3038; max-width: 760px; }

/* Ideas clave */
.ideas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.idea-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 20px;
  transition: transform 0.15s, box-shadow 0.15s; border-top: 3px solid;
}
.idea-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.idea-card .ico { font-size: 24px; }
.idea-card h4 { font-size: 15.5px; margin: 12px 0 8px; }
.idea-card p { font-size: 14px; color: var(--ink-soft); line-height: 1.55; }

/* Infografía */
.infobox { background: #fafbfc; border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.info-svg { width: 100%; height: auto; }
.info-caption { font-size: 14px; color: var(--ink-soft); line-height: 1.6; margin-top: 18px; text-align: center; max-width: 640px; margin-left: auto; margin-right: auto; }

/* ERAC grid */
.errc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.errc-cell { border: 2px solid var(--c); border-radius: 12px; padding: 18px; background: color-mix(in srgb, var(--c) 6%, #fff); }
.errc-verb { display: block; font-weight: 700; font-size: 17px; color: var(--c); margin-bottom: 8px; }
.errc-q { font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; }

/* Escalas Culture Map */
.scales { display: flex; flex-direction: column; gap: 16px; }
.scale-row { display: grid; grid-template-columns: 130px 1fr; grid-template-rows: auto auto; column-gap: 16px; align-items: center; }
.scale-name { font-size: 14px; font-weight: 600; grid-row: 1 / 3; }
.scale-track { position: relative; height: 6px; background: #e7e9ef; border-radius: 3px; }
.scale-dot { position: absolute; top: 50%; width: 15px; height: 15px; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.scale-ends { display: flex; justify-content: space-between; font-size: 11.5px; color: #9aa1ad; margin-top: 4px; }
.scale-ends em { font-style: normal; }

/* Comparación bad/good (p.ej. The Mom Test) */
.compare-grid { display: flex; gap: 16px; flex-wrap: wrap; }
.compare-col { flex: 1; min-width: 220px; border-radius: 12px; padding: 16px 18px; border: 1.5px solid var(--line); background: #fafbfc; }
.compare-col.bad { border-color: #e2b8b8; background: #fdf4f4; }
.compare-col.good { border-color: currentColor; }
.compare-label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 10px; }
.compare-col.bad .compare-label { color: #c0392b; }
.compare-list { list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; color: #4a5261; }
.compare-list li::before { content: "— "; color: #9aa1ad; }
.compare-note { margin-top: 14px; padding: 12px 16px; border-left: 3px solid currentColor; background: #fafbfc; border-radius: 8px; font-size: 13.5px; color: #4a5261; }

/* Listas accionables / ejemplos / frases */
.action-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.action-list li { display: flex; gap: 12px; font-size: 15px; line-height: 1.55; }
.action-list li::before { content: "→"; color: #7C5CFC; font-weight: 700; flex-shrink: 0; }

.examples { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.example { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.example .co { font-weight: 700; font-size: 15px; margin-bottom: 7px; }
.example p { font-size: 14px; color: var(--ink-soft); line-height: 1.55; }

.quotes { display: flex; flex-direction: column; gap: 16px; }
.quote { font-family: "Fraunces", Georgia, serif; font-size: 20px; font-style: italic; line-height: 1.45; padding-left: 20px; border-left: 3px solid; color: #23262e; }

/* Léelo junto a — cruces entre películas y libros */
.related-row { display: flex; flex-wrap: wrap; gap: 14px; }
.related-chip { display: flex; align-items: center; gap: 14px; text-decoration: none; cursor: pointer;
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 18px 12px 12px; background: #fff;
  transition: border-color 0.15s, transform 0.15s; min-width: 220px; }
.related-chip:hover { border-color: #c9cdfa; transform: translateY(-2px); }
.related-mini { width: 40px; flex-shrink: 0; border-radius: 3px; overflow: hidden; box-shadow: 0 3px 8px rgba(20,24,40,0.18); line-height: 0; }
.related-mini svg { width: 100%; display: block; }
.related-meta { display: flex; flex-direction: column; }
.related-meta strong { font-size: 14.5px; color: var(--ink); }
.related-meta em { font-style: normal; font-size: 12.5px; font-weight: 600; margin-top: 2px; }

.class-use { background: #fffdf5; border: 1px solid #f2e9c9; border-radius: 14px; padding: 20px 22px; display: flex; gap: 14px; }
.class-use .ico { font-size: 22px; }
.class-use p { font-size: 15px; line-height: 1.6; }
.class-use strong { display: block; margin-bottom: 4px; }

.links-row { display: flex; flex-wrap: wrap; gap: 12px; }
.link-chip {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 16px;
  font-size: 14px; color: var(--ink); background: #fff; transition: border-color 0.15s, transform 0.15s;
}
.link-chip:hover { border-color: #c9cdfa; transform: translateY(-2px); }
.link-chip::after { content: "↗"; color: #9aa1ad; }

/* ===================== Asistente IA ===================== */
.ai-fab {
  position: fixed; right: 26px; bottom: 26px; width: 58px; height: 58px; border-radius: 50%;
  border: none; cursor: pointer; font-size: 24px;
  background: linear-gradient(135deg, #7C5CFC, #a855f7); color: #fff;
  box-shadow: 0 10px 26px rgba(124,92,252,0.45); transition: transform 0.18s; z-index: 50;
}
.ai-fab:hover { transform: scale(1.06); }

.ai-panel[hidden] { display: none; }
.ai-panel {
  position: fixed; right: 26px; bottom: 96px; width: 380px; max-height: 70vh;
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; z-index: 50;
}
.ai-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 15px; }
.ai-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #9aa1ad; line-height: 1; }
.ai-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.ai-msg { font-size: 14px; line-height: 1.55; padding: 12px 14px; border-radius: 12px; max-width: 90%; }
.ai-msg.bot { background: #f3f2fb; color: #23262e; align-self: flex-start; border-bottom-left-radius: 4px; }
.ai-msg.user { background: #7C5CFC; color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.ai-msg .src { display: block; margin-top: 8px; font-size: 12px; color: #7C5CFC; font-weight: 600; }
.ai-msg.bot .demo-note { display:block; margin-top:8px; font-size:11.5px; color:#9aa1ad; }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 12px; }
.ai-chip { font-size: 12.5px; border: 1px solid var(--line); background: #fff; border-radius: 100px; padding: 7px 12px; cursor: pointer; color: var(--ink-soft); font-family: inherit; }
.ai-chip:hover { border-color: #c9cdfa; color: var(--ink); }
.ai-form { display: flex; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--line); }
.ai-form input { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; outline: none; font-family: inherit; }
.ai-form input:focus { border-color: #c9cdfa; }
.ai-form button { width: 40px; border: none; border-radius: 10px; background: #7C5CFC; color: #fff; font-size: 17px; cursor: pointer; }

/* ===================== Barra móvil (buscador + chips) ===================== */
.mbar { display: none; }

/* ===================== Responsive ===================== */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .view { padding: 28px 22px 80px; }
  #library.view { padding-top: 0; }
  .mbar {
    display: block; position: sticky; top: 0; z-index: 40;
    margin: 0 -22px 20px; padding: calc(12px + env(safe-area-inset-top)) 22px 10px;
    background: rgba(255,255,255,0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
  }
  .mbar .search-box { margin-bottom: 10px; background: var(--bg-side); padding: 11px 14px; }
  .mbar .search-box input { font-size: 16px; } /* 16px evita el zoom automático de iOS al enfocar */
  .chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -22px; padding: 2px 22px 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .chips::-webkit-scrollbar { display: none; }
  .chip {
    display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0; white-space: nowrap;
    border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
    border-radius: 100px; padding: 8px 14px; font-size: 13.5px; font-family: inherit; cursor: pointer;
    min-height: 36px;
  }
  .chip .dot { width: 8px; height: 8px; border-radius: 50%; }
  .chip.active { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
  .lib-head { margin-bottom: 22px; }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 28px 18px; }
  .cat-group { margin-bottom: 32px; }
  .detail-hero { flex-direction: column; }
  .detail-hero .hero-cover { width: 150px; }
  #lib-title { font-size: 40px; }
  .ai-panel { width: calc(100vw - 32px); right: 16px; }
}

.fade-in { animation: fade 0.35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Acceso destacado a la presentación visual de un libro (visual/<id>/) */
.visual-cta{display:flex;align-items:center;gap:14px;margin-top:20px;padding:14px 18px;border-radius:14px;background:var(--c,#111);color:#fff;text-decoration:none;box-shadow:0 10px 26px rgba(20,20,40,.22);transition:transform .2s,box-shadow .2s;max-width:460px}
.visual-cta:hover{transform:translateY(-2px);box-shadow:0 14px 30px rgba(20,20,40,.28)}
.visual-cta .vc-ico{flex:none;width:38px;height:38px;border-radius:50%;background:rgba(255,255,255,.22);display:grid;place-items:center;font-size:14px;padding-left:2px}
.visual-cta strong{display:block;font-size:16px;line-height:1.25}
.visual-cta em{display:block;font-style:normal;font-size:13px;opacity:.85;margin-top:2px}
.visual-cta .vc-arrow{margin-left:auto;font-size:20px}
.book-visual{display:inline-block;margin-top:5px;font-size:11px;font-weight:700;letter-spacing:.04em;color:#0f766e;background:#ccfbf1;border-radius:999px;padding:2px 8px}
@media (pointer:coarse){.visual-cta{min-height:56px}}
