/* =========================================================
   Elemental W — UI Components
   Componentes visuales reutilizables.
   Depende de: design-tokens.css
   ========================================================= */

/* ---------- Base ---------- */

.ew-ui {
  color: var(--ew-color-text);
  font-family: var(--ew-font-body);
}

.ew-container {
  width: min(calc(100% - (var(--ew-space-5) * 2)), var(--ew-container-lg));
  margin-inline: auto;
}

/* ---------- Botones ---------- */

.ew-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ew-space-2);

  min-height: 44px;
  padding: 0.75rem 1.25rem;

  border: 1px solid transparent;
  border-radius: var(--ew-radius-pill);

  font: inherit;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;

  cursor: pointer;

  transition:
    background-color var(--ew-transition-fast),
    border-color var(--ew-transition-fast),
    color var(--ew-transition-fast),
    transform var(--ew-transition-fast),
    box-shadow var(--ew-transition-fast);
}

.ew-button:hover {
  transform: translateY(-1px);
}

.ew-button:active {
  transform: translateY(1px) scale(0.98);
}

.ew-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ew-color-focus) 28%, transparent);
  outline-offset: 3px;
}

.ew-button--primary {
  background: var(--ew-color-primary);
  color: var(--ew-color-text-inverse);
}

.ew-button--primary:hover {
  background: var(--ew-color-primary-hover);
  box-shadow: var(--ew-shadow-sm);
}

.ew-button--secondary {
  background: var(--ew-color-surface);
  border-color: var(--ew-color-border-strong);
  color: var(--ew-color-plum);
}

.ew-button--secondary:hover {
  border-color: var(--ew-color-magenta);
  background: var(--ew-color-primary-soft);
}

.ew-button:disabled,
.ew-button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

/* ---------- Cards ---------- */

.ew-card {
  padding: var(--ew-space-5);

  background: var(--ew-color-surface);
  border: 1px solid var(--ew-color-border);
  border-radius: var(--ew-radius-lg);
  box-shadow: var(--ew-shadow-sm);
}

.ew-card--interactive {
  transition:
    transform var(--ew-transition-base),
    box-shadow var(--ew-transition-base),
    border-color var(--ew-transition-base);
}

.ew-card--interactive:hover {
  transform: translateY(-3px);
  border-color: var(--ew-color-coral);
  box-shadow: var(--ew-shadow-md);
}

.ew-card__eyebrow {
  margin: 0 0 var(--ew-space-2);

  color: var(--ew-color-magenta);
  font-size: var(--ew-text-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ew-card__title {
  margin: 0;

  color: var(--ew-color-plum);
  font-family: var(--ew-font-heading);
  font-size: var(--ew-text-2xl);
  line-height: 1.15;
}

.ew-card__description {
  margin: var(--ew-space-3) 0 0;

  color: var(--ew-color-text-muted);
  line-height: 1.6;
}

/* ---------- Badges ---------- */

.ew-badge {
  display: inline-flex;
  align-items: center;

  padding: 0.4rem 0.7rem;

  border-radius: var(--ew-radius-pill);
  background: var(--ew-color-primary-soft);
  color: var(--ew-color-magenta);

  font-size: var(--ew-text-xs);
  font-weight: 700;
}

/* ---------- Filtros ---------- */

.ew-filter {
  min-height: 42px;
  padding: 0.65rem 2.25rem 0.65rem 0.9rem;

  border: 1px solid var(--ew-color-border);
  border-radius: var(--ew-radius-md);
  background: var(--ew-color-surface);
  color: var(--ew-color-text);

  font: inherit;
}

.ew-filter:hover {
  border-color: var(--ew-color-coral);
}

.ew-filter:focus-visible {
  border-color: var(--ew-color-focus);
  outline: 3px solid color-mix(in srgb, var(--ew-color-focus) 18%, transparent);
}

/* ---------- Usuario ---------- */

.ew-user {
  display: inline-flex;
  align-items: center;
  gap: var(--ew-space-3);
}

.ew-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;

  border-radius: 50%;
  background: var(--ew-color-magenta);
  color: var(--ew-color-text-inverse);

  font-weight: 800;
}

/* ---------- Navegación global y cuenta ---------- */

.ew-site-header {
  position: sticky;
  top: 0;
  z-index: 100;

  border-bottom: 1px solid rgb(234 214 204 / 75%);
  background: rgb(255 250 246 / 92%);
  backdrop-filter: blur(16px);
}

.ew-site-header__content {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--ew-space-6);
  align-items: center;

  min-height: 76px;
}

