/**
 * Historial de Ukupuntos — Mi Cuenta.
 * Sin colores fijos: se usa currentColor/opacity para heredar el tema activo
 * (claro/oscuro) sin depender de variables CSS del tema que no podemos verificar.
 * Un único conjunto de columnas por fila; el media query solo reordena/oculta,
 * no duplica contenido.
 */

.ukupoints-history {
  display: block;
  width: 100%;
}

.ukupoints-history__row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr 1fr;
  gap: 8px 16px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid currentColor;
}

.ukupoints-history__row--head {
  font-weight: 600;
  opacity: .75;
}

.ukupoints-history__col {
  min-width: 0;
  overflow-wrap: break-word;
}

.ukupoints-history__col--points {
  font-weight: 700;
}

.ukupoints-history__col--order a {
  color: inherit;
  text-decoration: underline;
}

.ukupoints-history__col--order:empty::before,
.ukupoints-history__col--expiry:empty::before {
  content: "\2013"; /* – */
  opacity: .6;
}

/* UX-5: desglose de caducidad de un restore repartido entre varios lotes/estados. Nativo
   (details/summary), sin JS, operable por teclado y sin depender de hover -- válido tanto en
   escritorio como en móvil, a diferencia de un tooltip/title. */
.ukupoints-history__expiry-detail {
  display: inline-block;
}

.ukupoints-history__expiry-detail summary {
  cursor: pointer;
  text-decoration: underline dotted;
  list-style: none;
}

.ukupoints-history__expiry-detail summary::-webkit-details-marker {
  display: none;
}

.ukupoints-history__expiry-list {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  font-size: .9em;
  opacity: .85;
}

.ukupoints-history__expiry-list li {
  padding: 2px 0;
}

/* Etiqueta accesible: siempre en el DOM, visualmente oculta en desktop
   (donde la cabecera de columna ya da contexto) y visible en móvil
   (donde no hay cabecera). No es contenido duplicado: es la misma
   etiqueta, solo se cambia su presentación visual por viewport. */
.ukupoints-history__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Separación entre el menú de Mi Cuenta y el título del historial, en tablet y móvil
   (no en desktop ancho). Ancla en nuestra propia clase (.ukupoints-history), sin depender
   de wrappers de Astra ni tocar Account.php para añadir una clase al <h3>. 900px es un
   umbral razonable de "tablet e inferior"; el resto del layout de columnas de escritorio
   se mantiene sin cambios hasta 600px (ver bloque siguiente). */
@media (max-width: 900px) {
  h3:has(+ .ukupoints-history) {
    margin-top: 28px;
  }
}

/* 0.4.0 -- dashboard de Mi Cuenta (Account::balance_block()). Mismo criterio que el resto del
   archivo: sin colores fijos salvo el azul de marca puntual, namespace propio. */
.ukupoints-dashboard {
  border: 1px solid currentColor;
  border-radius: 8px;
  padding: 14px 18px;
  margin: 0 0 24px;
  max-width: 420px;
}

.ukupoints-dashboard__title {
  margin: 0 0 6px;
  font-weight: 600;
}

.ukupoints-dashboard__balance {
  margin: 0 0 4px;
  font-size: 1.05em;
}

.ukupoints-dashboard__expiry {
  margin: 0 0 10px;
  opacity: 0.75;
  font-size: 0.9em;
}

.ukupoints-dashboard__empty-copy {
  margin: 0 0 10px;
  opacity: 0.85;
}

.ukupoints-dashboard__links {
  margin: 0;
}

