/* ============================================================
   ticket.css - Estilos para ticket 80mm (Pantalla e Impresión)
   El Bocadón · Hamburguesería
   VERSIÓN FINAL - CON BANGERS EN ETIQUETAS Y TÍTULOS
   + SCROLL EN MODAL Y BOTONES FIJOS PARA TABLETS
   + DIRECCIÓN WRAP
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bangers&display=swap');

/* ============================================================
   MODAL TICKET - PANTALLA COMPLETA Y CENTRADO
   ============================================================ */
#modalTicket {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99999;
  justify-content: center;
  align-items: center;
  padding: 0.5rem;
  box-sizing: border-box;
}
#modalTicket.active {
  display: flex;
}

#modalTicket .modal-content {
  background: white;
  max-width: 500px;
  width: 100%;
  max-height: 95vh;
  height: 95vh;
  margin: 0;
  padding: 0;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#modalTicket .modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 2rem;
  cursor: pointer;
  color: #666;
  background: rgba(255,255,255,0.9);
  border: none;
  z-index: 20;
  padding: 0 10px;
  margin: 0;
  line-height: 1;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  transition: all 0.2s;
}
#modalTicket .modal-close:hover {
  background: #d32f2f;
  color: white;
  transform: rotate(90deg);
}

#ticketContenido {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.5rem 0 0 0;
  background: white;
  -webkit-overflow-scrolling: touch;
}

.ticket-wrapper-compact {
  width: 78mm;
  max-width: 78mm;
  margin: 0 auto;
  padding: 2mm 4mm 3mm 5mm;
  font-family: 'Arial', sans-serif;
  font-size: 13px;
  background: white;
  box-sizing: border-box;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.3;
  color: #1a1a1a;
  overflow: visible !important;
  height: auto !important;
}

.cliente-linea .valor-fijo,
.ticket-item-line .ticket-item-name,
.ticket-item-sub-line .ticket-item-name {
  overflow: visible !important;
  white-space: normal !important;
  text-overflow: clip !important;
}

