/* ── Fichas y tokens ─────────────────────────────────────────────── */
:root {
  --paper: #efeae0;
  --surface: #fbf9f4;
  --ink: #23302b;
  --ink-soft: #5b6660;
  --line: #d9d0bc;
  --line-soft: #e5deca;

  --spring: #2f8f86;
  --spring-deep: #1b5e56;
  --spring-wash: #e3efec;

  --gold: #b8863b;
  --gold-wash: #f5ecd8;

  --clay: #a8462a;
  --clay-wash: #f5e5df;

  --radius: 6px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Work Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--spring-deep); }
a:hover { color: var(--spring); }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
h1 { font-size: 1.65rem; margin: 0 0 1.5rem; }
h2 { font-size: 1.2rem; margin: 2rem 0 0.75rem; }

/* ── Estructura general: recepción con directorio a la izquierda ──── */
.shell {
  display: flex;
  align-items: flex-start;
  min-height: 100%;
}

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: var(--ink);
  color: #fff;
  padding: 0.85rem 1.1rem;
  position: sticky;
  top: 0;
  z-index: 60;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #fff;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}
.brand-mark { color: var(--gold); display: inline-flex; }
.sidebar .brand { margin-bottom: 2rem; }

.nav-toggle {
  background: transparent;
  border: none;
  color: #fff;
  padding: 0.3rem;
  margin: 0;
  cursor: pointer;
  display: inline-flex;
  border-radius: var(--radius);
}
.nav-toggle:hover { background: rgba(255, 255, 255, 0.1); }
.nav-toggle-close { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle-open { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle-close { display: inline-flex; }

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 20, 18, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 55;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  min-height: 100vh;
  background: var(--ink);
  color: #dfe6e2;
  padding: 1.5rem 1.25rem;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
}

.sidebar nav { display: flex; flex-direction: column; gap: 1.5rem; }

.nav-group-title {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  color: #8f9c95;
  margin: 0 0 0.5rem;
}

.nav-group { display: flex; flex-direction: column; }
.nav-group a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #dfe6e2;
  text-decoration: none;
  padding: 0.4rem 0.5rem;
  margin: 0 -0.5rem;
  border-radius: var(--radius);
  font-size: 0.93rem;
}
.nav-group a svg { flex-shrink: 0; opacity: 0.75; }
.nav-group a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-group a.active { background: var(--spring-deep); color: #fff; }
.nav-group a.active svg { opacity: 1; }

.nav-group-plain { border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 1.25rem; }

.logout-form { margin-top: auto; padding-top: 1.25rem; }
.logout-button {
  background: transparent;
  color: #b7c2bc;
  border: 1px solid rgba(255, 255, 255, 0.18);
  width: 100%;
  justify-content: center;
  margin-bottom: 0;
  font-size: 0.85rem;
}
.logout-button:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-whatsapp { font-weight: 500; }
.nav-whatsapp .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4bbf9b; flex-shrink: 0;
}

.content { flex: 1; min-width: 0; width: 100%; }

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
  overflow-x: auto;
}

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .topbar { display: flex; }
  .brand-desktop { display: none; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    height: 100vh;
    width: min(78vw, 300px);
    min-height: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 56;
    box-shadow: 2px 0 24px rgba(0, 0, 0, 0.25);
  }
  .sidebar.open { transform: translateX(0); }

  .backdrop { display: block; }
  .backdrop.visible { opacity: 1; pointer-events: auto; }

  body.nav-open { overflow: hidden; }

  main { padding: 1.5rem 1.25rem 3rem; }
}

/* ── Barra de acciones sobre la tabla ──────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-bottom: 0.25rem;
}
.toolbar .button { margin-bottom: 0; }
.export-group { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 1.25rem; }
.export-label { color: var(--ink-soft); font-size: 0.85rem; margin-right: 0.15rem; }
.export-group .button-secondary {
  margin-left: 0;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

/* ── Tablas: se leen como un libro de huéspedes, no una grilla ────── */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line-soft);
}
th {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: transparent;
  border-bottom: 1px solid var(--line);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(47, 143, 134, 0.05); }
td.actions { white-space: nowrap; }

.truncate {
  display: inline-block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

/* ── Botones ───────────────────────────────────────────────────── */
.button, button, .button-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--spring);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
}
.button:hover, button:hover { background: var(--spring-deep); }

.button-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  margin-left: 0.5rem;
}
.button-secondary:hover { background: var(--surface); border-color: var(--ink-soft); }

.actions form { display: inline; }
.actions a, .actions button {
  margin: 0 0.4rem 0 0;
  padding: 0.3rem 0.65rem;
  font-size: 0.85rem;
  background: transparent;
  color: var(--spring-deep);
  border: 1px solid var(--line);
}
.actions a:hover { background: var(--spring-wash); }
.actions button.danger, .actions form.danger button {
  color: var(--clay);
  border-color: var(--clay);
}
.actions button.danger:hover, .actions form.danger button:hover { background: var(--clay-wash); }

/* ── Formularios ───────────────────────────────────────────────── */
form .field { margin-bottom: 1.1rem; display: flex; flex-direction: column; max-width: 480px; }
form label { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; color: var(--ink); }
form input, form textarea, form select {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
}
form input:focus, form textarea:focus, form select:focus {
  outline: 2px solid var(--spring);
  outline-offset: 1px;
  border-color: var(--spring);
}
form textarea { min-height: 90px; }

.error {
  background: var(--clay-wash);
  color: var(--clay);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid rgba(168, 70, 42, 0.25);
  margin-bottom: 1rem;
}

/* ── Insignias de estado: como etiquetas de llavero ───────────────── */
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid transparent;
}
.status-ready, .status-confirmada { background: var(--spring-wash); color: var(--spring-deep); border-color: rgba(47, 143, 134, 0.25); }
.status-qr_ready, .status-pendiente_pago, .status-esperando_admin { background: var(--gold-wash); color: var(--gold); border-color: rgba(184, 134, 59, 0.3); }
.status-error, .status-rechazada, .status-cancelada, .status-expirada { background: var(--clay-wash); color: var(--clay); border-color: rgba(168, 70, 42, 0.25); }
.status-other { background: var(--line-soft); color: var(--ink-soft); }

/* ── Login: pantalla sola, sin directorio lateral ─────────────────── */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 2rem;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.4rem;
}
.login-brand .brand-mark { color: var(--gold); }
.login-hint { color: var(--ink-soft); font-size: 0.9rem; margin: 0 0 1.5rem; }
.login-card .field { max-width: none; }
.login-card button { width: 100%; justify-content: center; margin-top: 0.5rem; }

/* ── WhatsApp: ficha de vinculación ───────────────────────────────── */
.qr-box {
  text-align: center;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  max-width: 320px;
}
.qr-box img { max-width: 100%; border-radius: 4px; }
.qr-box p { color: var(--ink-soft); font-size: 0.9rem; }

/* ── Textos de apoyo ───────────────────────────────────────────── */
main > p { color: var(--ink-soft); max-width: 65ch; }
main > p a { font-weight: 500; }

/* ── Configuración: tarjetas cuadradas con ícono ──────────────────── */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  max-width: 820px;
}
.config-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  aspect-ratio: 1 / 1;
  padding: 1.25rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  text-align: center;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.config-tile:hover { border-color: var(--spring); transform: translateY(-2px); }
.config-tile-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--spring-wash);
  color: var(--spring-deep);
}
.config-tile-label { font-size: 0.88rem; font-weight: 500; line-height: 1.25; }
