﻿/* ============================================================
   PricePilot — Feuille de style principale
   ============================================================ */

:root {
    --bleu:        #2563eb;
    --bleu-hover:  #1d4ed8;
    --bleu-clair:  #eff6ff;
    --vert:        #16a34a;
    --vert-clair:  #dcfce7;
    --orange:      #d97706;
    --orange-clair:#fef3c7;
    --rouge:       #dc2626;
    --rouge-clair: #fee2e2;
    --gris-100:    #f8fafc;
    --gris-200:    #e2e8f0;
    --gris-400:    #94a3b8;
    --gris-600:    #475569;
    --gris-800:    #1e293b;
    --ps:          #7c3aed;
    --ps-hover:    #6d28d9;
    --radius:      6px;
    --shadow:      0 1px 3px rgba(0,0,0,.12);
    --shadow-md:   0 4px 12px rgba(0,0,0,.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    background: var(--gris-100);
    color: var(--gris-800);
    min-height: 100vh;
}

/* ---- NAVBAR ---- */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--gris-800);
    color: #fff;
    padding: 0 20px;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}
.nav-brand {
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    text-decoration: none;
    letter-spacing: .5px;
}
.nav-links { display: flex; gap: 4px; }
.nav-links a {
    color: #cbd5e1;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: background .15s;
}
.nav-links a:hover, .nav-links a.actif {
    background: rgba(255,255,255,.12);
    color: #fff;
}

/* ---- LOGIN ---- */
.page-login {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}
.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 380px;
    box-shadow: var(--shadow-md);
}
.login-logo {
    font-size: 28px;
    font-weight: 800;
    color: var(--bleu);
    text-align: center;
    margin-bottom: 4px;
    letter-spacing: 2px;
}
.login-card h1 {
    font-size: 14px;
    text-align: center;
    color: var(--gris-400);
    margin-bottom: 28px;
    font-weight: 400;
}

/* ---- FORMULAIRES ---- */
.champ { margin-bottom: 16px; }
.champ label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--gris-600);
    font-size: 13px;
}
.champ small { display: block; color: var(--gris-400); font-size: 12px; margin-top: 4px; }
.champ input[type=text],
.champ input[type=password],
.champ input[type=number],
.champ input[type=email],
.champ select,
.champ textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--gris-200);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
    background: #fff;
    color: var(--gris-800);
}
.champ input:focus, .champ select:focus, .champ textarea:focus {
    outline: none;
    border-color: var(--bleu);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.champs-ligne { display: flex; gap: 12px; }
.champs-ligne .champ { flex: 1; }
.requis { color: var(--rouge); }

/* ---- BOUTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
    text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primaire  { background: var(--bleu);    color: #fff; }
.btn-primaire:hover:not(:disabled) { background: var(--bleu-hover); }
.btn-secondaire{ background: var(--gris-200); color: var(--gris-800); }
.btn-secondaire:hover:not(:disabled) { background: #cbd5e1; }
.btn-ps        { background: var(--ps);      color: #fff; }
.btn-ps:hover:not(:disabled) { background: var(--ps-hover); }
.btn-danger    { background: var(--rouge-clair); color: var(--rouge); }
.btn-danger:hover:not(:disabled) { background: #fecaca; }
.btn-full { width: 100%; justify-content: center; }
.btn-lg   { padding: 11px 24px; font-size: 15px; }
.btn-sm   { padding: 5px 12px; font-size: 12px; }
.btn-xs   { padding: 3px 8px;  font-size: 11px; }

/* ---- ALERTES ---- */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
}
.alert-ok     { background: var(--vert-clair);   color: var(--vert); }
.alert-erreur { background: var(--rouge-clair);  color: var(--rouge); }
.alert-info   { background: var(--bleu-clair);   color: var(--bleu); }

/* ---- CONTAINER ---- */
.container { max-width: 1400px; margin: 0 auto; padding: 24px 20px; }
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.page-header h1 { font-size: 22px; }