.ew-site-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--ew-space-3);

  color: var(--ew-color-plum);

  font-family: var(--ew-font-display);
  font-size: var(--ew-text-xl);
  text-decoration: none;
}

.ew-site-brand:focus-visible {
  border-radius: var(--ew-radius-sm);
  outline: 3px solid color-mix(in srgb, var(--ew-color-focus) 28%, transparent);
  outline-offset: 4px;
}

.ew-site-brand__logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.ew-site-nav {
  display: flex;
  justify-content: center;
  gap: var(--ew-space-5);
}

.ew-site-nav__link {
  position: relative;

  color: var(--ew-color-text-muted);

  font-size: var(--ew-text-sm);
  font-weight: 700;
  text-decoration: none;

  transition: color var(--ew-transition-fast);
}

.ew-site-nav__link:hover {
  color: var(--ew-color-magenta);
}

.ew-site-nav__link:focus-visible {
  border-radius: var(--ew-radius-sm);
  outline: 3px solid color-mix(in srgb, var(--ew-color-focus) 28%, transparent);
  outline-offset: 3px;
}

.ew-site-nav__link.is-active,
.ew-site-nav__link[aria-current="page"] {
  color: var(--ew-theme-ink);
  font-weight: 800;
}

.ew-site-nav__link.is-active::after,
.ew-site-nav__link[aria-current="page"]::after {
  position: absolute;
  right: 0;
  bottom: -0.45rem;
  left: 0;

  height: 2px;

  border-radius: var(--ew-radius-pill);
  background: var(--ew-color-magenta);

  content: "";
}

.ew-site-session {
  display: flex;
  align-items: center;
  justify-content: flex-end;

  /* Reserva espacio para que resolver la sesión no cause layout shift */
  min-width: 168px;
}

.ew-site-session__login {
  min-height: 40px;
  padding: 0.65rem 1rem;

  font-size: var(--ew-text-sm);
}

.ew-account[hidden],
.ew-site-session__login[hidden] {
  display: none;
}

.ew-account {
  position: relative;
}

.ew-account__trigger {
  padding: 0.35rem 0.75rem;

  border: 0;
  border-radius: var(--ew-radius-pill);

  background: transparent;
  box-shadow: none;
  color: inherit;

  font: inherit;
  cursor: pointer;

  appearance: none;
}

.ew-account__trigger:hover {
  background: color-mix(in srgb, var(--ew-theme-surface) 28%, transparent);
}

.ew-account__trigger:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ew-color-focus) 22%, transparent);
  outline-offset: 3px;
}

.ew-account__text {
  display: grid;
  gap: 0.2rem;

  text-align: right;
}

.ew-account__text strong,
.ew-account__text span {
  display: block;
}

