/* ===========================================================
   CUBIA - CARTA GOURMET (100% ancho, paneles iguales con línea)
   Versión: nota izquierda y acciones derechas alineadas al fondo
   + offset óptico para bajar un poco ambas
   + animaciones suaves y FAB móvil, tipografía Playfair (como antes)
   =========================================================== */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700&display=swap');

:root {
  --cobrizo: #c46a2b;
  --titular: #0b1b2b;
  --gris: #5c5c5c;
  --bg: #fbf8f3;
  --linea: rgba(0, 0, 0, 0.12);
  --hover: rgba(196,106,43,0.05);

  /* Ajusta cuánto “más abajo” van los bloques del fondo */
  --nota-offset: 1.75rem;
}

/* Esta vista NO debe centrarse verticalmente (override del main de base.html) */
body.layout main#contenido {
  align-items: flex-start !important;
  justify-content: flex-start !important;
}

/* Fondo y tipografía de la carta (TODO Playfair como antes) */
body main {
  background: var(--bg);
  font-family: 'Playfair Display', serif;
  color: var(--titular);
  line-height: 1.5;
  font-weight: 500;
  overflow-x: hidden;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Wrapper principal — espacio inferior para el offset */
.carta-outer {
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 3rem calc(2.5rem + var(--nota-offset));
  box-sizing: border-box;
  max-width: 1600px;
}

/* Breadcrumb superior (solo visual, sin enlaces de momento) */
.breadcrumb-carta {
  font-size: 0.85rem;
  color: var(--gris);
  opacity: 0.9;
  margin-bottom: 0.75rem;
}

/* Cabecera (fondo original) */
.carta-head {
  text-align: center;
  margin: 0 0 2.5rem;
  padding: 1.2rem 0 1.5rem;
  background: linear-gradient(to bottom, #fff, var(--bg));
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.carta-head .titulo {
  font-weight: 700;
  font-size: 2.3rem;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--cobrizo);
  display: inline-block;
  position: relative;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.carta-head .titulo::before,
.carta-head .titulo::after {
  content: "";
  display: inline-block;
  width: 60px;
  height: 2px;
  background-color: var(--cobrizo);
  vertical-align: middle;
  margin: 0 12px;
  border-radius: 2px;
  opacity: .9;
}
.carta-head .sub {
  color: var(--gris);
  font-size: 1rem;
  font-style: italic;
  margin-top: .5rem;
  text-shadow: 0 1px 1px rgba(255,255,255,0.6);
}

/* Botón/enlace sutil en cabecera */
.carta-head-actions {
  margin-top: 1.25rem;
  display: flex;
  justify-content: center;
}
.carta-download-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--cobrizo);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease-out, opacity 0.12s ease-out;
}
.carta-download-link .icono {
  font-size: 1rem;
  transform: translateY(0.5px);
}
.carta-download-link .texto {
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
}
.carta-download-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  margin: 0 auto;
  width: 0;
  height: 1px;
  background-color: rgba(196,106,43,0.65);
  transition: width 0.18s ease-out;
}
.carta-download-link:hover {
  transform: translateY(-1px);
  opacity: 0.95;
}
.carta-download-link:hover .texto {
  border-bottom-color: transparent;
}
.carta-download-link:hover::after {
  width: 100%;
}
.carta-download-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(196,106,43,0.35);
  border-radius: 4px;
}

/* GRID: dos columnas iguales con línea vertical */
.carta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  justify-content: center;
  align-items: stretch;
  column-gap: 6rem;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
  min-height: 100%;
  overflow: visible;
}
.carta-grid::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1.5px;
  background: linear-gradient(to bottom,
    rgba(196,106,43,0.20) 0%,
    rgba(196,106,43,0.45) 50%,
    rgba(196,106,43,0.20) 100%);
  transform: translateX(-0.75px);
  pointer-events: none;
}

/* Columnas */
.columna {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 0 1rem 0.5rem;
  width: 100%;
  max-width: 700px;
  box-sizing: border-box;
}

/* Títulos de bloque */
.sec-title {
  text-align: center;
  text-transform: uppercase;
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  color: var(--cobrizo);
  margin: 2.4rem 0 1.25rem;
  padding: .35rem 0 .4rem;
  border-radius: 10px;
  box-shadow: 0 1px 0 var(--linea);
}
.sec-title::after {
  content: "";
  display: block;
  width: 60px;
  height: 2px;
  background-color: var(--cobrizo);
  margin: .4rem auto 0;
  border-radius: 1px;
  opacity: .85;
}