/* ---- CONFIG ---- */
.config-bienvenue { text-align: center; margin-bottom: 32px; }
.config-bienvenue h1 { font-size: 24px; margin-bottom: 8px; }
.config-sections { display: flex; flex-direction: column; gap: 20px; max-width: 720px; margin: 0 auto; }
.config-section {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    box-shadow: var(--shadow);
}
.config-section h2 { font-size: 16px; margin-bottom: 18px; color: var(--gris-800); border-bottom: 1px solid var(--gris-200); padding-bottom: 10px; }
.config-actions { display: flex; gap: 10px; margin-top: 8px; }
.config-footer { display: flex; justify-content: center; margin-top: 8px; }
.resultat-test { margin-top: 10px; font-size: 13px; padding: 8px 12px; border-radius: var(--radius); }
.resultat-test.ok     { background: var(--vert-clair);  color: var(--vert); }
.resultat-test.erreur { background: var(--rouge-clair); color: var(--rouge); }

/* ---- FILTRES ---- */
.filtres-bar {
    background: #fff;
    border-bottom: 1px solid var(--gris-200);
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.filtres-champs { display: flex; gap: 8px; flex-wrap: wrap; }
.filtre-input, .filtre-select {
    padding: 7px 10px;
    border: 1px solid var(--gris-200);
    border-radius: var(--radius);
    font-size: 13px;
    background: #fff;
}
.filtre-input:focus, .filtre-select:focus {
    outline: none;
    border-color: var(--bleu);
}
.filtre-input  { width: 160px; }
.filtre-select { width: 180px; }
.filtre-select-sm { width: 110px; padding: 7px 8px; border: 1px solid var(--gris-200); border-radius: var(--radius); font-size: 13px; }
.filtres-cases { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.filtres-cases label { display: flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; color: var(--gris-600); }
.filtres-actions { display: flex; gap: 8px; align-items: center; }

/* ---- BARRE D'ACTIONS ---- */
.actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--bleu-clair);
    border-bottom: 1px solid #bfdbfe;
}
.actions-selection { display: flex; align-items: center; gap: 10px; }
.actions-csv { display: flex; gap: 8px; }
.checkbox-tout { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; font-size: 13px; }
.compteur-selection { font-size: 12px; color: var(--gris-600); }

/* ---- TABLEAU ---- */
.table-wrapper { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 13px;
}
.table th, .table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--gris-200);
    text-align: left;
    vertical-align: middle;
}
.table thead th {
    background: var(--gris-800);
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 52px;
    z-index: 10;
}
.table thead th.sortable { cursor: pointer; user-select: none; }
.table thead th.sortable:hover { background: var(--gris-600); }
.sort-icon { font-size: 10px; margin-left: 4px; opacity: .6; }
.sort-icon.asc::after  { content: '▲'; }
.sort-icon.desc::after { content: '▼'; }
.table tbody tr:hover { background: var(--gris-100); }
.table tbody tr.selectionne { background: #eff6ff; }
.chargement, .vide { text-align: center; color: var(--gris-400); padding: 40px !important; }

/* Table produits — colonnes */
.col-check  { width: 36px; }
.col-id     { width: 60px; }
.col-ref    { width: 110px; }
.col-nom    { min-width: 180px; max-width: 260px; }
.col-fourn  { width: 110px; }
.col-achat  { width: 90px; }
.col-coeff, .col-fixe, .col-public, .col-bloque, .col-barre { width: 90px; }
.col-tva    { width: 70px; }
.col-arrondi{ width: 80px; }
.col-modele { width: 130px; }
.col-final  { width: 100px; font-weight: 700; }
.col-reduc  { width: 80px; }
.col-statut { width: 90px; }
.col-push   { width: 120px; }
.col-actions{ width: 120px; white-space: nowrap; }

/* Inputs dans le tableau */
.table td input[type=text], .table td input[type=number] {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--gris-200);
    border-radius: 4px;
    font-size: 12px;
    background: #fff;
    color: var(--gris-800);
}
.table td input:focus {
    outline: none;
    border-color: var(--bleu);
    background: var(--bleu-clair);
}
.table td input.modifie { border-color: var(--orange); }
.table td select {
    width: 100%;
    padding: 4px 4px;
    border: 1px solid var(--gris-200);
    border-radius: 4px;
    font-size: 12px;
    background: #fff;
}
.table td input[readonly] {
    background: var(--gris-100);
    color: var(--gris-400);
    cursor: not-allowed;
}

