/* =========================================================
   RAMDA EXPORT — Style de la fenêtre de réglages d'export
   Fichier : ramda-export.css  (à charger avec ramda-export.js)

   Ce fichier ne style QUE la fenêtre « Exporter » (classes rx-*).
   L'aperçu et l'impression des documents (classes rxd-*) sont stylés par
   ramda-export.js lui-même : le rendu écran et le rendu imprimé restent
   ainsi identiques.

   Les couleurs reprennent les variables de l'application
   (--color-teal, --color-gray-border, --color-gray-medium, --color-ink,
   --color-white, --font-sans) avec des valeurs de secours.
   ========================================================= */

/* ============================================================
   1. CONTENEUR
   ============================================================ */
.rx-win {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    /* Les onglets restent fixes : seul le panneau de réglages défile */
    max-height: min(72vh, 640px);
    max-height: min(72dvh, 640px);
    font-family: var(--font-sans, inherit);
    font-size: 13px;
    color: var(--color-ink, #111827);
}

.rx-win.is-busy {
    pointer-events: none;
    opacity: 0.7;
}

/* ============================================================
   2. CHOIX DU FORMAT (onglets)
   ============================================================ */
.rx-formats {
    position: sticky;
    top: 0;
    z-index: 2;
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 0 0 2px;
    background: var(--color-white, #fff);
    border-bottom: 1px solid var(--color-gray-border, #E5E7EB);
    -webkit-overflow-scrolling: touch;
}

/* Onglet vertical : icône au-dessus, texte en dessous */
.rx-fmt {
    flex: 1 1 0;
    min-width: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 10px 7px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--color-gray-medium, #6B7280);
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
}

.rx-fmt i {
    font-size: 22px;
    line-height: 1;
}

/* Couleurs d'icône par format (l'onglet actif prend la couleur de l'application) */
.rx-fmt[data-rx-fmt="pdf"] i { color: #DC2626; }
.rx-fmt[data-rx-fmt="excel"] i { color: #16A34A; }
.rx-fmt[data-rx-fmt="word"] i { color: #2563EB; }
.rx-fmt[data-rx-fmt="csv"] i { color: #0D9488; }
.rx-fmt[data-rx-fmt="print"] i { color: #4B5563; }

.rx-fmt:hover {
    color: var(--color-ink, #111827);
    background: rgba(17, 24, 39, 0.04);
}

.rx-fmt.is-active {
    border-bottom-color: var(--color-teal, #0E7C86);
    color: var(--color-teal, #0E7C86);
    font-weight: 600;
}

.rx-fmt:focus-visible {
    outline: 2px solid var(--color-teal, #0E7C86);
    outline-offset: -2px;
    border-radius: 4px;
}

/* ============================================================
   3. SECTIONS ET LIGNES DE RÉGLAGES
   ============================================================ */
.rx-panel {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
    padding-right: 2px;
}

.rx-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rx-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--color-gray-medium, #6B7280);
}

.rx-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.rx-row[hidden] {
    display: none;
}

.rx-label {
    font-weight: 500;
}

.rx-hint {
    margin: 0;
    font-size: 11px;
    color: var(--color-gray-medium, #6B7280);
}

.rx-fmt-hint {
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(14, 124, 134, 0.08);
}

.rx-loading {
    margin: 0;
    padding: 18px 0;
    text-align: center;
    color: var(--color-gray-medium, #6B7280);
}

/* ============================================================
   4. CHAMPS
   ============================================================ */
.rx-input,
.rx-select {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--color-gray-border, #D1D5DB);
    border-radius: 8px;
    background: var(--color-white, #fff);
    color: inherit;
    font: inherit;
}

.rx-input:focus,
.rx-select:focus {
    outline: none;
    border-color: var(--color-teal, #0E7C86);
    box-shadow: 0 0 0 3px rgba(14, 124, 134, 0.15);
}

.rx-row-number .rx-input {
    max-width: 140px;
}

.rx-color {
    max-width: 64px;
    height: 38px;
    padding: 3px;
    cursor: pointer;
}

/* --- Case à cocher --- */
.rx-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.rx-check input {
    flex-shrink: 0;
    width: auto;
    margin: 0;
}

/* --- Choix à boutons (même présentation que les Styles de tableau) --- */
.rx-seg {
    display: inline-flex;
    align-self: flex-start;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid var(--color-gray-border, #E5E7EB);
    border-radius: 8px;
}

.rx-seg label {
    position: relative;
    cursor: pointer;
}

.rx-seg label + label {
    border-left: 1px solid var(--color-gray-border, #E5E7EB);
}

.rx-seg input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.rx-seg span {
    display: block;
    padding: 7px 14px;
    background: var(--color-white, #fff);
    font-size: 12px;
    white-space: nowrap;
}

.rx-seg input:checked + span {
    background: var(--color-teal, #0E7C86);
    color: #fff;
}

.rx-seg input:focus-visible + span {
    outline: 2px solid var(--color-teal, #0E7C86);
    outline-offset: -2px;
}

/* ============================================================
   5. MESSAGE D'ERREUR
   ============================================================ */
.rx-error {
    padding: 10px 12px;
    border: 1px solid #FCA5A5;
    border-radius: 8px;
    background: #FEF2F2;
    color: #991B1B;
    font-size: 12px;
}

/* Message d'information (ex. « Appuyez à nouveau sur Envoyer ») */
.rx-error.is-info {
    border-color: #93C5FD;
    background: #EFF6FF;
    color: #1E40AF;
}

.rx-error {
    flex: 0 0 auto;
}

.rx-error[hidden] {
    display: none;
}

/* ============================================================
   6. FENÊTRE DE SECOURS
   (utilisée seulement si showGlobalPopup n'existe pas)
   ============================================================ */
.rx-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(17, 24, 39, 0.5);
}

.rx-modal-box {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 520px;
    max-height: 100%;
    border-radius: 12px;
    background: var(--color-white, #fff);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    font-family: var(--font-sans, inherit);
}

.rx-modal-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--color-gray-border, #E5E7EB);
    font-size: 15px;
}

.rx-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
}

.rx-modal-foot {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--color-gray-border, #E5E7EB);
}

.rx-modal-foot button {
    padding: 9px 16px;
    border: 1px solid var(--color-gray-border, #D1D5DB);
    border-radius: 8px;
    background: var(--color-white, #fff);
    font: inherit;
    cursor: pointer;
}

.rx-modal-foot .btn-primary {
    border-color: var(--color-teal, #0E7C86);
    background: var(--color-teal, #0E7C86);
    color: #fff;
}

.rx-modal-foot button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ============================================================
   7. MOBILE
   (police des champs à 16px : évite le zoom automatique de l'écran
   quand on touche un champ sur iPhone / Android)
   ============================================================ */
@media (max-width: 480px) {
    .rx-input,
    .rx-select {
        font-size: 16px;
    }

    .rx-seg {
        align-self: stretch;
    }

    .rx-seg label {
        flex: 1;
        text-align: center;
    }

    .rx-row-number .rx-input {
        max-width: none;
    }

    .rx-modal {
        align-items: flex-end;
        padding: 0;
    }

    .rx-modal-box {
        max-width: none;
        border-radius: 14px 14px 0 0;
    }
}