/* Plato */
.plato {
  margin-bottom: 1.9rem;
  border-radius: 10px;
  transition: background-color .15s ease, transform .1s ease, box-shadow .15s ease;
  padding: .2rem .35rem;
  box-shadow: 0 0 0 rgba(0,0,0,0);
}
.plato:hover {
  background-color: var(--hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

/* Línea principal */
.linea {
  display: flex;
  justify-content: space-between;
  align-items: center;
  column-gap: .75rem;
}

/* Nombre */
.nombre {
  flex: 1 1 auto;
  color: var(--titular);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  padding-right: 0.75rem;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

/* Precios */
.precios-superior {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 170px;
}
.precios-superior .labels {
  position: absolute;
  top: -1.05rem;
  right: 0;
  display: flex;
  gap: 1.2rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--cobrizo);
  font-weight: 600;
  pointer-events: none;
}
.precios-superior .valores {
  display: inline-flex;
  gap: 1.5rem;
  font-weight: 700;
  color: var(--titular);
  font-size: 1.05rem;
  align-items: center;
  line-height: 1;
}
.precios-uno {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.precios-uno .valor {
  font-weight: 700;
  color: var(--titular);
  font-size: 1.05rem;
}

/* Separador (línea simple original) */
.separador {
  width: 100%;
  height: 1px;
  background-color: var(--linea);
  margin: .5rem 0 .6rem;
}

/* Descripción */
.desc {
  color: var(--gris);
  font-size: 0.96rem;
  font-style: italic;
  line-height: 1.4;
  margin-top: .25rem;
}

/* ===== ALÉRGENOS POR PLATO ===== */
.alergenos-strip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}
.alergenos-icons {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.alergeno-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  background: none;
  box-shadow: none;
  border-radius: 0;
  transition: transform .1s ease, opacity .1s ease;
  cursor: pointer;
}
.alergeno-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.alergeno-icon:hover {
  transform: scale(1.08);
  opacity: 0.9;
}

/* ===== Nota final (columna izq, fondo + offset) ===== */
.nota-panel {
  margin-top: auto;
  transform: translateY(var(--nota-offset));
  background: #fff7f1;
  border: 1px dashed var(--cobrizo);
  border-radius: 14px;
  padding: 1.2rem 1.5rem;
  color: #6a3b18;
  font-size: 1rem;
  line-height: 1.45;
  text-align: center;
  box-shadow: inset 0 0 0 2px rgba(196,106,43,0.05);
  will-change: transform;
}

/* ===== Acciones (columna dcha, alineado al fondo + offset) ===== */
.acciones-panel {
  margin-top: auto;
  transform: translateY(var(--nota-offset));
  display: flex;
  flex-direction: column;
  gap: .75rem;
  justify-content: flex-start;
  align-items: stretch;
  will-change: transform;
}

/* Botón dentro del panel de acciones a ancho completo */
.acciones-panel .btn {
  width: 100%;
}

/* Wrapper sincronizado con nota-panel, pero sin recortes */
.tabla-alergenos-wrapper {
  width: 100%;
  background: #fff7f1;
  border: 1px dashed var(--cobrizo);
  border-radius: 14px;
  padding: 0;
  box-shadow: inset 0 0 0 2px rgba(196,106,43,0.05);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  box-sizing: border-box;
}

/* Imagen: ocupa TODO el espacio disponible sin deformarse */
.tabla-alergenos-img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  transition: transform 0.15s ease-out, opacity 0.15s ease-out;
}

.tabla-alergenos-img:hover {
  transform: scale(1.02);
  opacity: 0.95;
}

/* ===== Modal de alérgenos mejorado ===== */
.modal-alergenos-header {
  background: #fbf8f3;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  padding: 1rem 1.25rem;
}
.modal-alergenos-header .modal-title {
  color: #0b1b2b;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.modal-alergenos-body {
  background: #ffffff;
}

/* Imagen grande dentro del modal de alérgenos */
.tabla-xl-modal-img {
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
  border: 3px solid var(--cobrizo);
  border-radius: 1.5rem;
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
  cursor: zoom-in;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  background-color: #ffffff;
}
.tabla-xl-modal-img:hover {
  transform: scale(1.03);
  box-shadow: 0 18px 40px rgba(0,0,0,0.35);
}

#modalAlergenos .modal-dialog {
  padding: 0.5rem;
  transform: translateY(8px);
  transition: transform 0.25s ease-out;
}
#modalAlergenos.show .modal-dialog {
  transform: translateY(0);
}

/* ===== Botón flotante (FAB) para descarga en móvil ===== */
.carta-download-fab {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  width: 3.1rem;
  height: 3.1rem;
  border-radius: 999px;
  border: none;
  background: var(--cobrizo);
  color: #ffffff;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  box-shadow: 0 8px 18px rgba(0,0,0,0.25);
  cursor: pointer;
  z-index: 1050;
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out, opacity 0.12s ease-out;
}
.carta-download-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(0,0,0,0.28);
  opacity: 0.96;
}
.carta-download-fab:active {
  transform: translateY(0);
  box-shadow: 0 6px 14px rgba(0,0,0,0.24);
}