/* Prix final mis en valeur */
.prix-final-val {
    font-weight: 700;
    font-size: 13px;
    color: var(--bleu);
}

/* Réduction en rouge */
.reduction-val { color: var(--rouge); font-size: 12px; }

/* Statut sync */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.badge-local   { background: var(--orange-clair); color: var(--orange); }
.badge-synced  { background: var(--vert-clair);   color: var(--vert); }
.badge-erreur  { background: var(--rouge-clair);  color: var(--rouge); }
.badge-vide    { background: var(--gris-200);     color: var(--gris-400); }

/* Date push */
.date-push { font-size: 11px; color: var(--gris-400); white-space: nowrap; }

/* Boutons d'action ligne */
.actions-ligne { display: flex; gap: 4px; }

/* Déclinaisons indicator */
.btn-decl {
    background: none;
    border: 1px solid var(--gris-200);
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    padding: 2px 6px;
    color: var(--ps);
}
.btn-decl:hover { background: var(--gris-100); }

/* ---- PAGINATION ---- */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px;
    background: #fff;
    border-top: 1px solid var(--gris-200);
}
.page-btn {
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--gris-200);
    border-radius: var(--radius);
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.page-btn:hover { background: var(--gris-100); }
.page-btn.actif { background: var(--bleu); color: #fff; border-color: var(--bleu); font-weight: 700; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-info { font-size: 13px; color: var(--gris-600); margin: 0 8px; }

/* ---- MODALS ---- */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.5);
}
.modal-box {
    position: relative;
    background: #fff;
    border-radius: 12px;
    width: 520px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}
.modal-large { width: 900px; }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--gris-200);
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}
.modal-header h2 { font-size: 18px; }
.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--gris-400);
    padding: 4px 8px;
    border-radius: var(--radius);
}
.modal-close:hover { background: var(--gris-100); }
.modal-box form { padding: 24px; flex: 1; }
.modal-box #modal-decl-content { padding: 20px; }
.modal-box #import-apercu { padding: 20px; overflow-x: auto; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--gris-200);
    position: sticky;
    bottom: 0;
    background: #fff;
}

/* ---- TABLE MODÈLES ---- */
.table-modeles-decl { width: 100%; font-size: 12px; }
.table-modeles-decl th { background: var(--gris-100); font-weight: 600; padding: 6px 8px; }
.table-modeles-decl td { padding: 4px 8px; border-bottom: 1px solid var(--gris-200); }

