/* ==========================================================================
   Page Remises client — CRM Nielsen
   Style 2026 : noir profond, accent indigo, cartes douces, badges fins.
   ========================================================================== */

:root {
    --rm-noir: #0d0d0f;
    --rm-noir-soft: #17171b;
    --rm-gris-bord: #e6e6ea;
    --rm-gris-fond: #f7f7f9;
    --rm-accent: #6366f1;        /* indigo */
    --rm-accent-soft: #eef0ff;
    --rm-accent-dark: #4f46e5;
    --rm-texte-doux: #6b7280;
    --rm-vert: #10b981;
}

/* ---- Conteneur général ---- */
.remises_wrapper {
    max-width: 1100px;
    margin: 0 auto 50px auto;
    animation: rm_fade 0.4s ease;
}

@keyframes rm_fade {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- En-tête ---- */
.remises_head {
    margin-bottom: 30px;
}

.remises_head h2 {
    background: linear-gradient(135deg, var(--rm-noir) 0%, #26263a 100%);
    color: #fff;
    padding: 16px 28px;
    border-radius: 16px;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto 22px auto;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    box-shadow: 0 8px 24px rgba(13, 13, 15, 0.18);
    text-align: center;
}

.remises_code_client {
    font-weight: 500;
    opacity: 0.55;
    font-size: 0.7em;
    margin-left: 4px;
}

/* ---- Barre méta (stats + actions) ---- */
.remises_meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

/* petites "puces" de stats */
.rm_stat {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #fff;
    border: 1px solid var(--rm-gris-bord);
    padding: 9px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--rm-texte-doux);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.rm_stat strong {
    color: var(--rm-noir);
    font-weight: 700;
    font-size: 0.95rem;
}

.rm_stat i { color: var(--rm-accent); font-size: 0.9rem; }

/* séparateur visuel entre stats et boutons */
.rm_actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: 6px;
}

/* ---- Boutons (taille normale, cohérents) ---- */
.rm_btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}

.rm_btn i { font-size: 0.9rem; }

.rm_btn:hover { transform: translateY(-1px); }
.rm_btn:active { transform: translateY(0); }

/* Recalculer — noir, discret */
.rm_btn_refresh {
    background: var(--rm-noir);
    color: #fff;
    box-shadow: 0 3px 10px rgba(13, 13, 15, 0.2);
    /* garde-fous contre le .btn global du CSS principal */
    width: auto !important;
    height: auto !important;
    flex-direction: row !important;
    font-size: 0.85rem !important;
    min-width: 0 !important;
}
.rm_btn_refresh:hover { background: #26263a; }

/* Export — accent indigo, outline */
.rm_btn_ghost {
    background: #fff;
    color: var(--rm-accent-dark);
    border: 1.5px solid var(--rm-accent);
}
.rm_btn_ghost:hover {
    background: var(--rm-accent-soft);
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.15);
}

/* ---- Blocs par famille ---- */
.remise_famille_bloc {
    margin-bottom: 22px;
    border-radius: 18px;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--rm-gris-bord);
    box-shadow: 0 4px 20px rgba(13, 13, 15, 0.05);
    transition: box-shadow 0.2s ease;
}
.remise_famille_bloc:hover {
    box-shadow: 0 8px 30px rgba(13, 13, 15, 0.09);
}

.remise_famille_titre {
    margin: 0;
    padding: 15px 24px;
    background: linear-gradient(90deg, var(--rm-noir) 0%, #1f1f2e 100%);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.remise_famille_titre::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--rm-accent);
    box-shadow: 0 0 8px var(--rm-accent);
}

/* ---- Tableau ---- */
.remises_table {
    width: 100%;
    border-collapse: collapse;
}

.remises_table thead th {
    text-align: left;
    padding: 12px 24px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--rm-texte-doux);
    background: var(--rm-gris-fond);
    border-bottom: 1px solid var(--rm-gris-bord);
    font-weight: 600;
}

.remises_table tbody td {
    padding: 13px 24px;
    border-bottom: 1px solid #f2f2f4;
    font-size: 0.9rem;
    color: #1f2937;
}

.remises_table tbody tr:last-child td { border-bottom: none; }
.remises_table tbody tr { transition: background 0.12s ease; }
.remises_table tbody tr:hover { background: var(--rm-accent-soft); }