/* Permitir wrap en la dirección (también para impresión) */
.ticket-client-compact .cliente-linea .valor-fijo,
.ticket-client-compact div span[style*="white-space:normal"] {
  white-space: normal !important;
  word-break: break-word !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

.ticket-acciones {
  flex-shrink: 0;
  display: flex !important;
  gap: 0.8rem !important;
  justify-content: center !important;
  padding: 0.8rem 1rem !important;
  border-top: 2px solid #e8e0d8 !important;
  background: #faf6f0 !important;
  width: 100% !important;
  box-sizing: border-box;
  flex-wrap: wrap;
}
.ticket-acciones .btn-primary {
  width: auto;
  padding: 0.6rem 1.2rem;
  font-size: 0.85rem;
  border-radius: 40px;
  border: none;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  background: #8B5A2B;
  color: white;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ticket-acciones .btn-primary:hover {
  background: #5C3A1A;
  transform: scale(1.02);
}

/* ============================================================
   ESTILOS DEL TICKET
   ============================================================ */
.ticket-logo { text-align: center; margin-bottom: 1mm; }
.ticket-logo-img { height: 100px; max-width: 68mm; display: inline-block; object-fit: contain; }
.ticket-header-compact {
  text-align: center;
  font-family: 'Bangers', cursive;
  font-size: 22px;
  letter-spacing: 1.5px;
  color: #8B5A2B;
  margin: 0;
  line-height: 1.1;
}
.ticket-subheader-compact {
  text-align: center;
  font-size: 11px;
  color: #555;
  margin: 0;
  line-height: 1.2;
}
.ticket-phone-compact {
  text-align: center;
  font-size: 11px;
  color: #555;
  margin: 0;
  line-height: 1.2;
}
.ticket-divider-compact { border: 0; border-top: 1px solid #333; margin: 1.5mm 0; }
.ticket-divider-dashed { border: 0; border-top: 1px dashed #999; margin: 1mm 0; }
.ticket-title-compact {
  text-align: center;
  font-family: 'Bangers', cursive;
  font-size: 18px;
  color: #8B5A2B;
  margin: 0;
  line-height: 1.1;
}
.ticket-number-compact {
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  color: #333;
  margin: 0;
  line-height: 1.2;
}
.ticket-datetime-compact {
  text-align: center;
  font-size: 11px;
  color: #666;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
}

.ticket-client-compact {
  margin: 1mm 0;
  font-size: 13px;
}
.cliente-linea {
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: baseline !important;
  gap: 4px !important;
  margin: 0.5mm 0 !important;
  padding: 0 !important;
  font-size: 13px !important;
  line-height: 1.3 !important;
}
.cliente-linea strong {
  display: inline-block !important;
  min-width: 60px !important;
  flex-shrink: 0 !important;
  font-family: 'Bangers', cursive !important;
  font-weight: 400 !important;
  font-size: 14px !important;
  white-space: nowrap !important;
  color: #333 !important;
  letter-spacing: 0.5px;
}
.cliente-linea .valor-fijo {
  display: inline-block !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  flex: 1 !important;
  font-family: 'Arial', sans-serif !important;
  font-weight: 400 !important;
  color: #1a1a1a !important;
}

/* Para el wrap de dirección (clase específica) */
.ticket-client-compact .direccion-wrap {
  white-space: normal !important;
  word-break: break-word !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

.ticket-detail-compact { margin: 0.5mm 0; }
.ticket-detail-title-compact {
  font-family: 'Bangers', cursive !important;
  font-weight: 400 !important;
  font-size: 16px !important;
  margin-bottom: 0.5mm;
  color: #333;
  letter-spacing: 0.5px;
}
.ticket-items-compact { display: block; }

.ticket-item-line {
  display: flex !important;
  flex-wrap: nowrap !important;
  justify-content: space-between !important;
  align-items: flex-start !important;
  padding: 0.5mm 0 !important;
  font-size: 13px !important;
  border-bottom: 1px dotted #ddd !important;
  gap: 4px !important;
}
.ticket-item-line .ticket-item-name {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  white-space: normal !important;
  font-family: 'Arial', sans-serif !important;
  font-size: 13px !important;
  color: #1a1a1a !important;
  line-height: 1.3 !important;
}
.ticket-item-line .ticket-item-price {
  flex-shrink: 0 !important;
  white-space: nowrap !important;
  font-family: 'Arial', sans-serif !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  color: #222 !important;
  margin-left: 4px !important;
}

.ticket-item-sub-line {
  display: flex !important;
  flex-wrap: nowrap !important;
  justify-content: space-between !important;
  align-items: flex-start !important;
  padding: 0.3mm 0 0.3mm 3mm !important;
  font-size: 12px !important;
  color: #555 !important;
  border-bottom: 1px dotted #eee !important;
  gap: 4px !important;
}
.ticket-item-sub-line .ticket-item-name {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  white-space: normal !important;
  font-family: 'Arial', sans-serif !important;
  font-size: 12px !important;
  color: #555 !important;
  line-height: 1.3 !important;
}
.ticket-item-sub-line .ticket-item-price {
  flex-shrink: 0 !important;
  white-space: nowrap !important;
  font-family: 'Arial', sans-serif !important;
  font-size: 12px !important;
  color: #555 !important;
  margin-left: 4px !important;
}

.ticket-extras-divider { border-top: 1px dashed #999; margin: 0.5mm 0; }

.ticket-totals-compact { margin: 0.5mm 0; font-size: 13px; }
.ticket-total-line-compact {
  display: flex !important;
  flex-wrap: nowrap !important;
  justify-content: space-between !important;
  align-items: baseline !important;
  padding: 0.3mm 0 !important;
  font-size: 13px !important;
  gap: 8px !important;
}
.ticket-total-line-compact span:first-child {
  white-space: nowrap !important;
  font-family: 'Bangers', cursive !important;
  font-weight: 400 !important;
  font-size: 14px !important;
  color: #333 !important;
  letter-spacing: 0.5px;
}
.ticket-total-line-compact span:last-child {
  white-space: nowrap !important;
  font-family: 'Arial', sans-serif !important;
  font-weight: 600 !important;
  text-align: right !important;
  font-size: 13px !important;
}
.ticket-envio-compact {
  border-bottom: 1px dotted #bbb !important;
  padding-bottom: 0.5mm !important;
  margin-bottom: 0.3mm !important;
}
.ticket-total-final-compact {
  font-weight: 800 !important;
  font-size: 16px !important;
  padding-top: 0.5mm !important;
  color: #8B5A2B !important;
  border-top: 2px solid #8B5A2B !important;
  margin-top: 0.5mm !important;
}
.ticket-total-final-compact span:first-child {
  font-family: 'Bangers', cursive !important;
  font-weight: 400 !important;
  font-size: 18px !important;
  color: #8B5A2B !important;
}
.ticket-total-final-compact span:last-child {
  font-family: 'Bangers', cursive !important;
  font-size: 20px !important;
  color: #5C3A1A !important;
}

.ticket-puntos-compact {
  margin: 0.5mm 0;
  font-size: 13px;
}
.ticket-puntos-line {
  display: flex !important;
  justify-content: space-between !important;
  padding: 0.3mm 0 !important;
  font-size: 13px !important;
}
.ticket-puntos-line span:first-child {
  font-family: 'Bangers', cursive !important;
  font-weight: 400 !important;
  font-size: 14px !important;
  color: #333 !important;
}
.ticket-puntos-line span:last-child {
  font-family: 'Arial', sans-serif !important;
  font-weight: 600 !important;
  color: #27ae60 !important;
}

.ticket-footer-compact {
  text-align: center;
  font-family: 'Bangers', cursive;
  font-size: 18px;
  color: #8B5A2B;
  margin: 1mm 0 0.5mm 0;
  letter-spacing: 0.5px;
}
.ticket-footer-small-compact {
  text-align: center;
  font-family: 'Bangers', cursive;
  font-size: 16px;
  color: #8B5A2B;
  margin: 0;
  line-height: 1.2;
  letter-spacing: 0.5px;
}

/* ============================================================
   IMPRESIÓN
   ============================================================ */
@media print {
  body * { display: none !important; }
  #modalTicket, #modalTicket * { display: block !important; }
  #modalTicket {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: white !important;
    z-index: 99999 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
  }
  #modalTicket .modal-content {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    min-height: 100% !important;
    height: auto !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: white !important;
    overflow: visible !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-direction: column !important;
    max-height: none !important;
  }
  #modalTicket .modal-close,
  .ticket-acciones,
  #modalTicket .ticket-acciones {
    display: none !important;
  }
  #ticketContenido {
    overflow: visible !important;
    flex: none !important;
    padding: 0 !important;
  }
  .ticket-wrapper-compact {
    width: 78mm !important;
    max-width: 78mm !important;
    margin: 0 !important;
    padding: 1mm 3mm 2mm 4mm !important;
    font-size: 13px !important;
    background: white !important;
    box-sizing: border-box !important;
    page-break-after: avoid !important;
    border: none !important;
    font-family: 'Arial', sans-serif !important;
    transform: scale(1) !important;
    transform-origin: top left !important;
  }
  .ticket-logo-img { height: 90px !important; max-width: 68mm !important; }
  .ticket-header-compact { font-size: 20px !important; }
  .ticket-title-compact { font-size: 16px !important; }
  .ticket-total-final-compact { font-size: 14px !important; }
  .ticket-total-final-compact span:first-child { font-size: 16px !important; }
  .ticket-total-final-compact span:last-child { font-size: 18px !important; }
  .ticket-footer-compact { font-size: 16px !important; }
  .ticket-footer-small-compact { font-size: 14px !important; }

  .cliente-linea strong,
  .ticket-detail-title-compact,
  .ticket-total-line-compact span:first-child,
  .ticket-total-final-compact span:first-child,
  .ticket-puntos-line span:first-child {
    font-family: 'Bangers', cursive !important;
  }

  .cliente-linea,
  .ticket-item-line,
  .ticket-item-sub-line,
  .ticket-total-line-compact,
  .ticket-puntos-line {
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    gap: 4px !important;
  }
  .cliente-linea strong,
  .ticket-item-line .ticket-item-name,
  .ticket-item-sub-line .ticket-item-name,
  .ticket-total-line-compact span:first-child,
  .ticket-puntos-line span:first-child {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    line-height: 1.3 !important;
  }
  .cliente-linea .valor-fijo,
  .ticket-item-line .ticket-item-price,
  .ticket-item-sub-line .ticket-item-price,
  .ticket-total-line-compact span:last-child,
  .ticket-puntos-line span:last-child {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
  }

  /* Asegurar wrap en la dirección durante la impresión */
  .ticket-client-compact .cliente-linea .valor-fijo {
    white-space: normal !important;
    word-break: break-word !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  .ticket-item-line, .ticket-item-sub-line {
    page-break-inside: avoid !important;
  }
  .ticket-wrapper-compact * {
    color: #000 !important;
    border-color: #000 !important;
  }

  @page {
    margin: 0 !important;
    size: 78mm auto !important;
  }
}

/* ============================================================
   SCROLLBAR PERSONALIZADA
   ============================================================ */
#ticketContenido::-webkit-scrollbar {
  width: 6px;
}
#ticketContenido::-webkit-scrollbar-track {
  background: #f0ebe5;
}
#ticketContenido::-webkit-scrollbar-thumb {
  background: #8B5A2B;
  border-radius: 3px;
}
#ticketContenido::-webkit-scrollbar-thumb:hover {
  background: #5C3A1A;
}