/* =========================================================
   Album Fotografico Digital - Hoja de estilos
   Paleta: papel crema, tinta carbon, cuero marron, dorado
   ========================================================= */
:root {
  --paper: #f4efe4;
  --paper-2: #faf7f0;
  --ink: #2a2620;
  --ink-soft: #6b6357;
  --leather: #3d2f24;
  --leather-2: #4d3b2c;
  --gold: #c19a5b;
  --gold-dark: #a67f42;
  --line: #e0d8c6;
  --danger: #a23b2d;
  --success: #3f6b4a;
  --shadow: 0 10px 30px rgba(42, 38, 32, 0.18);
  --radius: 12px;
  --font-serif: Georgia, "Times New Roman", serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(193, 154, 91, 0.10), transparent 40%),
    var(--paper);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--gold-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--font-serif); font-weight: 700; line-height: 1.25; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }

.site-header {
  background: var(--leather);
  color: var(--paper);
  border-bottom: 3px solid var(--gold);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 16px; padding-bottom: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-serif); font-size: 1.4rem; font-weight: 700;
  color: var(--paper);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--gold); color: var(--leather);
  display: grid; place-items: center; font-size: 1.1rem;
}
.nav { display: flex; align-items: center; gap: 18px; }
.nav a { color: var(--paper); opacity: 0.9; font-size: 0.95rem; }
.nav a:hover { opacity: 1; }
.nav .user-name { opacity: 0.8; font-size: 0.9rem; }

.site-footer {
  margin-top: 60px; padding: 28px 0;
  text-align: center; color: var(--ink-soft); font-size: 0.85rem;
  border-top: 1px solid var(--line);
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer;
  font-size: 0.95rem; font-weight: 600; font-family: var(--font-sans);
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--gold); color: var(--leather); }
.btn-primary:hover { background: var(--gold-dark); color: #fff; }
.btn-dark { background: var(--leather); color: var(--paper); }
.btn-dark:hover { background: var(--leather-2); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--paper-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Formularios ---------- */
.form-card {
  max-width: 420px; margin: 60px auto; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 34px; box-shadow: var(--shadow);
}
.form-card h1 { margin: 0 0 6px; font-size: 1.7rem; }
.form-card .subtitle { margin: 0 0 22px; color: var(--ink-soft); }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 0.9rem; font-weight: 600; }
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; font-size: 0.95rem; font-family: inherit;
  color: var(--ink);
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(193,154,91,0.2);
}
.field textarea { resize: vertical; min-height: 90px; }
.form-foot { margin-top: 8px; text-align: center; font-size: 0.9rem; color: var(--ink-soft); }

/* ---------- Alertas ---------- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 0.92rem; }
.alert-error { background: #f7e3df; color: var(--danger); border: 1px solid #e6bfb7; }
.alert-success { background: #e2efe6; color: var(--success); border: 1px solid #bcd8c5; }

/* ---------- Dashboard ---------- */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin: 36px 0 26px; flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 2rem; }
.page-head .muted { color: var(--ink-soft); margin: 4px 0 0; }

.shelf {
  display: grid; gap: 40px 34px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  padding: 10px 0 30px;
}

/* Libro en la estanteria */
.book {
  position: relative; display: block; color: var(--ink);
  perspective: 1400px;
}
.book:hover { text-decoration: none; }
.book-cover {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 6px 10px 10px 6px;
  background: var(--leather);
  box-shadow: var(--shadow);
  overflow: hidden;
  transform: rotateY(0deg);
  transform-origin: left center;
  transition: transform 0.4s ease, box-shadow 0.3s ease;
}
.book:hover .book-cover { transform: rotateY(-16deg); box-shadow: 0 22px 44px rgba(42,38,32,0.32); }
/* Lomo del libro */
.book-cover::before {
  content: ""; position: absolute; top: 0; left: 0; bottom: 0; width: 14px;
  background: linear-gradient(90deg, rgba(0,0,0,0.35), rgba(255,255,255,0.08));
  z-index: 3;
}
/* Brillo del canto de paginas */
.book-cover::after {
  content: ""; position: absolute; top: 3px; right: 0; bottom: 3px; width: 6px;
  background: repeating-linear-gradient(180deg, #fff 0, #fff 1px, #e7e0cf 2px, #e7e0cf 3px);
  border-radius: 0 3px 3px 0; z-index: 4;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; opacity: 0.92; }
.book-cover .cover-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 18px 16px 18px 22px;
  background: linear-gradient(to top, rgba(0,0,0,0.6), rgba(0,0,0,0.05) 60%);
  color: #fff;
}
.book-cover .cover-title { font-family: var(--font-serif); font-size: 1.15rem; font-weight: 700; }
.book-cover .cover-meta { font-size: 0.8rem; opacity: 0.85; margin-top: 3px; }
.book-cover.no-photo { display: grid; place-items: center; }
.book-cover.no-photo .cover-overlay { justify-content: center; align-items: center; text-align: center; background: none; }

