/* ARCHIVAGE-286 — clôture et comptage des espèces.
 *
 * Classes de la caisse (comptage du tiroir, journées à clôturer, fenêtre de
 * clôture, contrôle espèces d'une journée clôturée), réutilisables par les
 * écrans pos du même parcours. Jetons uniquement : aucune couleur littérale
 * (cliquet hex), aucun des six composants pds-* redéfini.
 *
 * Chargée par base.html APRÈS pilote-components.css : le préfixe
 * `html body.pds-admin` égale la spécificité des composants, l'ordre départage.
 * Hors précache, comme les autres feuilles PDS (cache-first versionné par ?v=).
 */

/* ── Page étroite ─────────────────────────────────────────────────── */
html body.pds-admin .cx-narrow-page { max-width: 560px; margin: 0 auto; padding: 16px; }
html body.pds-admin .cx-page-title { font-family: var(--font-display); font-size: 1.4rem; margin-bottom: 4px; }
html body.pds-admin .cx-page-lead { color: var(--pds-ref-muted); font-size: 0.85rem; margin-bottom: 16px; }
html body.pds-admin .cx-page-note { font-size: 0.85rem; margin-bottom: 12px; }
html body.pds-admin .cx-section-title { font-family: var(--font-display); font-size: 1rem; margin: 20px 0 8px; }
html body.pds-admin .cx-section-title--spaced { margin-top: 24px; }
html body.pds-admin .cx-back { margin-top: 20px; font-size: 0.85rem; }

/* ── Messages ─────────────────────────────────────────────────────── */
html body.pds-admin .cx-flash {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 0.85rem;
}
html body.pds-admin .cx-flash--success { background: var(--pds-success-soft); color: var(--success-700); }
html body.pds-admin .cx-flash--warning { background: var(--pds-warning-soft); color: var(--warning-700); }
html body.pds-admin .cx-flash--danger { background: var(--pds-danger-soft); color: var(--studio-danger-ink, var(--pds-ref-danger)); }

/* ── Panneaux, lignes de contrôle, choix de comptage ──────────────── */
html body.pds-admin .cx-panel {
    background: var(--pds-ref-subtle);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}
html body.pds-admin .cx-control-row { display: flex; justify-content: space-between; gap: 8px; }
html body.pds-admin .cx-control-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
html body.pds-admin .cx-control-stack > form { display: flex; margin: 0; }
html body.pds-admin .cx-close-counted { align-items: center; justify-content: flex-end; gap: 6px; }
html body.pds-admin .cx-declared-cash {
    width: 120px; padding: 6px 8px; border: 1px solid var(--pds-ref-border);
    border-radius: 6px; font-size: 0.8rem; text-align: right;
}
/* Journées à clôturer au téléphone : la ligne devient une carte (`.phone-cards`),
 * les commandes prennent la largeur de la carte — libellés entiers, cibles ≥ 44 px,
 * plus de colonne d'actions cachée dans le défilement horizontal du tableau. */
