/* Estructura y estilos del componente de usuario */
.user-drawer {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-light);
  box-sizing: border-box;
}

/* Modo Drawer en Escritorio */
@media (min-width: 769px) {
  .user-drawer--desktop-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    width: 100%;
    max-width: 400px;
    border-left: 1px solid var(--border-light);
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.2);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s ease;
  }

  .user-drawer--desktop-drawer.user-drawer--open {
    transform: translateX(0);
    visibility: visible;
  }
}

/* Modo Dropdown en Escritorio */
@media (min-width: 769px) {
  .user-drawer--desktop-dropdown {
    position: absolute;
    top: calc(100% + 0.65rem);
    right: 0;
    z-index: 1100;
    width: 380px;
    max-height: calc(100vh - 5.5rem);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  }

  .user-drawer--desktop-dropdown.user-drawer--open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .user-drawer--desktop-dropdown .user-drawer__header {
    height: 3.5rem;
    padding: 0 1.25rem;
  }

  .user-drawer--desktop-dropdown .user-drawer__body {
    padding: 1.25rem;
    max-height: calc(100vh - 9.5rem);
  }
}

/* Modal Centrado en Móvil */
@media (max-width: 768px) {
  .user-drawer--mobile-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -46%) scale(0.96);
    width: min(420px, calc(100vw - 2rem));
    max-height: min(640px, calc(100vh - 3rem));
    z-index: 1100;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
  }

  .user-drawer--mobile-modal.user-drawer--open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
  }

  .user-drawer--mobile-modal .user-drawer__header {
    height: 3.5rem;
    padding: 0 1.25rem;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
  }

  .user-drawer--mobile-modal .user-drawer__body {
    padding: 1.25rem;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
  }

  /* Drawer Lateral en Móvil */
  .user-drawer--mobile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    width: 100%;
    max-width: 88vw;
    border-left: 1px solid var(--border-light);
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.25);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s ease;
  }

  .user-drawer--mobile-drawer.user-drawer--open {
    transform: translateX(0);
    visibility: visible;
  }

  .user-drawer--mobile-drawer .user-drawer__header {
    height: 3.5rem;
    padding: 0 1.25rem;
  }

  .user-drawer--mobile-drawer .user-drawer__body {
    padding: 1.25rem;
  }
}

/* Capa de fondo oscurecida */
.user-drawer__overlay {
  position: fixed;
  inset: 0;
  z-index: 1050;
  background-color: var(--overlay-bg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.user-drawer__overlay--visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

@media (min-width: 769px) {
  .user-drawer--desktop-dropdown ~ .user-drawer__overlay {
    display: none !important;
  }
}

/* Cabecera del panel */
.user-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
  padding: 0 1.5rem;
  background-color: var(--primary);
  border-bottom: 1px solid var(--primary-hover);
  flex-shrink: 0;
}

.user-drawer__header-title-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.user-drawer__header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-lg);
  line-height: 1;
  color: var(--accent);
  flex-shrink: 0;
}

.user-drawer__title {
  margin: 0;
  color: var(--text-inverse);
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
  white-space: nowrap;
}

.user-drawer__close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  color: var(--text-inverse);
  font-size: var(--fs-lg);
  line-height: 1;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.user-drawer__close-btn:hover {
  color: var(--accent);
  background-color: var(--primary-hover);
}

.user-drawer__close-btn:focus-visible {
  outline: 2px solid var(--accent);
}

/* Cuerpo y contenedor de secciones */
.user-drawer__body {
  flex: 1 1 auto;
  padding: 1.5rem;
  overflow-y: auto;
  background-color: var(--bg-light);
  -webkit-overflow-scrolling: touch;
}

.user-drawer__body::-webkit-scrollbar {
  width: 5px;
}

.user-drawer__body::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 4px;
}

.user-drawer__section--hidden,
.user-drawer-form--hidden {
  display: none !important;
}

.user-drawer-form__honeypot {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Pestañas de acceso */
.user-auth-tabs {
  display: flex;
  align-items: center;
  position: relative;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-light);
}

.user-auth-tabs__tab {
  flex: 1;
  position: relative;
  height: 2.75rem;
  padding: 0 0.75rem;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: center;
  background-color: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.2s ease;
}

.user-auth-tabs__tab::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: transparent;
  transition: background-color 0.2s ease;
}