/* ---- DIVERS ---- */
.nom-produit { font-weight: 600; }
.ref-produit { font-size: 12px; color: var(--gris-400); }
.has-combos  { font-size: 10px; background: var(--ps); color: #fff; border-radius: 3px; padding: 1px 5px; margin-left: 4px; }

/* Progress bar bulk */
.progress-bar-wrap {
    height: 4px;
    background: var(--gris-200);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}
.progress-bar {
    height: 100%;
    background: var(--bleu);
    transition: width .2s;
}

/* ---- STICKY COLONNES ---- */
.table.table-produits th.sticky-col,
.table.table-produits td.sticky-col {
    position: sticky;
    z-index: 5;
    background: #fff;
}
.table.table-produits thead th.sticky-col { z-index: 15; background: var(--gris-800); }
.table.table-produits tbody tr:hover td.sticky-col { background: var(--gris-100); }
.table.table-produits tbody tr.selectionne td.sticky-col { background: #eff6ff; }

/* Positions left des colonnes sticky (checkbox=36, id=60, nom variable) */
.sticky-col-check { left: 0; }
.sticky-col-id    { left: 36px; }
.sticky-col-nom   { left: 96px; box-shadow: 2px 0 4px rgba(0,0,0,.08); }

/* ---- ALERTE PRIX ACHAT ZERO ---- */
.alerte-achat-zero .nom-produit::after {
    content: ' ⚠️';
    font-size: 12px;
    title: 'Prix d\'achat à zéro';
}
.row-alerte-achat td { background: #fffbeb !important; }
.row-alerte-achat td.sticky-col { background: #fffbeb !important; }

/* ---- ÉCART PS ---- */
.ecart-ok      { color: var(--vert);   font-size: 12px; }
.ecart-diff    { color: var(--orange); font-size: 12px; font-weight: 700; }
.ecart-danger  { color: var(--rouge);  font-size: 12px; font-weight: 700; }
.col-ecart     { width: 90px; }

/* ---- DRAWER FICHE PRODUIT ---- */
.drawer {
    position: fixed;
    inset: 0;
    z-index: 900;
    pointer-events: none;
}
.drawer.ouvert { pointer-events: all; }

.drawer-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.4);
    opacity: 0;
    transition: opacity .25s;
}
.drawer.ouvert .drawer-overlay { opacity: 1; }

.drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 460px;
    max-width: 95vw;
    background: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0,0,0,.15);
    transform: translateX(100%);
    transition: transform .25s ease;
}
.drawer.ouvert .drawer-panel { transform: translateX(0); }

.drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--gris-200);
    flex-shrink: 0;
}
.drawer-tabs {
    display: flex;
    border-bottom: 1px solid var(--gris-200);
    flex-shrink: 0;
}
.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--gris-400);
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
}
.tab-btn.actif { color: var(--bleu); border-bottom-color: var(--bleu); }
.tab-btn:hover:not(.actif) { color: var(--gris-800); }

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}
.tab-pane { display: none; }
.tab-pane.actif { display: block; }

.drawer-info-row {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr;
    gap: 6px 12px;
    background: var(--gris-100);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 16px;
    font-size: 13px;
    align-items: center;
}
.drawer-prix-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bleu-clair);
    border-radius: var(--radius);
    padding: 14px;
    margin-top: 16px;
    gap: 4px;
}
.drawer-footer {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--gris-200);
    flex-shrink: 0;
    justify-content: flex-end;
}

/* Mode fiche : lignes cliquables */
.mode-fiche tbody tr { cursor: pointer; }
.mode-fiche tbody tr:hover { background: var(--bleu-clair); }
.mode-fiche tbody tr input,
.mode-fiche tbody tr select { pointer-events: none; }

/* ---- HISTORIQUE DANS DRAWER ---- */
.table-historique { width: 100%; font-size: 12px; }
.table-historique th { background: var(--gris-100); padding: 5px 8px; font-weight: 600; }
.table-historique td { padding: 4px 8px; border-bottom: 1px solid var(--gris-200); }
.badge-push  { background: #ede9fe; color: var(--ps); }
.badge-local-h { background: var(--orange-clair); color: var(--orange); }

/* ---- KBD ---- */
kbd {
    display: inline-block;
    padding: 2px 6px;
    background: var(--gris-100);
    border: 1px solid var(--gris-200);
    border-radius: 4px;
    font-size: 11px;
    font-family: monospace;
}

@media (max-width: 768px) {
    .filtres-bar { flex-direction: column; }
    .filtre-input, .filtre-select { width: 100%; }
    .table-wrapper { font-size: 12px; }
    .modal-large { width: 98vw; }
    .drawer-panel { width: 100vw; }
}
