@import url("https://fonts.googleapis.com/css2?family=Bangers&display=swap");
/* ============================================================
   BIBLIOTECA ESCOLAR — Design System
   Estética: Académica oscura · Tipografía serif · Dorado
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700;900&family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg:         #0d0f14;
  --bg2:        #131720;
  --bg3:        #1a1f2e;
  --card:       #1e2336;
  --border:     #2a3050;
  --gold:       #c9a84c;
  --gold-light: #e8c97a;
  --gold-dim:   rgba(201,168,76,.15);
  --teal:       #3ecfcf;
  --red:        #e05252;
  --green:      #4ade80;
  --text:       #e8e6df;
  --text2:      #9a9db5;
  --text3:      #6b6e85;
  --radius:     12px;
  --radius-lg:  20px;
  --shadow:     0 4px 24px rgba(0,0,0,.45);
  --shadow-gold:0 0 24px rgba(201,168,76,.2);
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ─────────────────────────────────────────────── */
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html { scroll-behavior:smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ── Tipografía ────────────────────────────────────────── */
h1,h2,h3,h4,h5 { font-family:'Playfair Display', serif; font-weight:700; line-height:1.2; }
h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: clamp(1.1rem, 2vw, 1.4rem); }
p  { color: var(--text2); }
a  { color: var(--gold); text-decoration:none; transition: color var(--transition); }
a:hover { color: var(--gold-light); }
code, .mono { font-family:'DM Mono', monospace; font-size:.85em; }

/* ── Layout helpers ────────────────────────────────────── */
.flex      { display:flex; }
.flex-col  { display:flex; flex-direction:column; }
.items-center { align-items:center; }
.justify-between { justify-content:space-between; }
.gap-1  { gap:.5rem; }
.gap-2  { gap:1rem; }
.gap-3  { gap:1.5rem; }
.gap-4  { gap:2rem; }
.w-full { width:100%; }
.hidden { display:none !important; }
.relative { position:relative; }

/* ── Card ──────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover { border-color: var(--gold); box-shadow: var(--shadow-gold); }

/* ── Botones ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1.4rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold), #a07830);
  color: #0d0f14;
}
.btn-primary:hover { filter: brightness(1.15); transform: translateY(-1px); box-shadow: var(--shadow-gold); }
.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }
.btn-danger {
  background: rgba(224,82,82,.15);
  color: var(--red);
  border: 1px solid rgba(224,82,82,.3);
}
.btn-danger:hover { background: rgba(224,82,82,.25); }
.btn-ghost { background:transparent; color:var(--text2); }
.btn-ghost:hover { color: var(--text); background: var(--bg3); }
.btn-sm { padding:.4rem .9rem; font-size:.8rem; }
.btn-lg { padding:.8rem 2rem; font-size:1rem; border-radius: var(--radius-lg); }
.btn:disabled { opacity:.4; cursor:not-allowed; transform:none !important; }
.btn-icon { padding: .5rem; border-radius: 8px; }

/* ── Inputs ────────────────────────────────────────────── */
.input, .select, .textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  padding: .65rem 1rem;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
.input::placeholder { color: var(--text3); }
.select { cursor:pointer; }
.select option { background: var(--bg2); }
.textarea { resize: vertical; min-height: 100px; }
.form-group { display:flex; flex-direction:column; gap:.5rem; }
.form-group label { font-size:.85rem; font-weight:600; color:var(--text2); }
.form-error { font-size:.8rem; color:var(--red); }

/* ── Badge ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .65rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .03em;
}
.badge-gold    { background: var(--gold-dim);       color: var(--gold); }
.badge-teal    { background: rgba(62,207,207,.12);  color: var(--teal); }
.badge-red     { background: rgba(224,82,82,.12);   color: var(--red); }
.badge-green   { background: rgba(74,222,128,.12);  color: var(--green); }
.badge-neutral { background: var(--bg3); color: var(--text2); }

/* ── Table ─────────────────────────────────────────────── */
.table-wrap { overflow-x:auto; border-radius: var(--radius); border:1px solid var(--border); }
table { width:100%; border-collapse:collapse; font-size:.88rem; }
thead th {
  background: var(--bg3);
  color: var(--text2);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .8rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: .8rem 1rem; border-bottom: 1px solid rgba(42,48,80,.5); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(201,168,76,.04); }

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity:1; pointer-events:all; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--transition);
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:1.5rem; }
.modal-title  { font-family:'Playfair Display',serif; font-size:1.3rem; }