/* ===== Animaciones suaves de entrada (secciones + platos) ===== */
.fade-up {
  opacity: 0;
  transform: translateY(8px);
  will-change: opacity, transform;
}
.fade-up.is-visible {
  animation: fadeUp 0.45s ease-out forwards;
}
@keyframes fadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Móvil */
@media (max-width: 991.98px) {
  .carta-outer {
    width: auto;
    padding: 1.2rem;
  }
  .carta-head .titulo {
    font-size: 1.8rem;
    letter-spacing: .12em;
  }

  .carta-grid {
    grid-template-columns: 1fr;
    row-gap: 2rem;
  }
  .carta-grid::before {
    display: none;
  }
  .columna {
    padding: 0 .5rem;
    max-width: none;
  }

  .linea {
    flex-direction: column;
    align-items: flex-start;
    gap: .4rem;
  }

  .desc  {
    font-size: .95rem;
  }

  .nota-panel,
  .acciones-panel {
    transform: none;
    margin-top: 1.5rem;
  }

  /* En móvil, dejamos que la tabla tenga altura natural */
  .tabla-alergenos-wrapper {
    min-height: auto !important;
  }

  /* En móvil, un poco más grande y fácil de pulsar */
  .carta-download-link {
    font-size: 1rem;
    padding: 0.15rem 0.1rem;
  }

  /* FAB visible solo en móvil */
  .carta-download-fab {
    display: inline-flex;
  }

  /* --- FIX SUPERPOSICIÓN ETIQUETAS/PRECIOS EN MÓVIL --- */
  .precios-superior {
    align-items: flex-start;
    min-width: 0;
    margin-top: 0.2rem;
  }
  .precios-superior .labels {
    position: static;
    top: auto;
    right: auto;
    display: flex;
    gap: 0.9rem;
    font-size: 0.8rem;
    margin-bottom: 0.1rem;
    pointer-events: none;
  }
  .precios-superior .valores {
    align-items: flex-start;
    gap: 0.9rem;
    font-size: 1rem;
  }
}

/* Impresión */
@media print {
  @page {
    size: A4 portrait;
    margin: 1.2cm 1.2cm;
  }

  body main {
    background: #fff !important;
    color: #000 !important;
    font-family: serif;
  }

  .carta-grid::before {
    display: none !important;
  }
  .columna {
    break-inside: avoid;
    padding: 0 1rem;
  }

  .nota-panel {
    transform: none !important;
    border: 1px dashed #000 !important;
    color: #000 !important;
    background: none !important;
    box-shadow: none !important;
  }

  .acciones-panel,
  .carta-head-actions,
  .breadcrumb-carta,
  .carta-download-fab {
    display: none !important;
  }

  .carta-head {
    background: #ffffff !important;
    box-shadow: none !important;
  }
}

/* ===========================================================
   MODO CAPTURA PDF (carta-print-mode)
   Se activa solo mientras se genera el PDF desde carta.js
   para aumentar contraste y legibilidad en la imagen.
   =========================================================== */

body.carta-print-mode main {
  background: #ffffff !important;
  color: #000000 !important;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
}

/* Cabecera más clara y sin degradado exagerado en la captura */
body.carta-print-mode .carta-head {
  background: #ffffff !important;
  box-shadow: none !important;
}

/* Título y subtítulo más oscuros */
body.carta-print-mode .carta-head .titulo {
  color: #000000 !important;
  text-shadow: none !important;
}

body.carta-print-mode .carta-head .sub {
  color: #333333 !important;
  text-shadow: none !important;
}

/* Línea central difuminada para que no distraiga tanto en el PDF */
body.carta-print-mode .carta-grid::before {
  background: rgba(0, 0, 0, 0.12) !important;
}

/* Títulos de sección, más oscuros y legibles */
body.carta-print-mode .sec-title {
  color: #000000 !important;
  box-shadow: none !important;
}

/* Nombre de plato / vino más grande y negro */
body.carta-print-mode .nombre {
  color: #000000 !important;
  font-size: 1.2rem !important;
  font-weight: 700 !important;
}

/* Descripción con más contraste */
body.carta-print-mode .desc {
  color: #333333 !important;
  font-size: 1rem !important;
}

/* Precios bien negros */
body.carta-print-mode .precios-superior .valores,
body.carta-print-mode .precios-uno .valor {
  color: #000000 !important;
  font-weight: 700 !important;
}

/* Nota final y caja de tabla de alérgenos más sencillas y claras */
body.carta-print-mode .nota-panel,
body.carta-print-mode .tabla-alergenos-wrapper {
  background: #ffffff !important;
  border: 1px solid #000000 !important;
  box-shadow: none !important;
  color: #000000 !important;
}

/* Reducimos un poco el efecto hover para que la captura no tenga sombras raras */
body.carta-print-mode .plato {
  background: #ffffff !important;
  box-shadow: none !important;
  transform: none !important;
}

/* ===========================================================
   NUEVO: Nota final solo al final en móvil
   - nota-panel-left: solo escritorio/tablet grande
   - nota-panel-mobile-only: solo móvil (al final de la carta)
   =========================================================== */

.nota-panel-mobile-only {
  display: none;
}

@media (max-width: 991.98px) {
  .nota-panel-left {
    display: none;
  }
  .nota-panel-mobile-only {
    display: block;
    margin-top: 1.5rem;
  }
}