.ukupoints-dashboard__link {
  /* Corrección QA 0.4.0: usaba #0000ff hardcodeado (se veía como el azul por defecto del
     navegador, distinto del acento real del theme) -- ahora consume la variable global de Astra,
     con el mismo valor actual como fallback solo por si el tema no la definiera. */
  color: var(--ast-global-color-0, #0085ff);
  text-decoration: none;
  font-weight: 600;
}

.ukupoints-dashboard__link:hover {
  text-decoration: underline;
}

.ukupoints-dashboard__link:focus-visible {
  outline: 2px solid var(--ast-global-color-0, #0085ff);
  outline-offset: 2px;
}

/* 0.4.0 -- resumen superior del endpoint (Account::render_summary()). */
.ukupoints-summary {
  margin: 0 0 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid currentColor;
}

.ukupoints-summary__title {
  margin: 0 0 8px;
  font-weight: 700;
  font-size: 1.1em;
}

.ukupoints-summary__balance {
  margin: 0 0 2px;
}

.ukupoints-summary__balance-number {
  font-size: 1.6em;
  font-weight: 800;
}

.ukupoints-summary__value {
  margin: 0 0 12px;
  opacity: 0.8;
}

.ukupoints-summary__expiry {
  margin: 0 0 12px;
}

.ukupoints-summary__expiry-title {
  margin: 0;
  font-weight: 600;
  font-size: 0.9em;
  opacity: 0.75;
}

.ukupoints-summary__expiry-detail {
  margin: 2px 0 0;
}

.ukupoints-summary__empty-copy {
  margin: 0 0 12px;
  opacity: 0.85;
}

.ukupoints-summary__actions {
  margin: 0 0 4px;
}

.ukupoints-summary__action {
  /* Corrección QA 0.4.0: mismo motivo que .ukupoints-dashboard__link -- ver ese comentario. */
  color: var(--ast-global-color-0, #0085ff);
  text-decoration: none;
  font-weight: 600;
}

.ukupoints-summary__action:hover {
  text-decoration: underline;
}

.ukupoints-summary__action:focus-visible {
  outline: 2px solid var(--ast-global-color-0, #0085ff);
  outline-offset: 2px;
}

/* 0.4.0 -- "¿Cómo funcionan los Ukupuntos?" (details/summary nativo, mismo patrón accesible que
   .ukupoints-history__expiry-detail: sin JS, operable por teclado, sin depender de hover). */
.ukupoints-how {
  margin-top: 12px;
}

.ukupoints-how summary {
  cursor: pointer;
  font-weight: 600;
  text-decoration: underline dotted;
  list-style: none;
}

.ukupoints-how summary::-webkit-details-marker {
  display: none;
}

.ukupoints-how summary:focus-visible {
  outline: 2px solid #0000ff;
  outline-offset: 2px;
}

.ukupoints-how__rules {
  margin: 10px 0 0;
  padding-left: 20px;
}

.ukupoints-how__rules li {
  margin-bottom: 4px;
}

.ukupoints-how__extra {
  margin: 10px 0 0;
  opacity: 0.85;
  font-size: 0.92em;
}

.ukupoints-history__heading {
  margin-top: 0;
}

@media (max-width: 600px) {
  .ukupoints-dashboard {
    max-width: none;
  }

  /* Corrección QA móvil 0.4.0: el resumen "Mis Ukupuntos" quedaba pegado al menú de Mi Cuenta de
     WooCommerce en móvil (en escritorio ya estaba bien). Solo margin-top -- no se toca el resto
     del shorthand "margin" de la regla base (0 0 28px), que sigue aplicando su margen inferior y
     el resto de la regla sin cambios; no afecta a desktop/tablet (>600px) ni al menú de Woo. */
  .ukupoints-summary {
    margin-top: 24px;
  }


  /* Especificidad igual a la de .ukupoints-history__row (0,1,0) hacía que esta
     regla perdiera el empate por orden de aparición y no llegara a ocultar la
     cabecera. Selector compuesto (0,2,0): gana siempre, con independencia del
     orden de las reglas. */
  .ukupoints-history__row.ukupoints-history__row--head {
    display: none;
  }

  .ukupoints-history__row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 3px;
    padding: 14px 0;
  }

  .ukupoints-history__col--points { order: 1; font-size: 1.15em; }
  .ukupoints-history__col--type   { order: 2; opacity: .85; }
  .ukupoints-history__col--order  { order: 3; }
  .ukupoints-history__col--date   { order: 4; margin-top: 10px; opacity: .7; font-size: .85em; }
  .ukupoints-history__col--expiry { order: 5; opacity: .7; font-size: .85em; }

  .ukupoints-history__col--order:empty,
  .ukupoints-history__col--expiry:empty {
    display: none;
  }

  .ukupoints-history__label {
    position: static;
    width: auto;
    height: auto;
    padding: 0;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }
}