.col_remise { text-align: right; width: 120px; }

/* ---- Badge de remise (fin, moderne) ---- */
.badge_remise {
    display: inline-block;
    background: var(--rm-accent-soft);
    color: var(--rm-accent-dark);
    padding: 4px 13px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.82rem;
    border: 1px solid rgba(99, 102, 241, 0.25);
    min-width: 52px;
    text-align: center;
    letter-spacing: -0.2px;
}

/* mise en avant des grosses remises */
.badge_remise.rm_high {
    background: var(--rm-noir);
    color: #fff;
    border-color: var(--rm-noir);
}

/* ---- Barre de recherche ---- */
#searchbar_remise_client {
    min-width: 300px;
    border: 1.5px solid var(--rm-gris-bord);
    border-radius: 12px;
    padding: 11px 16px;
    font-size: 0.95rem;
    transition: border 0.15s ease, box-shadow 0.15s ease;
}
#searchbar_remise_client:focus {
    outline: none;
    border-color: var(--rm-accent);
    box-shadow: 0 0 0 3px var(--rm-accent-soft);
}

/* ---- Autocomplétion ---- */
.remise_search_box {
    position: relative;
    display: inline-block;
}

.ac_results {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 50;
    background: #fff;
    border: 1px solid var(--rm-gris-bord);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(13, 13, 15, 0.15);
    max-height: 340px;
    overflow-y: auto;
    text-align: left;
    padding: 6px;
}

.ac_item {
    display: flex;
    flex-direction: column;
    padding: 10px 14px;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.12s;
}
.ac_item:hover { background: var(--rm-accent-soft); }

.ac_code {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--rm-noir);
}
.ac_nom {
    font-size: 0.78rem;
    color: var(--rm-texte-doux);
    margin-top: 2px;
}

.ac_empty {
    padding: 12px 14px;
    color: #9ca3af;
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
}

/* ---- Message vide / info ---- */
.rm_empty_state {
    max-width: 500px;
    margin: 30px auto;
    text-align: center;
    padding: 30px;
    background: #fff;
    border: 1px dashed var(--rm-gris-bord);
    border-radius: 18px;
    color: var(--rm-texte-doux);
}
.rm_empty_state i { font-size: 2rem; color: var(--rm-accent); margin-bottom: 12px; }

/* ---- Titres de section (Acquises / Quantitatives) ---- */
.rm_section_titre {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 32px 0 16px 4px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--rm-noir);
    letter-spacing: -0.2px;
}

.rm_section_titre i {
    color: var(--rm-vert);
    font-size: 0.95rem;
}

.rm_section_titre small {
    font-weight: 500;
    font-size: 0.78rem;
    color: var(--rm-texte-doux);
    letter-spacing: 0;
}

.rm_section_qty i { color: var(--rm-accent); }

/* bandeau d'avertissement doux sur le bloc quantitatif */
.rm_bloc_qty {
    border-color: rgba(99, 102, 241, 0.35);
}

/* ---- Badge quantité minimum ---- */
.badge_qte {
    display: inline-block;
    background: #fff7ed;
    color: #c2410c;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.8rem;
    border: 1px solid rgba(194, 65, 12, 0.25);
    white-space: nowrap;
}

/* ---- Code article (monospace discret) ---- */
.rm_code_art {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.82rem;
    background: var(--rm-gris-fond);
    border: 1px solid var(--rm-gris-bord);
    padding: 3px 8px;
    border-radius: 6px;
    color: #374151;
}

.rm_vide { color: #d1d5db; }

.col_qte  { text-align: center; width: 130px; }
.col_prix { text-align: right;  width: 120px; font-variant-numeric: tabular-nums; }

/* ---- Pop-up "Fiche tarif" (fiches Sage brutes) ---- */
.rm_modal_fiches.modal_container {
    align-items: center;
}

.rm_modal_fiches_box.modal {
    max-width: 900px;
    width: 92%;
    max-height: 85vh;
    padding: 28px;
    overflow: hidden;
}

/* Un seul conteneur scrollable (titre + tableau) : plus simple et plus fiable
   qu'un enchaînement de flex imbriqués. Seul le bouton fermer reste fixe. */
.rm_fiches_contenu {
    max-height: calc(85vh - 56px); /* 56px = padding haut+bas du .modal */
    overflow-y: auto;
    padding-right: 6px; /* évite que la barre de défilement chevauche le texte */
}

.rm_modal_close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: var(--rm-gris-fond);
    color: var(--rm-noir);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}
