/* Modales de Autenticación - Versión Corregida */
.auth-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 380px;
  max-height: 90vh;
  background-color: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  z-index: 1001;
  display: none; /* Importante: por defecto oculto */
  flex-direction: column;
  overflow: hidden;
}

/* Modal de registro más ancho para acomodar más campos */
.auth-modal#registerModal {
  max-width: 500px;
}

.auth-modal.open {
  display: flex; /* Solo mostrar cuando tenga la clase open */
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -60%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.auth-modal-header {
  background: linear-gradient(135deg, var(--primary-color), #d63384);
  color: white;
  padding: 1rem 1.5rem;
  text-align: center;
  position: relative;
  flex-shrink: 0;
}

.auth-modal-header h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
}

.close-auth-modal {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  z-index: 1002; /* Asegurar que esté por encima */
}

.close-auth-modal:hover {
  background: rgba(255, 255, 255, 0.2);
}

.auth-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-weight: 500;
  color: var(--text-color);
  font-size: 0.85rem;
}

.form-group input {
  padding: 0.7rem 0.875rem;
  border: 2px solid #e9ecef;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  background-color: #f8f9fa;
}

.form-group select {
  padding: 0.7rem 0.875rem;
  border: 2px solid #e9ecef;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  background-color: #f8f9fa;
  cursor: pointer;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  background-color: white;
  box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.1);
}

.form-group input.error,
.form-group select.error {
  border-color: #dc3545;
  background-color: #fff5f5;
}

/* Secciones del formulario */
.form-section {
  border-bottom: 1px solid #e9ecef;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-section:last-of-type {
  border-bottom: none;
  margin-bottom: 1rem;
}

.form-section h3 {
  color: #333;
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #f8f9fa;
}

.form-error {
  color: #dc3545;
  font-size: 0.75rem;
  margin-top: 0.25rem;
  display: none;
  line-height: 1.3;
}

.form-error.show {
  display: block;
}

.auth-submit-btn {
  background: linear-gradient(135deg, var(--primary-color), #d63384);
  color: white;
  border: none;
  padding: 0.875rem 1rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
  margin-top: 0.5rem;
}

.auth-submit-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(230, 57, 70, 0.3);
}

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

.auth-submit-btn .loading-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 0.5rem;
}

.auth-submit-btn.loading .loading-spinner {
  display: inline-block;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.auth-switch {
  text-align: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e9ecef;
}

.auth-switch p {
  margin: 0 0 0.5rem 0;
  color: #666;
  font-size: 0.85rem;
}

.auth-switch-btn {
  background: none;
  border: none;
  color: var(--primary-color);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.85rem;
  transition: color 0.2s;
}

.auth-switch-btn:hover {
  color: #d63384;
}

.password-requirements {
  background: #f8f9fa;
  border-radius: 4px;
  padding: 0.5rem;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: #666;
}

/* Fila de campos inline */
.form-row {
  display: flex;
  gap: 0.75rem;
}

.form-row .form-group {
  flex: 1;
}

/* User menu dropdown */
.user-menu {
  position: relative;
  display: inline-block;
}

.user-menu-toggle {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}

.user-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.user-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  min-width: 180px;
  z-index: 1000;
  display: none;
  overflow: hidden;
  margin-top: 0.5rem;
}

.user-menu-dropdown.open {
  display: block;
  animation: dropdownSlideIn 0.2s ease-out;
}

@keyframes dropdownSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-menu-item {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  background: none;
  text-align: left;
  color: var(--text-color);
  cursor: pointer;
  transition: background-color 0.2s;
  font-size: 0.9rem;
  text-decoration: none;
}

.user-menu-item:hover {
  background: #f8f9fa;
  color: var(--text-color);
}

.user-menu-item i {
  margin-right: 0.5rem;
  width: 16px;
}

.login-prompt {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.login-btn,
.register-btn {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
}

.login-btn:hover,
.register-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  color: white;
  text-decoration: none;
}

.register-btn {
  background: white;
  color: var(--primary-color);
  border-color: white;
}

.register-btn:hover {
  background: #f8f9fa;
  color: var(--primary-color);
}

/* Responsive */
@media (max-width: 480px) {
  .auth-modal {
    width: 95%;
    max-width: none;
    max-height: 95vh;
  }

  .auth-modal-body {
    padding: 1.25rem;
  }

  .auth-modal-header {
    padding: 0.875rem 1.25rem;
  }

  .form-row {
    flex-direction: column;
    gap: 1rem;
  }
}

@media (max-height: 600px) {
  .auth-modal {
    max-height: 95vh;
  }

  .auth-modal-body {
    padding: 1rem;
  }

  .auth-form {
    gap: 0.75rem;
  }
}

/* =====================
   Perfil: estilo igual a modal de pedidos
   ===================== */
#profileModal.auth-modal {
  max-width: 800px;
  width: 90%;
  padding: 0; /* quitar cualquier padding interno */
  box-shadow: 0 10px 40px rgba(0,0,0,.3);
}

#profileModal .auth-modal-content { /* por compatibilidad si existe wrapper */
  background:#fff;
  display:flex;
  flex-direction:column;
  height:100%;
  max-height:80vh;
  overflow:hidden;
}

#profileModal .auth-modal-header {
  background: linear-gradient(135deg, var(--primary-color, #e63946), #d63384);
  color:#fff;
  padding:1.5rem;
  margin:0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  text-align:left;
  border-bottom: none;
}

#profileModal .auth-modal-header h2 { margin:0; font-size:1.45rem; font-weight:600; }
#profileModal .close-auth-modal { top: .75rem; right:1rem; }

#profileModal .auth-form {
  padding:1.5rem 1.5rem 1.25rem;
  overflow-y:auto;
  flex:1;
  gap:1rem;
}

#profileModal .form-group label { font-size:.8rem; font-weight:600; }
#profileModal .form-group input { background:#f8f9fa; }
#profileModal .form-row, #profileModal .form-grid { display:flex; gap:1rem; }
#profileModal .form-row .form-group, #profileModal .form-grid .form-group { flex:1; }

#profileModal .auth-submit-btn { margin-top:.25rem; }

/* Scrollbar consistente */
#profileModal .auth-form::-webkit-scrollbar { width:8px; }
#profileModal .auth-form::-webkit-scrollbar-track { background:#f1f1f1; }
#profileModal .auth-form::-webkit-scrollbar-thumb { background:#c5c5c5; border-radius:4px; }
#profileModal .auth-form::-webkit-scrollbar-thumb:hover { background:#b0b0b0; }
#profileModal .auth-form { scrollbar-width:thin; scrollbar-color:#c5c5c5 #f1f1f1; }

@media (max-width:640px){
  #profileModal.auth-modal { max-width:95%; }
  #profileModal .form-row, #profileModal .form-grid { flex-direction:column; gap:1rem; }
}