@media (max-width: 767.98px) {
    html body.pds-admin .phone-cards .cx-control-stack { width: 100%; align-items: stretch; }
    html body.pds-admin .phone-cards .cx-control-stack > form { width: 100%; }
    html body.pds-admin .phone-cards .cx-control-stack button { flex: 1 1 auto; white-space: normal; }
    html body.pds-admin .phone-cards .cx-close-counted .cx-declared-cash { flex: 1 1 0; width: auto; min-width: 0; min-height: 44px; }
    html body.pds-admin .phone-cards .cx-count-now { justify-content: center; text-align: center; }
}
html body.pds-admin .cx-setting-form { display: flex; flex-direction: column; gap: 8px; font-size: 0.85rem; }
html body.pds-admin .cx-setting-form > p { margin: 0; }
/* Option « clôturer sans compter » : un cadre, un texte d'aide, une action pleine largeur. */
html body.pds-admin .cx-count-choice {
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
html body.pds-admin .cx-inline-form { display: inline-flex; margin: 0; }
html body.pds-admin .cx-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* ── Textes et liens ──────────────────────────────────────────────── */
html body.pds-admin .cx-help { font-size: 0.82rem; color: var(--text-secondary); }
html body.pds-admin :is(p.cx-help, .cx-help > p) { margin: 0 0 10px; }
html body.pds-admin .cx-link { color: var(--pds-ref-link); }
html body.pds-admin .cx-link--compact { font-size: 0.8rem; padding: 6px 0; }
html body.pds-admin table :is(th, td).cx-num { text-align: right; }

/* ── Actions ──────────────────────────────────────────────────────── */
html body.pds-admin .cx-block-action { display: flex; width: 100%; justify-content: center; }
html body.pds-admin .cx-block-action--capped { max-width: 360px; margin-bottom: 20px; }

/* ── Contrôle espèces d'une journée clôturée (cash_check_rows) ────── */
html body.pds-admin .cx-check-label { color: var(--text-secondary); }
html body.pds-admin .cx-check-value { font-weight: 600; }
html body.pds-admin .cx-check-note { color: var(--text-secondary); font-style: italic; }
html body.pds-admin .cx-diff { font-weight: 700; }
html body.pds-admin .cx-diff--zero { color: var(--studio-success-ink, var(--pds-success)); }
html body.pds-admin .cx-diff--plus { color: var(--pds-ref-link); }
html body.pds-admin .cx-diff--minus { color: var(--studio-danger-ink, var(--pds-ref-danger)); }

/* ── Encaissement tardif (ARCHIVAGE-286 P1) ───────────────────────── */
html body.pds-admin .cx-kpi-hint { display: block; margin-top: 2px; font-size: 11px; opacity: 0.75; }
html body.pds-admin .cx-pay-received { margin: -2px 0 6px; font-size: 12px; color: var(--text-secondary); }

/* ── ARCHIVAGE-286 P2 : historique des clôtures fiscales ──────────── */
html body.pds-admin .cx-fiscal-page { max-width: 720px; margin: 0 auto; padding: 16px; }
html body.pds-admin .cx-fiscal-status > p { margin: 0 0 6px; }
html body.pds-admin .cx-fiscal-ok { color: var(--studio-success-ink, var(--pds-success)); font-weight: 600; }
html body.pds-admin .cx-fiscal-groups { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
html body.pds-admin .cx-fiscal-card { margin-bottom: 12px; }
html body.pds-admin .cx-fiscal-card__head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; font-weight: 600; }
html body.pds-admin .cx-fiscal-figures {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 6px 12px;
    margin: 0;
    font-size: 0.85rem;
}
html body.pds-admin .cx-fiscal-figures > div { min-width: 0; }
html body.pds-admin .cx-fiscal-figures dt { color: var(--text-secondary); }
html body.pds-admin .cx-fiscal-figures dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
html body.pds-admin .cx-fiscal-figures__treasury,
html body.pds-admin .cx-fiscal-figures__cumul { border-top: 1px solid var(--border); padding-top: 6px; }
html body.pds-admin .cx-fiscal-list { margin: 0 0 12px; padding-left: 18px; font-size: 0.85rem; }
html body.pds-admin .cx-fiscal-hash code { overflow-wrap: anywhere; font-size: 0.75rem; }

/* ── CAISSE-JOURNEE-MANUELLE : reste à répartir ─────────────────
 * Composant caisse/partials/_payment_split.html (jour ouvert et jour clos).
 * Cibles tactiles ≥ 44 px au téléphone ; montants alignés à droite. */
html body.pds-admin .cx-paysplit-total { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
html body.pds-admin .cx-paysplit-total-value { font-size: 1.1rem; font-weight: 700; }
html body.pds-admin .cx-paysplit-item { margin-bottom: 8px; }
html body.pds-admin .cx-paysplit-line { display: flex; align-items: center; gap: 8px; }
html body.pds-admin .cx-paysplit-method { flex: 1; min-width: 0; min-height: 44px; }
html body.pds-admin .cx-paysplit-amount { width: 120px; min-height: 44px; text-align: right; font-variant-numeric: tabular-nums; }
html body.pds-admin .cx-paysplit-amount[aria-invalid="true"] { border-color: var(--pds-ref-danger); }
html body.pds-admin .cx-paysplit-unit { font-size: 0.8rem; color: var(--text-secondary); }
html body.pds-admin .cx-paysplit-remove {
    min-width: 44px; min-height: 44px; background: none; border: none;
    font-size: 1.2rem; color: var(--text-secondary); cursor: pointer;
}
html body.pds-admin .cx-paysplit-add { margin-top: 4px; min-height: 44px; }
html body.pds-admin .cx-paysplit-summary { margin: 14px 0 4px; border-top: 1px solid var(--border); padding-top: 10px; }
html body.pds-admin .cx-paysplit-row { display: flex; justify-content: space-between; font-size: 0.9rem; padding: 2px 0; }
html body.pds-admin .cx-paysplit-row dd { margin: 0; font-variant-numeric: tabular-nums; }
html body.pds-admin .cx-paysplit-rest { font-weight: 700; font-size: 1rem; }
html body.pds-admin .cx-paysplit-rest--exact { color: var(--studio-success-ink, var(--pds-success)); }
html body.pds-admin .cx-paysplit-rest--over { color: var(--studio-danger-ink, var(--pds-ref-danger)); }
html body.pds-admin .cx-paysplit-status { font-size: 0.85rem; color: var(--text-secondary); margin: 4px 0 0; }
html body.pds-admin [data-split-submit]:disabled { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 767px) {
    html body.pds-admin .cx-paysplit-amount { width: 104px; }
}

/* ── CAISSE-JOURNEE-MANUELLE : bandeau d'ouverture de journée ─── */
html body.pds-admin .cx-window { margin-bottom: 12px; }
html body.pds-admin .cx-window--open { border-left: 4px solid var(--pds-success); }
html body.pds-admin .cx-window-title { font-weight: 700; margin: 0 0 4px; }
html body.pds-admin .cx-window-meta { font-size: 0.85rem; color: var(--text-secondary); margin: 0 0 10px; }
html body.pds-admin .cx-window-action { min-height: 44px; }
/* Page de ventilation : la colonne de la grille ne s'élargit jamais au-delà
 * de l'écran (sinon débordement à 320 px, recette WebKit). */
html body.pds-admin .cx-paysplit-page { grid-template-columns: minmax(0, 1fr); }
html body.pds-admin .cx-paysplit-page > * { min-width: 0; }
/* Écrans < 360 px (modale caisse : ~224 px utiles) : le moyen de paiement prend
 * sa propre ligne, montant + unité + retrait dessous — rien ne sort du cadre. */
@media (max-width: 359.98px) {
    html body.pds-admin .cx-paysplit-line { flex-wrap: wrap; row-gap: 6px; }
    html body.pds-admin .cx-paysplit-method { flex: 1 1 100%; }
    html body.pds-admin .cx-paysplit-amount { flex: 1 1 0%; width: auto; min-width: 0; }
}
