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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f4f6f9;
  color: #333;
  padding-top: 7rem; /* Espacio para header + controles fijos */
}

/* ===============================
   FUENTE CUSTOM
================================= */
@font-face {
  font-family: 'Adigiana UI';
  src: url('./fonts/FontsRUs.ttf') format('woff2'),
       url('./fonts/FontsRUs.ttf') format('woff');
}

/* ===============================
   HEADER
================================= */
header {
  position: fixed;
  top: 0;
  width: 100%;
  height: 55px;
  background: linear-gradient(145deg, rgb(110 171 135), rgb(44 83 60));
  color: white;
  text-align: center;
  padding: 1.2rem 1rem;
  z-index: 1001;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-family: "Adigiana UI", sans-serif;
  flex-grow: 1;
  font-size: 1.80rem;
  margin: 0;
}

.logout-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.5);
  color: white;
  padding: 0.5rem 0.8rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.logout-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: white;
}

/* ===============================
   SUMMARY CONTROLS
================================= */
.summary-controls {
  position: fixed;
  top: 60px; /* Justo debajo del header */
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  padding: 0.75rem 1rem;
  background: white;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  z-index: 1000;
  max-width: 600px;
  margin: auto;
  border-radius: 8px;
}

.summary-btn {
  flex: 1;
  min-width: 80px;
  padding: 0.75rem;
  background: #ccc;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: not-allowed;
  transition: all 0.2s ease;
}

.summary-btn.active {
  background: #3498db;
  cursor: pointer;
}

.summary-btn.active:hover {
  background: #2980b9;
}

/* ===============================
   MAIN CONTENT
================================= */
main {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
  margin-top: 7px; /* header (55) + controles (~60) + buffer */
  position: relative;
  z-index: 1;
}

.category-btn {
  display: block;
  width: 80vw;
  max-width: 500px;
  margin: 0.75rem auto;
  padding: 1rem;
  background: white;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
  text-align: center;
  position: relative;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.category-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.category-btn.disabled {
  opacity: 0.6;
  pointer-events: none;
}

.category-btn .arrow {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.category-btn.open .arrow {
  transform: translateY(-50%) rotate(180deg);
}

/* ===============================
   PRODUCTS LIST
================================= */
.products-list {
  display: none;
  margin-left: 2rem;
  padding: 0.5rem 0;
  border-left: 2px solid #e0e0e0;
  margin-top: -0.5rem;
}

.product-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: white;
  border-bottom: 1px solid #eee;
  transition: background 0.2s ease;
}

.product-item:hover {
  background: #f9f9f9;
}

.product-info {
  flex: 1;
  min-width: 0;
}

.product-name {
  font-weight: bold;
  white-space: normal;
}

.product-brand {
  color: #777;
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.product-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.product-price {
  width: 60px;
  text-align: right;
  margin-right: 1rem;
}

.quantity-input {
  width: 60px;
  padding: 0.3rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
  text-align: right;
  cursor: not-allowed;
}

.quantity-input.enabled {
  background: white;
  color: black;
  cursor: text;
}

/* ===============================
   LOGIN MODAL
================================= */
.login-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.login-box {
  background: white;
  padding: 2rem;
  border-radius: 10px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.login-box h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.login-box input {
  padding: 10px;
  margin-bottom: 10px;
  width: calc(100% - 20px);
  border: 1px solid #ddd;
  border-radius: 4px;
  box-sizing: border-box;
}

.login-box button {
  padding: 1rem;
  width: 100%;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
  margin-top: 10px;
}

.login-box button:hover {
  background: #2980b9;
}

.login-box button.register-btn {
  background: #2ecc71;
}

.login-box button.register-btn:hover {
  background: #27ae60;
}

#authError {
  color: red;
  margin-top: 10px;
  font-size: 0.9em;
  min-height: 1.5em;
}

/* ===============================
   SUMMARY MODAL
================================= */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 10px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 1.3rem;
  cursor: pointer;
  font-weight: bold;
  user-select: none;
}

/* ===============================
   SUMMARY TABLE - RESPONSIVE
================================= */
.summary-table-wrapper {
  max-height: 300px;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* Fuerza quiebres en móvil */
}

.summary-table th,
.summary-table td {
  border-bottom: 1px solid #ddd;
  padding: 0.5rem;
  text-align: left;
  vertical-align: top;
}

.summary-table th.price-column,
.summary-table td.price-column {
  text-align: right;
  white-space: nowrap;
  min-width: 60px;
}

/* Alineación específica y forzada para Cantidad */
.summary-table th.quantity-column,
.summary-table td.quantity-column {
  text-align: center;
}

.summary-table td:first-child {
  word-break: break-word;
  max-width: 150px;
}

th {
  background: #ecf0f1;
}

.total-line {
  margin-top: 1rem;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
}

.actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: space-between;
}