.rm_modal_close:hover { background: var(--rm-accent-soft); color: var(--rm-accent-dark); }

.rm_fiches_head h3 {
    margin: 0 0 4px 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--rm-noir);
    padding-right: 40px;
}
.rm_fiches_sous_titre {
    margin: 0 0 18px 0;
    font-size: 0.82rem;
    color: var(--rm-texte-doux);
}

.rm_fiches_scroll {
    border: 1px solid var(--rm-gris-bord);
    border-radius: 14px;
}
.rm_fiches_scroll .remises_table thead th { position: sticky; top: 0; z-index: 1; }

/* petit bouton d'aide "?" (légende des critères numériques type gamme) */
.rm_aide_btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 4px;
    border: 1px solid var(--rm-texte-doux);
    border-radius: 50%;
    background: #fff;
    color: var(--rm-texte-doux);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    cursor: help;
    text-transform: none;
    letter-spacing: 0;
}
.rm_aide_btn:hover { border-color: var(--rm-accent); color: var(--rm-accent-dark); }

/* ---- Vérifier la remise d'un article ---- */
.rm_article_check {
    background: #fff;
    border: 1px solid var(--rm-gris-bord);
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 28px;
}
.rm_article_check h3 {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--rm-noir);
    display: flex;
    align-items: center;
    gap: 8px;
}
.rm_article_check h3 i { color: var(--rm-accent); font-size: 0.85rem; }

.rm_article_check_form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.rm_article_check_form .remise_search_box {
    flex: 1 1 220px;
}
.rm_article_check_form input {
    width: 100%;
    border: 1.5px solid var(--rm-gris-bord);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.9rem;
}
.rm_article_check_form input:focus {
    outline: none;
    border-color: var(--rm-accent);
    box-shadow: 0 0 0 3px var(--rm-accent-soft);
}

.rm_article_resultat_box {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--rm-gris-bord);
}
.rm_article_titre {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--rm-noir);
    margin-bottom: 4px;
}
.rm_article_classement {
    margin: 0 0 14px 0;
    font-size: 0.82rem;
    color: var(--rm-texte-doux);
}
.rm_article_source {
    margin: 0 0 8px 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--rm-texte-doux);
    display: flex;
    align-items: center;
    gap: 6px;
}
.rm_article_source i { color: var(--rm-accent); }
.rm_article_ligne {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.rm_article_prix { font-size: 0.85rem; color: #374151; font-variant-numeric: tabular-nums; }
.rm_article_note {
    margin: 14px 0 0 0;
    font-size: 0.75rem;
    color: #9ca3af;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}
.rm_article_msg { font-size: 0.85rem; color: var(--rm-texte-doux); }
.rm_article_msg_erreur { color: #b91c1c; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .col_remise { width: auto; }
    .remises_meta { flex-direction: column; }
    .rm_actions { margin-left: 0; flex-wrap: wrap; justify-content: center; }
    .remises_head h2 { font-size: 1.1rem; }
    .rm_section_titre { flex-direction: column; gap: 2px; align-items: flex-start; }
    .col_qte, .col_prix { width: auto; }
}

/* ==========================================================================
   IMPRESSION / PDF
   ========================================================================== */
@media print {
    header,
    .menu_mobile,
    .no_print,
    #searchbar_remise_client,
    .rm_actions,
    .flex_center.wrap.mb30 {
        display: none !important;
    }

    body { background: #fff; }

    .remises_head h2 {
        background: #fff !important;
        color: #000 !important;
        border: 2px solid #000;
        box-shadow: none;
    }

    .rm_stat { border: 1px solid #ccc; box-shadow: none; }

    .badge_remise {
        background: #fff !important;
        color: #000 !important;
        border: 1px solid #000;
    }

    .remise_famille_bloc {
        box-shadow: none;
        border: 1px solid #999;
        page-break-inside: avoid;
    }

    .remise_famille_titre {
        background: #eee !important;
        color: #000 !important;
    }
    .remise_famille_titre::before { display: none; }
}