/* ── Toast ─────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .8rem 1.2rem;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: .88rem;
  min-width: 280px;
  animation: slideUp .3s ease;
}
.toast-success { border-color: rgba(74,222,128,.4); }
.toast-error   { border-color: rgba(224,82,82,.4); }
.toast-info    { border-color: rgba(201,168,76,.4); }
@keyframes slideUp {
  from { transform: translateY(20px); opacity:0; }
  to   { transform: translateY(0); opacity:1; }
}

/* ── Sidebar layout ─────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-logo-icon {
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.sidebar-logo-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sidebar-logo-text h3 {
  font-size: 1rem;
  font-family:'Playfair Display',serif;
  color: var(--gold);
}
.sidebar-logo-text span { font-size:.7rem; color:var(--text3); }

.nav-section { padding: 1rem; }
.nav-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text3);
  padding: .5rem .5rem .3rem;
  display: block;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .8rem;
  border-radius: 10px;
  color: var(--text2);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  margin-bottom: .15rem;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: var(--gold-dim);
  color: var(--gold);
  border: 1px solid rgba(201,168,76,.25);
}
.nav-item .nav-icon { font-size: 1rem; width: 20px; text-align:center; }

.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid var(--border);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem;
  border-radius: 10px;
  background: var(--bg3);
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gold-dim);
  border: 2px solid var(--gold);
  display: grid;
  place-items: center;
  font-size: .85rem;
  font-weight: 700;
  color: var(--gold);
  flex-shrink: 0;
  overflow: hidden;
}
.user-avatar img { width:100%; height:100%; object-fit:cover; }
.user-info .name { font-size: .83rem; font-weight: 600; }
.user-info .role { font-size: .72rem; color: var(--text3); }

/* ── Main content ───────────────────────────────────────── */
.main-content { overflow-y:auto; }
.page-header {
  padding: 2rem 2rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to right, var(--bg2), transparent);
}
.page-header h1 { font-size: 1.6rem; }
.page-body { padding: 2rem; }