.ew-account__text strong {
  max-width: 180px;

  overflow: hidden;

  font-size: var(--ew-text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ew-account__text span {
  color: var(--ew-color-text-muted);

  font-size: var(--ew-text-xs);
  line-height: 1.2;
}

.ew-account__menu {
  position: absolute;
  top: calc(100% + 0.65rem);
  right: 0;
  z-index: 120;

  display: grid;
  gap: 0.45rem;

  width: min(300px, calc(100vw - 2rem));
  padding: 1rem;

  border: 1px solid
    color-mix(in srgb, var(--ew-theme-surface) 60%, var(--ew-color-border));
  border-radius: var(--ew-radius-md);

  background: var(--ew-color-surface);
  box-shadow: var(--ew-shadow-sm);
}

.ew-account__menu[hidden] {
  display: none;
}

.ew-account__menu-label {
  color: var(--ew-theme-accent);

  font-size: var(--ew-text-xs);
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.ew-account__menu-email {
  overflow-wrap: anywhere;

  color: var(--ew-theme-ink);

  font-size: var(--ew-text-sm);
}

.ew-account__menu-role {
  color: var(--ew-color-text-muted);

  font-size: var(--ew-text-xs);
}

.ew-account__divider {
  height: 1px;
  margin: 0.05rem 0;

  border: 0;
  background: color-mix(
    in srgb,
    var(--ew-theme-surface) 40%,
    var(--ew-color-border)
  );
}

.ew-account__nav {
  display: grid;
  gap: 0.1rem;
}

.ew-account__nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;

  margin-inline: -0.5rem;
  padding: 0.5rem;

  border-radius: var(--ew-radius-sm);

  color: var(--ew-color-text);

  font-size: var(--ew-text-sm);
  font-weight: 700;
  text-decoration: none;

  transition:
    background-color var(--ew-transition-fast),
    color var(--ew-transition-fast);
}

.ew-account__nav-icon {
  display: inline-flex;
  flex: 0 0 auto;
}

.ew-account__nav-label {
  flex: 1 1 auto;
  min-width: 0;
}

.ew-account__nav-arrow {
  flex: 0 0 auto;

  opacity: 0.65;

  transition: transform var(--ew-transition-fast);
}

.ew-account__nav-link:hover,
.ew-account__nav-link:focus-visible {
  background: color-mix(in srgb, var(--ew-theme-surface) 30%, transparent);
  color: var(--ew-color-magenta);
}

.ew-account__nav-link:hover .ew-account__nav-arrow,
.ew-account__nav-link:focus-visible .ew-account__nav-arrow {
  transform: translateX(2px);
}

.ew-account__nav-link:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ew-color-focus) 24%, transparent);
  outline-offset: 2px;
}

.ew-account__nav-link[hidden] {
  display: none;
}

.ew-account__logout {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;

  min-height: 36px;
  margin-inline: -0.5rem;
  padding: 0.45rem 0.5rem;

  border: 0;
  border-radius: var(--ew-radius-sm);

  background: transparent;
  color: var(--ew-color-text-muted);

  font: inherit;
  font-size: var(--ew-text-xs);
  font-weight: 700;

  cursor: pointer;

  transition:
    background-color var(--ew-transition-fast),
    color var(--ew-transition-fast);
}

.ew-account__logout-icon {
  display: inline-flex;
  flex: 0 0 auto;
}

.ew-account__logout:hover,
.ew-account__logout:focus-visible {
  background: color-mix(in srgb, var(--ew-theme-surface) 30%, transparent);
  color: var(--ew-color-magenta);
}

.ew-account__logout:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ew-color-focus) 20%, transparent);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .ew-site-header__content {
    grid-template-columns: 1fr auto;
  }

  .ew-site-nav {
    display: none;
  }
}

@media (max-width: 720px) {
  .ew-site-session {
    min-width: 96px;
  }

  .ew-account__text {
    display: none;
  }

  .ew-account__logout {
    padding-inline: 0.55rem;
  }

  .ew-account__menu {
    right: 0;
    width: min(280px, calc(100vw - 1.5rem));
  }

  .ew-site-session__login {
    min-height: 38px;
    padding-inline: 0.8rem;

    font-size: var(--ew-text-xs);
  }
}

@media (max-width: 640px) {
  .ew-site-header__content {
    min-height: 68px;
  }

  .ew-site-brand span {
    font-size: var(--ew-text-lg);
  }
}

/* ---------- Accesibilidad ---------- */

@media (prefers-reduced-motion: reduce) {
  .ew-button,
  .ew-card--interactive {
    transition: none;
  }

  .ew-button:hover,
  .ew-button:active,
  .ew-card--interactive:hover {
    transform: none;
  }
}
