@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap');

/* RESET */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(to right, #f3f4f6, #e5e7eb);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 30px;
}

/* CONTAINER */
.container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-radius: 20px;
  width: 100%;
  max-width: 1200px;
  padding: 40px 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 30px;
}

@media (min-width: 768px) {
  header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}


.logo h1 {
  font-size: 30px;
  font-weight: 600;
  color: #111827;
}

.sucursal-selector-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sucursal-selector-container label {
  font-weight: 600;
  color: #374151;
}

#header-sucursal-select {
  padding: 10px 15px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: white;
  font-size: 14px;
  transition: border-color 0.3s ease;
}

#header-sucursal-select:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 5px rgba(96, 165, 250, 0.4);
}

/* FORMULARIO PRINCIPAL */
form {
  display: flex;
  flex-direction: column;
  gap: 30px;
  padding-bottom: 100px; /* <= agrega esto */
}


/* LISTA DE PRODUCTOS */
#product-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.product-item {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow 0.3s;
}

.product-item:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
}

.product-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.product-name {
  font-size: 17px;
  font-weight: 500;
  color: #374151;
}

/* BOTONES ACCIONES (✔️ ❌ mejorados) */
.action-buttons {
  display: flex;
  gap: 8px;
}

.action-buttons button {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* BOTÓN ACEPTAR (✔️ verde) */
.btn-accept {
  background: linear-gradient(135deg, #34d399, #10b981); /* Verde elegante */
}

.btn-accept:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 10px rgba(52, 211, 153, 0.4);
}

/* BOTÓN RECHAZAR (❌ rojo) */
.btn-reject {
  background: linear-gradient(135deg, #f87171, #ef4444); /* Rojo elegante */
}

.btn-reject:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 10px rgba(248, 113, 113, 0.4);
}



/* CAMPOS */
.product-interactions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.product-presentation,
.product-quantity,
.product-comment {
  flex: 1;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 14px;
  background: white;
  transition: border-color 0.3s ease;
}

.product-comment {
  resize: vertical;
  min-height: 60px;
}

/* TEXTAREA */
.general-notes-container textarea {
  margin-bottom: 60px; /* o más si deseas más separación visual */
  width: 100%;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  font-size: 14px;
  resize: vertical;
}

/* BOTONES GLOBALES (uniforme con pop-up) */
.order-buttons button,
button#save-order,
button#confirm-order,
button#regresar-btn,
button#select-date-btn,
button#send-order {
  width: auto;
  min-width: 140px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  border: none;
  border-radius: 10px; /* Más rectangular */
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}


.order-buttons button:hover,
button#save-order:hover,
button#confirm-order:hover,
button#regresar-btn:hover,
button#select-date-btn:hover,
button#send-order:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(16, 185, 129, 0.3);
}

/* COLORES ESPECÍFICOS */
#save-order {
  background: linear-gradient(135deg, #10b981, #059669);
}

#confirm-order {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}

#confirm-order:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

#regresar-btn {
  background: linear-gradient(135deg, #6b7280, #4b5563);
}

#send-order {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

#select-date-btn {
  background: linear-gradient(135deg, #10b981, #059669);
}


/* MODAL DE SUCURSAL Y FECHA */
.modal {
  display: none;
  justify-content: center;
  align-items: center;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(6px);
  z-index: 1050;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 16px;
  width: 350px;
  max-width: 90%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  text-align: center;
  animation: fadeIn 0.4s ease;
}

.modal-content h2,
.modal-content h3 {
  margin-bottom: 20px;
  font-size: 22px;
  font-weight: 600;
  color: #1f2937;
}

.modal-content select,
.modal-content input[type="date"] {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  font-size: 16px;
  margin-bottom: 20px;
  background: white;
}

.modal-content button {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 9999px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  cursor: pointer;
}

.modal-content button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(16, 185, 129, 0.3);
}

/* ANIMACIONES */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.sucursal-proveedor-card {
  background: #f9fafb;
  padding: 25px;
  border-radius: 16px;
  margin-bottom: 40px;
  text-align: center;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.05);
}

.sucursal-proveedor-title {
  font-size: 20px;
  color: #374151;
  margin-bottom: 25px;
}

.sucursal-proveedor-title strong {
  color: #2563eb;
  font-weight: 600;
}

.proveedor-select-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.proveedor-select-wrapper label {
  font-size: 16px;
  font-weight: 600;
  color: #374151;
}

.proveedores-container {
  padding: 12px 18px;
  width: 250px;
  font-size: 15px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: white;
  transition: border-color 0.3s ease;
}

.proveedores-container:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 5px rgba(96, 165, 250, 0.4);
  outline: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}



/* RESPONSIVE */
@media (max-width: 768px) {
  .container {
    padding: 20px;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
  }

  .order-buttons {
    display: flex;
    gap: 16px; /* antes era 8px, ahora más amplio */
    flex-wrap: wrap;
    justify-content: center;
  }
  
}
@media (max-width: 640px) {
  .product-interactions {
    flex-direction: column;
  }

  .product-presentation,
  .product-quantity,
  .product-comment {
    width: 100%;
  }

  .order-buttons {
    flex-direction: column;
    width: 100%;
  }

  .order-buttons button {
    width: 100%;
  }

  .modal-content {
    padding: 20px;
    width: 95%;
  }
}
@media (max-width: 640px) {
  .container {
    padding: 20px 16px;
  }
}
/* MOBILE OPTIMIZATION GENERAL */
@media (max-width: 768px) {
  body {
    overflow-x: hidden;
  }

  header {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }

  .logo h1 {
    font-size: 22px;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.3;
  }

  .sucursal-selector-container {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
  }

  .sucursal-selector-container label {
    font-size: 15px;
  }

  #header-sucursal-select {
    width: 100%;
    font-size: 15px;
  }

  .proveedores-container {
    width: 100%;
    font-size: 15px;
  }

  .sucursal-mensaje {
    font-size: 16px;
    text-align: center;
    padding: 0 8px;
    word-break: break-word;
  }

  .modal-content {
    width: 95%;
  }

  .order-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .order-buttons button {
    width: 100%;
  }
}
/* Fix del problema de cajas encimadas y espacio compacto */
.container {
  max-width: 680px; /* más cómodo para mobile y tablet */
  margin: 0 auto;
  padding: 32px 20px;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
}