/* ── Stat cards ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  transition: all var(--transition);
}
.stat-card:hover { border-color:var(--gold); transform:translateY(-2px); }
.stat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  margin-bottom: .2rem;
}
.stat-value { font-size: 2rem; font-weight: 700; font-family:'Playfair Display',serif; }
.stat-label { font-size: .78rem; color: var(--text3); font-weight: 500; }

/* ── Book card ──────────────────────────────────────────── */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}
.book-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.book-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-gold); border-color: var(--gold); }
.book-cover {
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.book-cover-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  gap: .4rem;
  width: 100%;
}
.book-cover-icon {
  font-size: 2rem;
  opacity: .85;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.4));
}
.book-cover-title {
  font-size: .78rem;
  font-weight: 700;
  color: rgba(255,255,255,.92);
  line-height: 1.3;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
  word-break: break-word;
}
.book-cover-author {
  font-size: .68rem;
  color: rgba(255,255,255,.7);
  font-style: italic;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.book-cover-placeholder {
  font-size: 3rem;
  opacity: .3;
}
.book-cat-badge {
  position: absolute;
  top: .5rem;
  left: .5rem;
  padding: .2rem .55rem;
  border-radius: 6px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.book-fav-btn {
  position: absolute;
  top: .5rem;
  right: .5rem;
  background: rgba(13,15,20,.7);
  border: none;
  border-radius: 8px;
  width: 30px; height: 30px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: .85rem;
  transition: all var(--transition);
  color: var(--text2);
}
.book-fav-btn:hover, .book-fav-btn.active { color: var(--gold); }
.book-info { padding: .9rem; }
.book-title { font-size: .9rem; font-weight: 600; color: var(--text); margin-bottom: .2rem; line-height:1.3; }
.book-author { font-size: .78rem; color: var(--text3); }
.book-pages  { font-size: .72rem; color: var(--text3); margin-top: .4rem; }

/* ── Encuesta card ──────────────────────────────────────── */
.survey-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: all var(--transition);
}
.survey-card:hover { border-color: var(--gold); }

/* ── Loader ─────────────────────────────────────────────── */
.loader {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center {
  display: flex; align-items: center; justify-content: center;
  padding: 4rem;
  flex-direction: column; gap: 1rem;
  color: var(--text3);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0; bottom: 0;
    z-index: 500;
    transition: left .3s ease;
    height: 100%;
    width: 260px;
    overflow-y: auto;
  }
  .sidebar.open { left: 0; box-shadow: 4px 0 24px rgba(0,0,0,.5); }
  .mobile-toggle {
    display: flex;
    position: fixed;
    top: .75rem; left: .75rem;
    z-index: 501;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .45rem .6rem;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text);
    align-items: center;
    gap: .3rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
  }
  .main-content { padding: 0; min-height: 100vh; }
  .page-header { padding: 1rem 1rem 0.5rem; padding-top: 3.5rem; }
  .page-body { padding: .75rem 1rem 2rem; }
  .page-header h1 { font-size: 1.3rem; }
  .page-header p { font-size: .82rem; }

  /* Books grid responsive */
  .books-grid { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .book-cover { height: 160px; }
  .book-cover-icon { font-size: 1.5rem; }
  .book-cover-title { font-size: .7rem; }
  .book-info { padding: .6rem; }
  .book-title { font-size: .85rem; }
  .book-author { font-size: .75rem; }

  /* Cards y grids */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
  .cards-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .filters-bar { flex-wrap: wrap; gap: .5rem; }
  .filters-bar .input, .filters-bar select { width: 100%; }

  /* Tablas responsive */
  .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Sudoku en móvil */
  .sudoku-container { max-width: 100%; }
  .sudoku-cell { font-size: .75rem; }
  .sudoku-numpad button { width: 32px; height: 32px; font-size: .85rem; }

  /* Modals */
  .modal-content { margin: .5rem; width: calc(100% - 1rem); max-height: 92vh; }

  /* Overlapping sidebar close area */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 499;
  }
  .sidebar.open ~ .sidebar-overlay { display: block; }
}
@media (max-width: 480px) {
  .books-grid { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
  .book-cover { height: 140px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header h1 { font-size: 1.15rem; }
  .btn { font-size: .82rem; padding: .4rem .8rem; }
}
@media (min-width: 769px) { .mobile-toggle { display:none; } }

/* ── Divider ─────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text3);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity:.4; }
.empty-state h3 { font-family:'DM Sans',sans-serif; font-weight:600; color:var(--text2); }
.empty-state p  { font-size:.88rem; }

/* ── Progress bar ────────────────────────────────────────── */
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(to right, var(--gold), var(--gold-light));
  border-radius: 2px;
  transition: width .5s ease;
}

/* ── PDF Viewer ──────────────────────────────────────────── */
.pdf-viewer-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg);
}
.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1.5rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.pdf-toolbar .page-input {
  width: 55px;
  padding: .3rem .5rem;
  text-align: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: .85rem;
}
#pdf-canvas-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1.5rem;
  background: #1a1a2e;
}
#pdf-canvas {
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  border-radius: 4px;
  max-width: 100%;
}

/* ── CreativePixeLamb brand watermark ─────────────────────── */
body::after {
  content: 'CreativePixeLamb';
  position: fixed;
  bottom: .75rem;
  right: 1rem;
  font-size: .58rem;
  color: var(--text3);
  letter-spacing: .1em;
  text-transform: uppercase;
  pointer-events: none;
  z-index: 9999;
  opacity: .5;
  font-family: 'DM Sans', sans-serif;
}

/* ═══════════════════════════════════════════════════════════
   BORDERLANDS THEME — Cel-shaded Comic Style (v20)
   ═══════════════════════════════════════════════════════════ */
:root {
  --font-heading: inherit;
  --border-width: 1px;
  --border-style: solid;
  --shadow-comic: none;
  --radius-override: unset;
}

/* Apply heading font from theme (all themes may set --font-heading) */
h1, h2, h3, .page-header h1, .modal-title, .section-title h3 {
  font-family: var(--font-heading, 'Playfair Display', serif);
}

/* Supervisor badge */
.badge-supervisor {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  font-weight: 700;
  padding: .15rem .6rem;
  border-radius: 999px;
  font-size: .7rem;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}
.badge-supervisor::before { content: '🛡️'; }
