/* ================= LOGIN MODAL ================= */

/* ===============================
   OVERLAY GENERAL
================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  z-index: 9998;
}

/* ===============================
   MODAL LOGIN / REGISTER
================================ */
.modal-login {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 95%;
  max-width: 420px;
  background: #ffffff;
  border-radius: 18px;
  padding: 35px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
  z-index: 9999;
  animation: modalFade 0.3s ease forwards;
}

/* Animación */
@keyframes modalFade {
  to {
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Header */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

.modal-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: #222;
}

.close-modal {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #888;
  transition: 0.3s;
}

.close-modal:hover {
  color: #d81b60;
}

/* ===============================
   FORMULARIO
================================ */
.modal-login form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.modal-login input {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #ddd;
  font-size: 14px;
  transition: 0.3s;
  outline: none;
}

.modal-login input:focus {
  border-color: #d81b60;
  box-shadow: 0 0 0 3px rgba(216, 27, 96, 0.15);
}

.login-subtitle {
  font-size: 14px;
  color: #666;
  margin-bottom: 10px;
}

.modal-login label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Botón principal */
.modal-login button[type="submit"] {
  margin-top: 10px;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #d81b60, #ff4081);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: 0.3s;
}

.modal-login button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(216, 27, 96, 0.4);
}

/* Texto extra */
.login-extra {
  margin-top: 18px;
  text-align: center;
  font-size: 14px;
}

.login-extra a {
  color: #d81b60;
  font-weight: 600;
  text-decoration: none;
}

.login-extra a:hover {
  text-decoration: underline;
}

.modal-payment { z-index: 10002; }
.modal-qr { z-index: 10002; }
.modal-login { z-index: 10002; }

/* ===== MOSTRAR LOGIN CUANDO JS AGREGA .open ===== */
#loginModal.open,
#registerModal.open {
  display: block;
}

#loginContent.open,
#registerContent.open {
  display: block;
}

.user-menu {
  position: relative;
}

.user-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 13px;
  font-weight: 600;
  padding: 0;
}

.user-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
}

#userNameText {
  font-size: 14px;
  font-weight: 600;
  display: inline-block;
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  background: white;
  width: 200px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  padding: 0;
  display: flex !important;
  flex-direction: column !important;
  z-index: 10000;
  margin-top: 8px;
  visibility: hidden;
  opacity: 0;
  border: 1px solid #f0f0f0;
  min-width: 180px;
  transition: opacity 0.2s, visibility 0.2s;
}

.user-dropdown a {
  display: block !important;
  padding: 12px 16px;
  text-decoration: none;
  color: #333;
  font-size: 14px;
  white-space: nowrap;
  width: 100%;
  box-sizing: border-box;
  border-bottom: 1px solid #f5f5f5;
  transition: background-color 0.2s ease;
}

.user-dropdown a:last-child {
  border-bottom: none;
}

.user-dropdown a:hover {
  background: #f9f9f9;
  color: #d81b60;
}

.logout {
  color: #d81b60 !important;
  font-weight: 600;
}

/* MOBILE - Mostrar dropdown solo con .active */
@media (max-width: 768px) {
  .user-menu.active .user-dropdown {
    visibility: visible !important;
    opacity: 1 !important;
  }
}

/* DESKTOP - Mostrar texto y dropdown al hover SOLO si está logueado */
@media (min-width: 769px) {
  #userNameText {
    display: block;
  }
  
  .user-btn {
    flex-direction: column;
  }

  .user-menu.logged-in:hover .user-dropdown,
  .user-menu.logged-in.active .user-dropdown {
    visibility: visible !important;
    opacity: 1 !important;
  }
}

.login-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-top: -5px;
}

.remember {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
}

.remember input {
  accent-color: #d81b60;
  width: 14px;
  height: 14px;
}

.forgot-link {
  color: #d81b60;
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

.forgot-link:hover {
  text-decoration: underline;
}

/* Compact login modal for mobile */
@media (max-width: 600px) {
  .modal-login {
    width: calc(100% - 20px);
    max-width: 360px;
    max-height: 82vh;
    overflow-y: auto;
    border-radius: 14px;
    padding: 16px 14px 14px;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.98);
  }

  .modal-header {
    margin-bottom: 12px;
  }

  .modal-header h2 {
    font-size: 18px;
    margin: 0;
  }

  .close-modal {
    font-size: 20px;
    line-height: 1;
  }

  .login-subtitle {
    font-size: 13px;
    margin-bottom: 8px;
  }

  .modal-login form {
    gap: 10px;
  }

  .modal-login label {
    font-size: 12px;
    margin-bottom: 3px;
  }

  .input-group {
    gap: 4px;
  }

  .modal-login input {
    padding: 10px 11px;
    font-size: 13px;
    border-radius: 8px;
  }

  .login-options {
    margin-top: 0;
    font-size: 12px;
    gap: 8px;
  }

  .remember {
    gap: 5px;
    font-size: 12px;
  }

  .remember input {
    width: 12px;
    height: 12px;
  }

  .forgot-link {
    font-size: 12px;
  }

  .modal-login button[type="submit"] {
    margin-top: 4px;
    padding: 10px;
    font-size: 14px;
    border-radius: 8px;
  }

  .login-extra {
    margin-top: 12px;
    font-size: 12px;
  }
}
