/* =========================================================
   AUTH SYSTEM — RESTAURANTE PANAMÁ v14
   Login · Registro · Invitado
   Flujo: Preload → Auth Screen → Página principal
   ========================================================= */

/* ── Pantalla de auth — encima de TODO, incluyendo el preloader ── */
#auth-screen {
  position: fixed;
  inset: 0;
  z-index: 10000; /* encima del preloader (9999) */
  display: flex;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s ease, visibility 0.45s ease;
  font-family: 'DM Sans', sans-serif;
  overflow: hidden;
}

#auth-screen.visible {
  opacity: 1;
  visibility: visible;
}

/* ── Panel izquierdo — imagen de fondo ── */
.auth-bg {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: none;
}

@media (min-width: 768px) {
  .auth-bg {
    display: block;
  }
}

.auth-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.auth-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.45) 0%,
    rgba(0, 0, 0, 0.15) 60%
  );
}

/* Texto sobre imagen */
.auth-bg-text {
  position: absolute;
  bottom: 48px;
  left: 40px;
  right: 40px;
  z-index: 2;
  color: #ffffff;
}

.auth-bg-text h2 {
  font-family: 'Forum', serif;
  font-size: clamp(24px, 3.5vw, 40px);
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 12px;
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.auth-bg-text p {
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  text-shadow: 0 1px 6px rgba(0,0,0,0.5);
}

/* ── Panel derecho — formulario ── */
.auth-panel {
  width: 100%;
  max-width: 460px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 48px;
  overflow-y: auto;
  position: relative;
  box-shadow: -4px 0 40px rgba(0,0,0,0.08);
}

@media (max-width: 767px) {
  .auth-panel {
    max-width: 100%;
    padding: 32px 24px;
  }
  #auth-screen {
    flex-direction: column;
  }
}

/* Logo en el panel */
.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 32px;
}

.auth-logo img {
  height: 72px;
  width: auto;
  object-fit: contain;
}

/* Títulos */
.auth-title {
  font-family: 'Forum', serif;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 400;
  color: #1A1A1A;
  line-height: 1.25;
  margin-bottom: 6px;
  text-align: center;
}

.auth-subtitle {
  font-size: 13px;
  color: #777777;
  text-align: center;
  margin-bottom: 28px;
}

/* ── Tabs login / register ── */
.auth-tabs {
  display: flex;
  border-bottom: 1px solid #e8e8e8;
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 12px 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #AAAAAA;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.25s ease, border-color 0.25s ease;
}

.auth-tab.active {
  color: #1A1A1A;
  border-bottom-color: #E4C590;
}

.auth-tab:hover:not(.active) {
  color: #555;
}

/* ── Panels de formulario ── */
.auth-form-panel {
  display: none;
  animation: authFadeIn 0.3s ease;
}

.auth-form-panel.active {
  display: block;
}

@keyframes authFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Campos ── */
.auth-field {
  margin-bottom: 16px;
  position: relative;
}

.auth-field label {
  display: block;
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #1A1A1A;
  margin-bottom: 7px;
  font-weight: 500;
}

.auth-field input {
  width: 100%;
  background: #FAFAFA;
  border: 1px solid #E0E0E0;
  color: #1A1A1A;
  padding: 13px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.25s ease, background 0.25s ease;
  -webkit-appearance: none;
  border-radius: 0;
}

.auth-field input:focus {
  border-color: #E4C590;
  background: #FFFDF8;
  box-shadow: 0 0 0 3px rgba(228, 197, 144, 0.12);
}

.auth-field input::placeholder {
  color: #BBBBBB;
}

.auth-field input.error-input {
  border-color: #e05252 !important;
}

/* Ícono de ojo para contraseña */
.auth-field .toggle-pw {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: #AAAAAA;
  font-size: 16px;
  background: none;
  border: none;
  padding: 4px;
  margin-top: 10px;
  line-height: 1;
  transition: color 0.2s;
}

.auth-field .toggle-pw:hover { color: #E4C590; }

/* Mensaje de error inline */
.auth-field-error {
  font-size: 10px;
  color: #e05252;
  margin-top: 5px;
  display: none;
  letter-spacing: 0.3px;
}

.auth-field.has-error .auth-field-error {
  display: block;
}

/* Recordarme / Olvidé contraseña */
.auth-row-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #555;
  cursor: pointer;
}

.auth-check-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #E4C590;
  cursor: pointer;
}

.auth-forgot {
  font-size: 12px;
  color: #E4C590;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
  background: none;
  border: none;
  font-family: 'DM Sans', sans-serif;
}