.actions button {
  flex: 1;
  padding: 0.8rem;
  background: #ecf0f1;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.actions button:hover {
  background: #dce2e6;
}

#userDataBlock {
  border-top: 1px solid #ddd;
  padding-top: 1rem;
}

#userDataBlock p {
  margin-bottom: 0.8rem;
}

#userDataBlock label {
  display: block;
  font-size: 0.9rem;
  margin: 0.5rem 0 0.2rem;
}

#userDataBlock input {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 1rem;
}

/* === SPLASH REVISADO FINAL === */
#splash {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  z-index: 99999;
  background: #000; /* fallback */
}

.splash-content {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Fondo bosque */
.background {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

/* Hojitas */
.leaf {
  position: absolute;
  top: -30px;
  width: 15px; height: 15px;
  background: #4CAF50;
  border-radius: 50%;
  opacity: 0.8;
  animation: fall 6s linear infinite;
  z-index: 2;
}

.leaf:nth-child(2) { left: 5%; animation-delay: 0s; }
.leaf:nth-child(3) { left: 15%; animation-delay: 1s; }
.leaf:nth-child(4) { left: 25%; animation-delay: 2s; }
.leaf:nth-child(5) { left: 35%; animation-delay: 3s; }
.leaf:nth-child(6) { left: 50%; animation-delay: 4s; }
.leaf:nth-child(7) { left: 65%; animation-delay: 2.5s; }
.leaf:nth-child(8) { left: 75%; animation-delay: 3.5s; }
.leaf:nth-child(9) { left: 85%; animation-delay: 1.5s; }
.leaf:nth-child(10) { left: 95%; animation-delay: 4.5s; }

@keyframes fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.8;
  }
  100% {
    transform: translateY(100vh) rotate(360deg);
    opacity: 0;
  }
}

/* Zorrito centrado */
.fox-wrapper {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  max-width: 100%;
}

.fox-wrapper img {
  display: block;
  width: auto;
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  cursor: pointer;
  will-change: opacity;
  backface-visibility: hidden;
  transform: translateZ(0);
}

/* 👇 Forzamos mismo ajuste para el ojo guiñado */
#fox-wink {
  position: absolute;
  top: 0; left: 0;
  width: auto;
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  display: block;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

/* Ajuste para monitores grandes */
@media (min-width: 1024px) {
  .fox-wrapper img {
    max-height: 90vh;
    max-width: 60vw;
  }
  #fox-wink {
    max-height: 90vh;
    max-width: 60vw;
  }
}

/* Textos */
.welcome {
  position: absolute;
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 1.8rem;
  font-weight: bold;
  text-shadow: 2px 2px 5px #000;
  font-family: 'Adigiana UI', sans-serif;
  text-align: center;
  z-index: 4;
}

.hint {
  position: absolute;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 1.2rem;
  text-shadow: 1px 1px 3px #000;
  text-align: center;
  z-index: 4;
}

/* ===============================
   TRANSICIONES LOGOUT
================================= */
#splash {
  transition: opacity 0.5s ease-in-out;
}

.login-modal {
  transition: opacity 0.3s ease-in-out;
}

.logout-btn {
  transition: all 0.2s ease;
}

.logout-btn:active {
  transform: scale(0.95);
}

/* ===============================
   TRANSICIONES LOGOUT
================================= */

#pdfModal .actions button {
  flex: 1;
  margin: 0 0.5rem;
}

#pdfConfirmBtn {
  background: #2ecc71; /* Verde */
  color: white;
  border: none;
}

#pdfConfirmBtn:hover {
  background: #27ae60;
}

/* Estilo para el modal de opciones */
#pdfModal .options-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.option-item {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 1.1rem;
  user-select: none;
}

.option-item input[type="checkbox"] {
  opacity: 0;
  position: absolute;
}

.checkbox-custom {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #3498db;
  border-radius: 4px;
  margin-right: 10px;
  position: relative;
  transition: background 0.2s;
}

.option-item input[type="checkbox"]:checked + .checkbox-custom::after {
  content: '✓';
  position: absolute;
  color: white;
  font-size: 14px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.option-item input[type="checkbox"]:checked + .checkbox-custom {
  background: #3498db;
}

#pdfConfirmBtn {
  margin-top: 1rem;
  padding: 0.8rem 1.5rem;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  width: 100%;
}

#pdfConfirmBtn:hover {
  background: #2980b9;
}