/* ==========================================================================
   QUOMYA — EDITOR DE VENTAS V1
   Wave S4.4C. Scoped entirely to `.sale-editor-backdrop.qy-theme`.

   Deliberadamente NO se toca la estructura HTML del editor: la sincronía
   agregado/componentes (aggregatePaymentDirty, syncAggregatePaymentFromLines,
   normalizeAggregateControlsToTotal…) en salesEditor.module.js localiza cada
   control por id/data-attribute docenas de veces. Preservación >
   simplificación -- este fichero solo repinta lo que measurement mostró
   realmente en blanco: la tarjeta del modal y las filas del historial usan
   literales `#FFFFFF`/`rgba(248,250,252,.82)` con !important pensados para
   las superficies claras sin migrar, que ganan por orden de carga incluso a
   `var(--rt-surface) !important`. Cada override de aquí iguala esa prioridad.
   ========================================================================== */

.sale-editor-backdrop.qy-theme {
  color-scheme: dark;
}

.sale-editor-backdrop.qy-theme .sale-editor-card,
.sale-editor-backdrop.qy-theme .sale-modal-card {
  background: var(--qy-color-surface-1) !important;
  color: var(--qy-color-text-primary) !important;
}

.sale-editor-backdrop.qy-theme .sale-editor-header span {
  color: var(--qy-color-text-tertiary);
  font: var(--qy-text-label-md);
  letter-spacing: var(--qy-tracking-label);
  text-transform: uppercase;
}

.sale-editor-backdrop.qy-theme .sale-editor-header h3 {
  color: var(--qy-color-text-primary) !important;
}

.sale-editor-backdrop.qy-theme .editor-cancelled-warning {
  color: var(--qy-color-pending-text) !important;
  background: var(--qy-color-pending-soft) !important;
  border: 1px solid var(--qy-color-pending);
  border-radius: var(--qy-radius-md);
  padding: var(--qy-space-3) var(--qy-space-4);
}

.sale-editor-backdrop.qy-theme .form-field label {
  color: var(--qy-color-text-secondary) !important;
}

/*
 * `.form-field input/select/textarea` trae un fondo blanco al 82% de opacidad
 * literal (no una variable), así que el repintado de qy-theme no lo alcanza.
 */
.sale-editor-backdrop.qy-theme .form-field input,
.sale-editor-backdrop.qy-theme .form-field select,
.sale-editor-backdrop.qy-theme .form-field textarea {
  background: var(--qy-color-surface-2) !important;
  color: var(--qy-color-text-primary) !important;
  border: 1px solid var(--qy-color-border-interactive) !important;
}

.sale-editor-backdrop.qy-theme .form-field input:focus,
.sale-editor-backdrop.qy-theme .form-field select:focus,
.sale-editor-backdrop.qy-theme .form-field textarea:focus {
  background: var(--qy-color-surface-3) !important;
  border-color: var(--qy-color-brand) !important;
  box-shadow: var(--qy-focus-ring) !important;
}

.sale-editor-backdrop.qy-theme .editor-sale-block,
.sale-editor-backdrop.qy-theme .editor-component-row,
.sale-editor-backdrop.qy-theme .editor-preview-card {
  background: var(--qy-color-surface-2) !important;
  border: 1px solid var(--qy-color-border-strong) !important;
  color: var(--qy-color-text-primary) !important;
}

.sale-editor-backdrop.qy-theme .editor-block-heading strong {
  color: var(--qy-color-text-primary) !important;
}

.sale-editor-backdrop.qy-theme .editor-block-heading span {
  color: var(--qy-color-text-secondary) !important;
}

/*
 * Bug preexistente y ajeno al tema: `ux-simple.css` fija `.empty-mini` en
 * `display: grid` con especificidad de autor, que gana al `display: none`
 * de `[hidden]` (origen user-agent). El aviso "Sin subventas" quedaba
 * visible incluso con subventas reales presentes. Se corrige solo dentro del
 * editor migrado, sin tocar la lógica de salesEditor.module.js.
 */
.sale-editor-backdrop.qy-theme .empty-mini[hidden] {
  display: none !important;
}

.sale-editor-backdrop.qy-theme .empty-mini {
  background: var(--qy-color-surface-2) !important;
  border: 1px dashed var(--qy-color-border-interactive) !important;
  color: var(--qy-color-text-secondary) !important;
}

.sale-editor-backdrop.qy-theme .empty-mini strong {
  color: var(--qy-color-text-primary) !important;
}

.sale-editor-backdrop.qy-theme #editor-total-preview {
  color: var(--qy-color-brand-text) !important;
}

.sale-editor-backdrop.qy-theme #editor-total-detail,
.sale-editor-backdrop.qy-theme .editor-preview-card > span {
  color: var(--qy-color-text-secondary) !important;
}

.sale-editor-backdrop.qy-theme .editor-history-panel {
  color: var(--qy-color-text-secondary) !important;
}

/*
 * Igual problema, distinto literal: `rgba(248,250,252,.82)` en las filas del
 * historial de ediciones.
 */
.sale-editor-backdrop.qy-theme .editor-history-list article {
  background: var(--qy-color-surface-2) !important;
  border: 1px solid var(--qy-color-border) !important;
  color: var(--qy-color-text-primary) !important;
}

.sale-editor-backdrop.qy-theme .editor-history-list article strong {
  color: var(--qy-color-text-primary) !important;
}

.sale-editor-backdrop.qy-theme .editor-history-list article span {
  color: var(--qy-color-text-secondary) !important;
}

/*
 * Tres fallos de contraste reales medidos (WCAG AA, 4.5:1 mínimo a 12-14px):
 *
 * 1-2. `.danger-btn` usa el ancla roja cruda (--qy-color-cancelled,
 *    #EF4444) en vez de la variante de texto ya AA-safe
 *    (--qy-color-cancelled-text, #F87171) que qy-tokens-v1.css documenta
 *    exactamente para este caso.
 * 3. `.primary-btn` usa `color: var(--rt-ink) !important` (blanco) sobre
 *    relleno de marca. El propio comentario de accesibilidad en
 *    qy-tokens-v1.css lo advierte: "White on brand measures 2.33:1... text
 *    on a brand fill is always --qy-color-text-on-brand (7.07:1)".
 */
.sale-editor-backdrop.qy-theme .danger-btn {
  color: var(--qy-color-cancelled-text) !important;
}

.sale-editor-backdrop.qy-theme .primary-btn {
  color: var(--qy-color-text-on-brand) !important;
}

@media (max-width: 559px) {
  .sale-editor-backdrop.qy-theme .editor-sale-block,
  .sale-editor-backdrop.qy-theme .editor-component-row {
    padding: var(--qy-space-3) !important;
  }
}
