/**
 * fractionne-styles.css
 * Styles pour [ktm_fractionne] et [ktm_fractionne_config]
 */

/* ════════════════════════════════════════════
   TABLEAU DE SÉLECTION (vue publique)
════════════════════════════════════════════ */
.ktmf-wrap {
    font-family: 'Poppins', sans-serif;
    margin: 24px 0;
    /* min-width:0 : évite qu'un parent flex/grid (Elementor, thème) s'élargisse à la taille du tableau */
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.ktmf-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #1a5276;
    display: inline-block;
}

/* ── Wrapper scrollable du tableau ──────── */
.ktmf-table-scroll {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 12px;
    /* Scrollbar fine, visible au survol */
    scrollbar-width: thin;
    scrollbar-color: #FF7700 #f3f4f6;
}
.ktmf-table-scroll::-webkit-scrollbar { height: 4px; }
.ktmf-table-scroll::-webkit-scrollbar-track { background: #f3f4f6; border-radius: 10px; }
.ktmf-table-scroll::-webkit-scrollbar-thumb { background: #FF7700; border-radius: 10px; }

/* ── Tableau ──────────────────────────────── */
.ktmf-table {
    table-layout: fixed;   /* colonnes de plans égales, jamais plus large que le conteneur */
    /* Peu de plans : le tableau ne s'étire pas sur toute la largeur (libellés + n plans de 150 px max) */
    width: min(100%, calc(76px + var(--ktmf-cols, 3) * 150px));
    border-collapse: collapse;
    font-size: 13px;
}

.ktmf-table thead th {
    padding: 10px 8px 12px;
    text-align: center;
    font-weight: 500;
    color: #374151;
    vertical-align: bottom;
}
.ktmf-th-label { text-align: left !important; width: 76px; }

.ktmf-table td,
.ktmf-table th {
    border-top: 1px solid #f3f4f6;
    padding: 10px 8px;
    text-align: center;
    color: #6b7280;
}
.ktmf-table thead th { border-top: none; }

.ktmf-row-label {
    text-align: left !important;
    font-weight: 500;
    color: #374151 !important;
    white-space: nowrap;
    padding-left: 0 !important;
    width: 60px;
}

/* ── Colonne recommandée (1re) ───────────── */
.ktmf-col-first {
    background: #fff3e6;
}
.ktmf-col-first .ktmf-plan-times { color: #CC5E00; }
.ktmf-col-first .ktmf-montant-main { color: #CC5E00; }

.ktmf-col-first-bot {
    border-radius: 0 0 8px 8px;
}

/* ── Colonne active (sélectionnée) ──────── */
.ktmf-col-active {
    background: #eaf3de !important;
}
.ktmf-col-active .ktmf-plan-times { color: #27500A !important; }
.ktmf-col-active .ktmf-montant-main { color: #27500A !important; }

/* ── En-tête de plan ─────────────────────── */
.ktmf-badge-recommande {
    display: block;
    font-size: 10px;
    font-weight: 600;
    background: #FF7700;
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 20px;
    margin-bottom: 6px;
}

.ktmf-plan-times {
    display: block;
    font-size: 24px;
    font-weight: 900;
    color: #111827;
}

/* ── Montant par tranche ─────────────────── */
.ktmf-montant-main {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

/* ── Surplus affiché en petit ────────────── */
.ktmf-surplus {
    display: block;
    font-size: 11px;
    color: #92400e;
    margin-top: 2px;
}

/* ── Boutons "Choisir" ───────────────────── */
.ktmf-btn-row td {
    padding-bottom: 8px;
    border-bottom: none;
}

.ktmf-choose-btn {
    width: 100%;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
}
.ktmf-choose-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}
.ktmf-choose-btn.ktmf-choose-active {
    background: #FF7700;
    color: #FFFFFF;
    border-color: #914503;
}

/* ── Bouton "Se connecter" pour les invités ── */
.ktmf-login-btn {
    display: block;
    width: 100%;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #FF7700;
    background: #fff3e6;
    color: #CC5E00;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    box-sizing: border-box;
}
.ktmf-login-btn:hover {
    background: #FF7700;
    color: #ffffff;
}

/* ── Note informative ────────────────────── */
.ktmf-info-note {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 12px;
    color: #6b7280;
    background: #f9fafb;
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 4px;
}
.ktmf-info-note svg { flex-shrink: 0; margin-top: 1px; }

/* ── Message non connecté ────────────────── */
.ktmf-login-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 13px;
    color: #6b7280;
}
.ktmf-login-notice a { color: #1a5276; font-weight: 600; text-decoration: none; }
.ktmf-login-notice a:hover { text-decoration: underline; }

/* ════════════════════════════════════════════
   ÉCRAN DE CONFIRMATION
════════════════════════════════════════════ */
.ktmf-confirm-block {
    background: #f9fafb;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 16px;
}
.ktmf-confirm-title {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 14px;
}
.ktmf-confirm-grid { display: flex; flex-direction: column; }

.ktmf-confirm-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e5e7eb;
}
.ktmf-confirm-row:last-child { border-bottom: none; }

.ktmf-confirm-row-highlight {
    background: #eaf3de;
    margin: 0 -18px;
    padding: 10px 18px;
    border-bottom: none !important;
}
.ktmf-confirm-row-highlight .ktmf-confirm-label,
.ktmf-confirm-row-highlight .ktmf-confirm-val { color: #27500A; }

.ktmf-confirm-label { font-size: 13px; color: #6b7280; }
.ktmf-confirm-val   { font-size: 13px; font-weight: 600; color: #111827; }

.ktmf-confirm-notice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 14px;
    background: #fef3c7;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
    color: #92400e;
}
.ktmf-confirm-notice svg { flex-shrink: 0; margin-top: 1px; color: #d97706; }

.ktmf-confirm-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 4px;
}

.ktmf-btn-primary,
.ktmf-btn-secondary {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s;
}
.ktmf-btn-primary { background: #FF7700; color: #ffffff; }
.ktmf-btn-primary:hover { opacity: 0.88; }
.ktmf-btn-primary:disabled { background: #9ca3af; cursor: not-allowed; }
.ktmf-btn-secondary { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.ktmf-btn-secondary:hover { background: #e5e7eb; }
.ktmf-btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Feedback AJAX ───────────────────────── */
#ktmf-feedback {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    line-height: 1.5;
}
.ktmf-feedback-success { background: #dcfce7; color: #166534; }
.ktmf-feedback-error   { background: #fee2e2; color: #991b1b; }
.ktmf-recharge-link    { color: #FF7700; font-weight: 600; text-decoration: underline; }

/* ════════════════════════════════════════════
   INTERFACE DE CONFIGURATION (admin/vendeur)
════════════════════════════════════════════ */
.ktmf-config-wrap {
    font-family: 'Poppins', sans-serif;
    background: #f8fafc;
    border: 1.5px dashed #cbd5e1;
    border-radius: 12px;
    padding: 20px;
    margin: 24px 0;
}

.ktmf-config-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.ktmf-config-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}
.ktmf-config-title svg { color: #64748b; }

.ktmf-config-badge {
    font-size: 11px;
    font-weight: 600;
    background: #1e293b;
    color: #94a3b8;
    padding: 2px 10px;
    border-radius: 20px;
}

/* ── Plans existants ─────────────────────── */
.ktmf-config-plan-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 8px;
    transition: border-color 0.15s;
}
.ktmf-config-plan-row:hover { border-color: #94a3b8; }

.ktmf-config-plan-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.ktmf-config-plan-times {
    font-size: 15px;
    font-weight: 700;
    color: #1a5276;
    flex-shrink: 0;
    min-width: 32px;
}

.ktmf-config-plan-detail {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ktmf-delete-plan-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.ktmf-delete-plan-btn:hover { color: #dc2626; background: #fee2e2; }

.ktmf-config-empty {
    font-size: 13px;
    color: #94a3b8;
    text-align: center;
    padding: 12px 0;
}

/* ── Formulaire d'ajout ──────────────────── */
.ktmf-config-add-block {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.ktmf-config-add-title {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 12px;
}

.ktmf-config-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.ktmf-config-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 120px;
}
.ktmf-config-field label {
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.ktmf-config-field input {
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #111827;
    background: #ffffff;
    width: 100%;
}
.ktmf-config-field input:focus {
    outline: none;
    border-color: #1a5276;
    box-shadow: 0 0 0 3px rgba(26, 82, 118, 0.1);
}

.ktmf-btn-add {
    padding: 9px 18px;
    background: #FF7700;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s;
    align-self: flex-end;
}
.ktmf-btn-add:hover { opacity: 0.88; }
.ktmf-btn-add:disabled { background: #9ca3af; cursor: not-allowed; }

#ktmf-config-feedback {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 600px) {
    .ktmf-confirm-actions { flex-direction: column; }
    .ktmf-config-form { flex-direction: column; }
    .ktmf-config-plan-detail { display: none; }

    /* Jusqu'à 3 plans : tout tient sans défilement, dès 320 px de large */
    .ktmf-table { font-size: 11px; }
    .ktmf-th-label { width: 66px; }
    .ktmf-table { width: min(100%, calc(66px + var(--ktmf-cols, 3) * 112px)); }
    .ktmf-table td,
    .ktmf-table th { padding: 8px 3px; overflow-wrap: anywhere; }
    .ktmf-table thead th { padding: 8px 3px 10px; }
    .ktmf-row-label {
        white-space: normal;
        font-size: 11px;
        padding-left: 0 !important;
        width: auto;
    }
    .ktmf-plan-times { font-size: 20px; }
    .ktmf-montant-main { font-size: 13px; white-space: nowrap; }
    .ktmf-period { font-size: 10px; }
    .ktmf-badge-recommande { font-size: 8px; padding: 2px 2px; margin-bottom: 4px; white-space: nowrap; letter-spacing: -.2px; }
    .ktmf-choose-btn { padding: 7px 2px; font-size: 11px; }
    .ktmf-info-note { font-size: 11px; }
    .ktmf-custom { flex-direction: column; align-items: stretch; text-align: center; }
    .ktmf-custom-btn { width: 100%; }

    /* Plus de 3 plans (palier mixte) : on garde des colonnes lisibles et le tableau défile */
    .ktmf-many .ktmf-table { min-width: calc(66px + var(--ktmf-cols, 4) * 84px); }
}

/* ── Apparition douce (remplace fadeIn de jQuery) ── */
@keyframes ktmf-in { from { opacity: 0; } to { opacity: 1; } }
.ktmf-anim-in { animation: ktmf-in .18s ease-out; }
@media (prefers-reduced-motion: reduce) { .ktmf-anim-in { animation: none; } }

/* ── Paiement direct Mobile Money ── */
.ktmf-confirm-actions { flex-wrap: wrap; }
.ktmf-btn-mm { flex: 1 1 100%; order: -1; }
.ktmf-btn-primary:disabled, .ktmf-btn-secondary:disabled { opacity: .6; cursor: not-allowed; }
.ktmf-btn-secondary.ktmf-as-secondary { background: transparent; }

/* ════════════════════════════════════════════
   8.9.0 — Fractionnement automatique
════════════════════════════════════════════ */
.ktmf-period {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: #6b7280;
    margin-top: 2px;
}

/* « Payer le montant de mon choix » : suite du tableau */
.ktmf-custom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed #e5e7eb;
}
.ktmf-custom-text {
    font-size: 13px;
    color: #6b7280;
}
.ktmf-custom-btn {
    padding: 9px 16px;
    border-radius: 8px;
    border: 1.5px solid #FF7700;
    background: #ffffff;
    color: #CC5E00;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.ktmf-custom-btn:hover,
.ktmf-custom-btn:focus-visible {
    background: #FF7700;
    color: #ffffff;
}

/* Bouton « Se connecter » d'un visiteur (ouvre le simulateur) */
button.ktmf-login-btn {
    width: 100%;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #374151;
    cursor: pointer;
}