.book-actions {
  display: flex; gap: 8px; justify-content: center; margin-top: 14px;
  opacity: 0; transition: opacity 0.2s ease;
}
.book:hover .book-actions { opacity: 1; }

/* Estado vacio */
.empty {
  text-align: center; padding: 70px 20px; border: 2px dashed var(--line);
  border-radius: 16px; background: var(--paper-2); color: var(--ink-soft);
}
.empty h2 { color: var(--ink); margin-top: 0; }

/* ---------- Editor de album ---------- */
.editor-grid { display: grid; grid-template-columns: 1fr; gap: 26px; }
@media (min-width: 900px) { .editor-grid { grid-template-columns: 320px 1fr; } }

.panel {
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 16px; padding: 22px; box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 16px; font-size: 1.2rem; }

.upload-drop {
  border: 2px dashed var(--gold); border-radius: 12px;
  padding: 26px 16px; text-align: center; background: #fff;
  color: var(--ink-soft); cursor: pointer; transition: background 0.15s;
}
.upload-drop:hover, .upload-drop.dragover { background: #fbf6ec; }

.photo-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  margin-top: 6px; list-style: none; padding: 0;
}
.photo-item {
  position: relative; border-radius: 10px; overflow: hidden;
  background: #fff; border: 1px solid var(--line); box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  cursor: grab;
}
.photo-item.dragging { opacity: 0.4; }
.photo-item img { width: 100%; height: 130px; object-fit: cover; display: block; }
.photo-item .cap {
  width: 100%; border: none; border-top: 1px solid var(--line);
  padding: 7px 9px; font-size: 0.8rem; font-family: inherit; color: var(--ink);
}
.photo-item .cap:focus { outline: none; background: #fbf6ec; }
.photo-item .ph-actions {
  position: absolute; top: 6px; right: 6px; display: flex; gap: 6px;
}
.icon-btn {
  border: none; width: 28px; height: 28px; border-radius: 7px;
  background: rgba(42,38,32,0.7); color: #fff; cursor: pointer; font-size: 0.85rem;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--danger); }
.icon-btn.star.active { background: var(--gold); color: var(--leather); }
.drag-handle {
  position: absolute; top: 6px; left: 6px;
  background: rgba(42,38,32,0.7); color: #fff; border-radius: 7px;
  width: 28px; height: 28px; display: grid; place-items: center; font-size: 0.9rem;
}

.theme-swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent;
}
.swatch.selected { border-color: var(--gold); box-shadow: 0 0 0 2px #fff inset; }

.hint { font-size: 0.82rem; color: var(--ink-soft); margin-top: 8px; }

/* ---------- Visor de libro ---------- */
.viewer-body {
  margin: 0; background: #201a14; color: var(--paper);
  min-height: 100vh; overflow-x: hidden;
}
.viewer-body.bg-solid { background: #201a14; }
.viewer-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: rgba(20,16,12,0.75); backdrop-filter: blur(6px);
}
.viewer-topbar .v-title { font-family: var(--font-serif); font-size: 1.05rem; }
.viewer-topbar .v-tools { display: flex; gap: 10px; align-items: center; }
.viewer-stage {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 80px 10px 40px;
}
#flipbook {
  box-shadow: 0 30px 70px rgba(0,0,0,0.6);
}
#flipbook .page {
  background-color: var(--page-color, #faf7f0);
  background-size: cover; background-position: center;
}
#flipbook .page.hard {
  background: var(--cover-color, #3d2f24); color: #fff;
}
#flipbook .page .page-inner {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#flipbook .page .page-inner img { max-width: 100%; max-height: 100%; object-fit: contain; }
#flipbook .page .page-caption {
  position: absolute; bottom: 14px; left: 0; right: 0; text-align: center;
  font-family: var(--font-serif); font-size: 0.95rem; color: var(--ink);
}
#flipbook .cover-content {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 30px;
}
#flipbook .cover-content h1 { font-size: 1.8rem; margin: 0 0 10px; color: #fff; }
#flipbook .cover-content p { opacity: 0.8; }
.viewer-controls {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 30; display: flex; gap: 12px; align-items: center;
  background: rgba(20,16,12,0.8); padding: 10px 16px; border-radius: 999px;
  backdrop-filter: blur(6px);
}
.viewer-controls button {
  background: transparent; border: 1px solid rgba(255,255,255,0.25);
  color: #fff; width: 40px; height: 40px; border-radius: 999px; cursor: pointer;
  font-size: 1rem; display: grid; place-items: center;
}
.viewer-controls button:hover { background: var(--gold); color: var(--leather); border-color: var(--gold); }
.viewer-controls .page-indicator { font-size: 0.85rem; opacity: 0.85; min-width: 70px; text-align: center; }

/* Toggle */
.switch { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.switch input { width: auto; }

.divider { height: 1px; background: var(--line); margin: 18px 0; border: 0; }

/* Utilidades */
.text-muted { color: var(--ink-soft); }
.mt-0 { margin-top: 0; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.mb-16 { margin-bottom: 16px; }