/* Ajuste de encabezado en móvil */
header {
  width: 100%;
  gap: 20px;
}

header .logo h1 {
  font-size: 24px;
  line-height: 1.3;
  text-align: center;
  margin-bottom: 0;
}

/* Corrige el select de sucursal en mobile */
.sucursal-selector-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

#header-sucursal-select {
  width: 100%;
  font-size: 15px;
}

/* Estilo para los productos */
.product-name {
  word-wrap: break-word;
  white-space: normal;
}

/* Elimina scroll lateral y asegura buena legibilidad */
body {
  overflow-x: hidden;
}
.pedido-wrapper {
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .pedido-wrapper {
    padding: 0;
  }

  .logo h1 {
    font-size: 24px;
    text-align: center;
  }

  .sucursal-selector-container {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .inventario-wrapper {
    width: 100%;
    max-width: 100%;
    padding: 0;
    margin: 0 auto;
  }
}
.general-notes-container {
  margin-bottom: 80px; /* espacio debajo del bloque de notas y botón */
}
.pedido-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.general-notes-container {
  margin-bottom: 40px;
}

#buttons-container {
  margin-bottom: 60px;
}

#send-order {
  margin-bottom: 80px;
}
#guardar-container button {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  width: 100%;
  transition: all 0.3s ease;
}

#guardar-container button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(16, 185, 129, 0.3);
}
#order-summary {
  background: white;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
  padding: 24px;
  margin: 20px 0 40px; /* arriba, lados, abajo */
  overflow-x: auto;
}

#order-summary table {
  width: 100%;
  border-collapse: collapse;
}

#order-summary th,
#order-summary td {
  border: 1px solid #e5e7eb;
  padding: 10px;
  text-align: left;
  font-size: 14px;
  word-break: break-word;
}

#order-summary th {
  background: #f3f4f6;
  font-weight: 600;
}
#buttons-container {
  margin-top: 30px;
  margin-bottom: 80px; /* subido de 40px a 80px */
  display: flex;
  flex-direction: column;
  gap: 16px;
}
/* Estilos responsivos para la tabla del resumen */
#order-summary table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

#order-summary th,
#order-summary td {
  padding: 10px;
  border: 1px solid #e5e7eb;
  text-align: left;
  font-size: 14px;
}

#order-summary th {
  background: #f9fafb;
  font-weight: 600;
}

#order-summary {
  background: #ffffff;
  padding: 20px;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
  margin: 20px auto;
  overflow-x: auto;
  max-width: 100%;
}

/* Centrar título y ajustar tabla en móvil */
#order-summary h3 {
  margin-bottom: 16px;
  font-size: 18px;
  text-align: center;
}

/* Mejora legibilidad para móviles */
@media (max-width: 480px) {
  #order-summary th,
  #order-summary td {
    font-size: 13px;
    padding: 8px;
  }

  #order-summary table {
    font-size: 13px;
  }
}

#enviar-container {
  margin-top: 20px;
  margin-bottom: 80px;
}
#order-summary {
  margin-bottom: 60px; /* antes 40px */
}
#buttons-container {
  margin-top: 40px; /* antes 30px */
}
#buttons-container,
#enviar-container {
  background: transparent !important;
  box-shadow: none !important;
}
@media (max-width: 768px) {
  .order-buttons {
    gap: 20px;
    margin-top: 20px;
  }

  #buttons-container button,
  #enviar-container button {
    width: 100%;
    margin-bottom: 12px;
  }
}
/* Estilos para alinear Enviar y Regresar lado a lado */
.enviar-flex {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

#enviar-container button {
  min-width: 140px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  border: none;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

#send-order {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

#regresar-btn-final {
  background: linear-gradient(135deg, #6b7280, #4b5563);
}

/* En móviles que se vean uno debajo del otro */
@media (max-width: 640px) {
  .enviar-flex {
    flex-direction: column;
    align-items: stretch;
  }

  #enviar-container button {
    width: 100%;
  }
}
/* 🟩 TARJETAS DE PEDIDOS PARA MÓVIL */
.card-pedido {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-pedido:hover {
  transform: scale(1.01);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.05);
}

.card-pedido p {
  margin-bottom: 8px;
  font-size: 15px;
  color: #374151;
}

.card-pedido strong {
  color: #1f2937;
}

.card-pedido a {
  display: inline-block;
  margin-top: 12px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  font-weight: 600;
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 10px;
  text-decoration: none;
  transition: background 0.2s ease;
}

.card-pedido a:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}
/* 🔧 FIX: Prevenir que el modal de gestión de productos se abra automáticamente
   Scoped a #modal-producto-backdrop para no romper otras modales que usan el
   patrón estándar de inventario.css (toggle de `.hidden`), como la modal
   "Nuevo Elaborado" del editor de recetas. */
#modal-producto-backdrop.tv-modal-backdrop {
  display: none !important;
}

#modal-producto-backdrop.tv-modal-backdrop.is-open {
  display: flex !important;
}

/* Asegurar que el modal del sistema principal mantenga su comportamiento */
.modal:not(.tv-modal-backdrop) {
  display: none;
}

.modal:not(.tv-modal-backdrop).is-open {
  display: flex;
}