.auth-forgot:hover { color: #c9a870; }

/* ── Botón principal ── */
.auth-btn-primary {
  width: 100%;
  background: #E4C590;
  border: none;
  color: #1A1A1A;
  padding: 15px 24px;
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.2s ease;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.auth-btn-primary:hover {
  background: #c9a870;
  transform: translateY(-1px);
}

.auth-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Spinner dentro del botón */
.auth-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: #1A1A1A;
  border-radius: 50%;
  animation: authSpin 0.6s linear infinite;
  display: none;
}

.auth-spinner.visible { display: inline-block; }

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

/* ── Divisor "o continúa con" ── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: #CCCCCC;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #E8E8E8;
}

/* ── Botones OAuth — Google y Facebook ── */
.auth-social-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.auth-btn-social {
  width: 100%;
  background: #ffffff;
  border: 1px solid #E0E0E0;
  color: #1A1A1A;
  padding: 13px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 0;
}

.auth-btn-social:hover {
  background: #FAFAFA;
  border-color: #CCCCCC;
  transform: translateY(-1px);
}

.auth-btn-social svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.auth-btn-social.google:hover { border-color: #4285F4; }
.auth-btn-social.facebook:hover { border-color: #1877F2; }

/* ── Botón invitado ── */
.auth-btn-guest {
  width: 100%;
  background: transparent;
  border: none;
  color: #777777;
  padding: 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
}

.auth-btn-guest:hover { color: #1A1A1A; }

/* ── Toast de notificaciones ── */
.auth-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: #1A1A1A;
  color: #ffffff;
  padding: 14px 24px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  border-left: 3px solid #E4C590;
  z-index: 99999;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 90vw;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

.auth-toast.show {
  transform: translateX(-50%) translateY(0);
}

.auth-toast.error { border-left-color: #e05252; }
.auth-toast.success { border-left-color: #4CAF50; }

/* ── Modal recuperar contraseña ── */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
}

.auth-modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.auth-modal {
  background: #ffffff;
  padding: 40px 36px;
  max-width: 400px;
  width: 100%;
  position: relative;
  animation: authModalIn 0.3s ease;
}

@keyframes authModalIn {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.auth-modal h3 {
  font-family: 'Forum', serif;
  font-size: 22px;
  color: #1A1A1A;
  margin-bottom: 8px;
}

.auth-modal p {
  font-size: 13px;
  color: #666;
  margin-bottom: 20px;
  line-height: 1.6;
}

.auth-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  color: #999;
  cursor: pointer;
  line-height: 1;
}

.auth-modal-close:hover { color: #1A1A1A; }

/* ── Badge de usuario logueado en el header ── */
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  position: relative;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #E4C590;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Forum', serif;
  font-size: 15px;
  color: #1A1A1A;
  font-weight: 600;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid rgba(228,197,144,0.4);
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-name-label {
  font-size: 12px;
  color: #1A1A1A;
  font-weight: 500;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Dropdown del usuario */
.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: #ffffff;
  border: 1px solid rgba(228,197,144,0.25);
  min-width: 180px;
  z-index: 2000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.25s ease;
}

.user-badge:hover .user-dropdown,
.user-badge.open .user-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  transition: background 0.15s;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: 'DM Sans', sans-serif;
}

.user-dropdown-item:hover { background: #F7F4F0; }

.user-dropdown-item.danger { color: #e05252; }
.user-dropdown-item.danger:hover { background: #FFF5F5; }

.user-dropdown-divider {
  height: 1px;
  background: #F0F0F0;
  margin: 4px 0;
}

/* ── Indicador de sesión de invitado ── */
.guest-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #888;
  letter-spacing: 1px;
  padding: 6px 12px;
  border: 1px solid rgba(228,197,144,0.3);
  cursor: pointer;
  transition: all 0.2s;
}

.guest-badge:hover {
  border-color: #E4C590;
  color: #E4C590;
}

/* ── Responsive auth panel ── */
@media (max-width: 480px) {
  .auth-panel {
    padding: 28px 20px;
  }
  .auth-title {
    font-size: 22px;
  }
  .auth-logo img {
    height: 56px;
  }
  .auth-modal {
    padding: 28px 20px;
  }
  .auth-toast {
    font-size: 12px;
    padding: 12px 18px;
    white-space: normal;
    text-align: center;
    max-width: calc(100vw - 32px);
  }
  .auth-tabs {
    margin-bottom: 20px;
  }
}

/* ── Ocultar el botón header cuando hay sesión activa ── */
body.auth-logged .header .btn-secondary.auth-cta {
  display: none;
}

/* ── Animación de salida de auth-screen ── */
#auth-screen.exiting {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

/* ══════════════════════════════════════════════════════
   AUTO-LLENADO DE DATOS EN FORMULARIO DE RESERVACIÓN
   ══════════════════════════════════════════════════════ */

/* Banner de aviso de auto-llenado */
.res-autofill-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(201, 168, 76, 0.07);
  border: 1px solid rgba(201, 168, 76, 0.25);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  grid-column: 1 / -1;
  font-size: 12.5px;
  color: rgba(228, 197, 144, 0.85);
  line-height: 1.4;
}

.res-autofill-banner svg {
  flex-shrink: 0;
  opacity: 0.75;
  color: #c9a84c;
}

.res-autofill-banner strong {
  color: #e4c590;
  font-weight: 600;
}

/* Badge "✓ de tu cuenta" junto al label del campo auto-llenado */
.res-autofill-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  font-size: 10px;
  letter-spacing: 0.5px;
  color: rgba(201, 168, 76, 0.7);
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  text-transform: none;
}

/* Highlight sutil en inputs auto-llenados */
.res-autofill-banner ~ .res-form-group #res-nombre:not(:placeholder-shown),
.res-autofill-banner ~ .res-form-group #res-email:not(:placeholder-shown) {
  border-color: rgba(201, 168, 76, 0.35);
}

/* Responsive: banner ocupa ancho completo en mobile */
@media (max-width: 600px) {
  .res-autofill-banner {
    font-size: 12px;
    padding: 9px 12px;
  }
}