.user-auth-tabs__tab:hover {
  color: var(--text);
}

.user-auth-tabs__tab--active {
  color: var(--primary);
}

.user-auth-tabs__tab--active::after {
  background-color: var(--primary);
}

.user-auth-tabs__tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

/* Formularios y campos de entrada */
.user-drawer-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.user-drawer-form__subtitle {
  margin: 0 0 0.25rem;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.user-drawer-form__group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.user-drawer-form__label {
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.3;
}

.user-drawer-form__input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.user-drawer-form__icon {
  position: absolute;
  left: 0.875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-md);
  line-height: 1;
  color: var(--placeholder);
  pointer-events: none;
  transition: color 0.2s ease;
}

.user-drawer-form__input {
  width: 100%;
  height: 2.75rem;
  padding: 0 0.875rem 0 2.5rem;
  color: var(--text);
  font-size: var(--fs-sm);
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  outline: none;
  box-sizing: border-box;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.user-drawer-form__input--password {
  padding-right: 2.625rem;
}

.user-drawer-form__input::placeholder {
  color: var(--placeholder);
  font-weight: 400;
  font-size: var(--fs-sm);
}

.user-drawer-form__input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

.user-drawer-form__input-wrap:focus-within .user-drawer-form__icon {
  color: var(--primary);
}

.user-drawer-form__toggle-pwd {
  position: absolute;
  right: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--text-muted);
  font-size: var(--fs-md);
  line-height: 1;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.user-drawer-form__toggle-pwd:hover {
  color: var(--text);
}

.user-drawer-form__toggle-pwd:focus-visible {
  outline: 2px solid var(--primary);
}

.user-drawer-form__submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 2.75rem;
  padding: 0 1rem;
  margin-top: 0.25rem;
  color: var(--text-inverse);
  font-size: var(--fs-sm);
  font-weight: 700;
  background-color: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: 0 3px 0 var(--accent-hover);
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.user-drawer-form__submit-btn:hover {
  background-color: var(--accent-hover);
}

.user-drawer-form__submit-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Tarjeta de perfil y sesión activa */
.user-profile-card {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  margin-bottom: 1.25rem;
  background-color: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
}

.user-profile-card__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  flex-shrink: 0;
  color: var(--primary);
  background-color: var(--bg-dark);
  border: 1px solid var(--border-light);
  border-radius: 8px;
}

.user-profile-card__avatar i {
  font-size: var(--fs-lg);
  line-height: 1;
}

.user-profile-card__info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-profile-card__greeting {
  margin: 0 0 0.125rem;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-profile-card__greeting strong {
  color: var(--primary);
  font-weight: 700;
}

.user-profile-card__email {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-drawer__logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  height: 2.75rem;
  padding: 0 1rem;
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  background-color: transparent;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.user-drawer__logout-btn i {
  font-size: var(--fs-md);
  line-height: 1;
}

.user-drawer__logout-btn:hover {
  color: var(--error);
  border-color: var(--error);
  background-color: var(--bg-dark);
}

.user-drawer__logout-btn:focus-visible {
  outline: 2px solid var(--error);
}

/* Mensajes de feedback y estado */
.user-drawer__feedback,
.user-drawer-form__feedback {
  margin-top: 0.25rem;
}

.user-drawer__feedback:empty,
.user-drawer-form__feedback:empty {
  display: none;
}

.user-drawer__feedback--info,
.user-drawer-form__feedback--info,
.user-drawer__feedback--success,
.user-drawer-form__feedback--success,
.user-drawer__feedback--error,
.user-drawer-form__feedback--error {
  padding: 0.75rem 1rem;
  font-size: var(--fs-xs);
  line-height: 1.4;
  background-color: var(--bg-light);
  border: 1px solid var(--border-light);
  border-left-width: 4px;
  border-radius: 6px;
}

.user-drawer__feedback--info,
.user-drawer-form__feedback--info {
  color: var(--info);
  border-left-color: var(--info);
  background-color: var(--bg);
}

.user-drawer__feedback--success,
.user-drawer-form__feedback--success {
  color: var(--success);
  border-left-color: var(--success);
  background-color: var(--bg);
}

.user-drawer__feedback--error,
.user-drawer-form__feedback--error {
  color: var(--error);
  font-weight: 500;
  border-left-color: var(--error);
  background-color: var(--bg);
}