/* ================================================================
   STYLE.CSS — Optimisé tablette Lenovo 10" + scannette Bluetooth
   ================================================================ */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --blue:       #0056b3;
    --blue-dark:  #004085;
    --blue-nav:   #003366;
    --red:        #dc3545;
    --orange:     #e67e00;
    --green:      #28a745;
    --grey-dark:  #343a40;
    --grey-light: #f4f6f9;
    --white:      #ffffff;
    --radius:     10px;
    --shadow:     0 2px 8px rgba(0,0,0,0.10);
    --font-base:  17px;   /* Plus grand pour tablette */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: var(--font-base);
    background-color: var(--grey-light);
    color: #333;
    line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
header {
    background-color: var(--blue-nav);
    color: #fff;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.header-top {
    padding: 10px 16px 6px;
}

.header-top h1 {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
}

/* ── Navigation ── */
nav {
    display: flex;
    gap: 4px;
    padding: 6px 10px;
    background-color: var(--blue-dark);
    flex-wrap: wrap;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    color: rgba(255,255,255,0.85);
    padding: 10px 18px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.95rem;
    min-height: 48px;       /* Touch target tablette */
    white-space: nowrap;
    transition: background 0.15s;
}

.nav-btn:hover,
.nav-btn.active {
    background-color: rgba(255,255,255,0.2);
    color: #fff;
    text-decoration: none;
}

/* ── Container ── */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 14px 12px 40px;
}

/* ── Alertes ── */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 14px;
    font-size: 1rem;
    font-weight: 500;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ── Barre de scan ── */
.scan-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border-radius: var(--radius);
    padding: 10px 14px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.scan-icon { font-size: 1.4rem; }

.scan-bar input {
    flex: 1;
    font-size: 1.1rem;
    padding: 10px 12px;
    border: 2px solid #cce0ff;
    border-radius: 8px;
    outline: none;
    min-height: 48px;
}

.scan-bar input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0,86,179,0.15);
}

.scan-bar button {
    min-height: 48px;
    padding: 0 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    background-color: var(--blue);
    color: #fff;
    transition: background 0.15s;
}

.scan-bar button:hover { background-color: var(--blue-dark); }

.btn-secondary {
    background-color: #6c757d !important;
    min-width: 48px;
    font-size: 1.1rem !important;
}

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    border: 3px solid transparent;
    transition: transform 0.1s, border-color 0.15s;
    cursor: pointer;
    min-height: 80px;
}

.stat-card:hover { transform: translateY(-2px); text-decoration: none; }
.stat-card.active { border-color: currentColor; transform: translateY(-2px); }

.stat-nb {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.stat-label {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #555;
}

.stat-total  { color: var(--blue); }
.stat-perime { color: var(--red); }
.stat-retrait{ color: var(--orange); }
.stat-rupture{ color: var(--grey-dark); }
.stat-ok {
    color: #1b5e20;
    border: 2px solid #66bb6a;
}
.stat-ok.active {
    background: #e8f5e9;
    border-color: #2e7d32;
}
.stat-retire {
    color: #e65100;
    border: 2px solid #ff9800;
    position: relative;
}
.btn-reset-retraits {
    display: block;
    font-size: 0.72rem;
    color: #e65100;
    text-decoration: none;
    margin-top: 4px;
    opacity: 0.7;
}
.btn-reset-retraits:hover { opacity: 1; }
.alert-retrait {
    background: #fff8e1;
    border-left: 4px solid #ff9800;
    color: #6d4c00;
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 0.95rem;
}

/* ── Filtres Rayons ── */
.rayon-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.rayon-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 50px;
    background: #fff;
    border: 2px solid #cce0ff;
    color: var(--blue);
    font-weight: 600;
    font-size: 0.95rem;
    min-height: 46px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    box-shadow: var(--shadow);
}

.rayon-btn:hover { background: #e8f0ff; text-decoration: none; }

.rayon-btn.active {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}

.rayon-btn.rayon-ok {
    opacity: 0.55;
    border-style: dashed;
}

.rayon-badge {
    background: var(--red);
    color: #fff;
    border-radius: 50px;
    padding: 2px 8px;
    font-size: 0.78rem;
    font-weight: 800;
    min-width: 22px;
    text-align: center;
}

.rayon-btn.active .rayon-badge {
    background: rgba(255,255,255,0.3);
}

/* ── Résumé filtre ── */
.filtre-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #e8f0ff;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.btn-reset {
    background: var(--blue);
    color: #fff;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
}

.btn-reset:hover { background: var(--blue-dark); text-decoration: none; }

/* ── Tableau ── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th, td {
    padding: 12px 10px;
    border-bottom: 1px solid #e9ecef;
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f0f4ff;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #555;
    font-weight: 700;
    position: sticky;
    top: 0;
}

tr:last-child td { border-bottom: none; }

/* Couleurs de lignes selon statut */
.row-perime  { background-color: #fff5f5; }
.row-retrait { background-color: #fffbf0; }
.row-rupture { background-color: #f8f9fa; }

tr.highlight { background-color: #fff3cd !important; transition: background 0.5s; }

/* Colonnes */
.td-gencode { font-size: 0.82rem; color: #777; font-family: monospace; white-space: nowrap; width: 90px; }

/* Colonne Produit : largeur fixe, lien tronqué */
.td-nom          { width: 160px; max-width: 160px; }
.td-nom a        { font-weight: 600; color: #333; display: block;
                   font-size: 0.82rem; white-space: normal; word-break: break-word; line-height: 1.3; }

/* Colonne Fournisseur : tronquée avec … et tooltip au survol */
.td-fournisseur  { width: 100px; max-width: 100px;
                   overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
                   font-size: 0.85rem; color: #555; cursor: help; }

.td-dlc          { white-space: nowrap; font-weight: 600; width: 88px; }
.td-jours        { text-align: center; width: 46px; }
.td-stock        { text-align: center; font-size: 1.1rem; width: 46px; }
.td-statut       { white-space: nowrap; width: 80px; }
.td-update       { width: 1px; white-space: nowrap; padding-right: 6px !important; }
.td-action       { width: 1px; white-space: nowrap; padding-left: 0 !important; }

/* Badges jours */
.badge-jours  { background: #e8f5e9; color: #2e7d32; padding: 3px 8px; border-radius: 6px; font-weight: 700; font-size: 0.85rem; }
.badge-perime { background: #ffebee; color: #c62828; padding: 3px 8px; border-radius: 6px; font-weight: 700; font-size: 0.85rem; }

/* Statut badges */
.statut {
    padding: 5px 12px;
    border-radius: 50px;
    font-size: 0.82rem;
    font-weight: 700;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.statut-perime  { background: #dc3545; color: #fff; }
.statut-retrait { background: #ffc107; color: #333; }
.statut-rupture { background: #343a40; color: #fff; }
.statut-ok      { background: #28a745; color: #fff; }

/* ── Formulaire MAJ rapide ── */
.form-update-rapide {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    padding: 0;
    box-shadow: none;
    margin: 0;
    flex-wrap: nowrap;
}

.input-dlc {
    width: 118px !important;
    min-width: 100px !important;
    padding: 6px 4px !important;
    font-size: 0.85rem !important;
    border: 1px solid #ccc !important;
    border-radius: 6px !important;
    margin: 0 !important;
    min-height: 42px;
}

/* Boutons présent / rupture */
.btn-present,
.btn-rupture {
    min-width: 42px;
    min-height: 42px;
    padding: 0 !important;
    font-size: 1.1rem !important;
    border-radius: 8px !important;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.btn-present { background: #e8f5e9; }
.btn-present:hover { background: #c8e6c9; }
.btn-rupture { background: #f5f5f5; }
.btn-rupture:hover { background: #e0e0e0; }

/* ── Compteur d'UVC retirées ── */
.retrait-counter {
    display: flex;
    align-items: center;
    gap: 2px;
    background: #fff8f0;
    border: 1.5px solid #ffcc80;
    border-radius: 8px;
    padding: 2px 5px;
    flex-shrink: 0;
}

.retrait-icon {
    font-size: 0.9rem;
    line-height: 1;
    user-select: none;
}

.input-retrait {
    width: 42px !important;
    min-width: 42px !important;
    min-height: 38px !important;
    padding: 4px 2px !important;
    font-size: 1rem !important;
    font-weight: 700;
    text-align: center !important;
    border: none !important;
    background: transparent !important;
    color: #e65100;
    border-radius: 6px !important;
    margin: 0 !important;
    box-shadow: none !important;
    -moz-appearance: textfield;
}
.input-retrait::-webkit-inner-spin-button,
.input-retrait::-webkit-outer-spin-button { opacity: 1; }
.input-retrait:focus { outline: none; background: #ffe0b2 !important; }

/* ── Bouton supprimer ── */
.btn-delete {
    min-width: 44px;
    min-height: 44px;
    background: #fff0f0;
    border: 1px solid #ffcdd2;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.btn-delete:hover { background: #ffcdd2; }

.form-delete {
    background: transparent;
    padding: 0;
    box-shadow: none;
    margin: 0;
}

/* ── Message tableau vide ── */
.empty-msg {
    text-align: center;
    padding: 40px !important;
    font-size: 1.2rem;
    color: #555;
}

/* ── Formulaires généraux ── */
form {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-top: 18px;
}

form h3 {
    margin-bottom: 14px;
    color: var(--blue-dark);
    border-bottom: 2px solid #e8f0ff;
    padding-bottom: 8px;
}

form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.95rem;
}

form input[type="text"],
form input[type="number"],
form input[type="date"],
form input[type="file"],
form select {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 1px solid #ccd;
    border-radius: 8px;
    margin-bottom: 14px;
    min-height: 48px;
}

form input:focus, form select:focus {
    border-color: var(--blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,86,179,0.12);
}

form button[type="submit"],
form button.btn-primary {
    background: var(--blue);
    color: #fff;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    min-height: 48px;
    transition: background 0.15s;
}
form button[type="submit"]:hover { background: var(--blue-dark); }

/* ── Fiche produit ── */
.fiche-produit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.fiche-card {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.fiche-card h3 {
    margin-bottom: 12px;
    border-bottom: 2px solid #eee;
    padding-bottom: 8px;
    color: var(--blue-dark);
}

.fiche-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.button-link {
    display: inline-flex;
    align-items: center;
    background: var(--green);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 700;
    min-height: 48px;
    text-decoration: none;
}
.button-link:hover { background: #218838; text-decoration: none; }

/* ── Footer ── */
footer {
    text-align: center;
    padding: 20px;
    background: #e9ecef;
    color: #6c757d;
    font-size: 0.88rem;
    margin-top: 30px;
}

/* ── Responsive tablette 10" (environ 1280px) ── */
@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .td-gencode { display: none; }
    th:first-child { display: none; }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .header-top h1 { font-size: 1rem; }
    .input-dlc { width: 110px !important; }
}

/* ── Tri cliquable ── */
.th-tri a {
    color: #555;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.th-tri a:hover { color: var(--blue); }
.th-tri.tri-actif { background: #e0ecff; }
.th-tri.tri-actif a { color: var(--blue); font-weight: 800; }

/* ── Statistiques / Graphiques ── */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 0;
}

.chart-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.chart-card h3 {
    margin-bottom: 16px;
    color: var(--blue-dark);
    font-size: 1rem;
    border-bottom: 2px solid #e8f0ff;
    padding-bottom: 8px;
}

.chart-card-wide {
    grid-column: 1 / -1;
}

.chart-container {
    position: relative;
    height: 220px;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 12px;
    font-size: 0.85rem;
    color: #555;
    align-items: center;
}

.legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    vertical-align: middle;
}

@media (max-width: 700px) {
    .charts-grid { grid-template-columns: 1fr; }
    .chart-card-wide { grid-column: auto; }
}

/* ══════════════════════════════════════════
   STATS — Onglets
══════════════════════════════════════════ */
.stats-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.stats-tab {
    padding: 10px 22px;
    min-height: 44px;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    background: #fff;
    font-size: 1rem;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
}

.stats-tab:hover {
    border-color: #4a90d9;
    color: #4a90d9;
    background: #f0f7ff;
}

.stats-tab.active {
    background: #4a90d9;
    border-color: #4a90d9;
    color: #fff;
}

.stats-tab:nth-child(2).active {
    background: #ff9800;
    border-color: #ff9800;
}

/* ══════════════════════════════════════════
   STATS — Filtres période
══════════════════════════════════════════ */
.periode-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.periode-btn {
    padding: 8px 16px;
    min-height: 40px;
    border: 2px solid #dee2e6;
    border-radius: 20px;
    background: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: all 0.2s;
}

.periode-btn:hover {
    border-color: #ff9800;
    color: #e65100;
}

.periode-btn.active {
    background: #ff9800;
    border-color: #ff9800;
    color: #fff;
}

@media (max-width: 600px) {
    .stats-tabs { flex-direction: column; }
    .periode-filters { gap: 6px; }
    .periode-btn { font-size: 0.82rem; padding: 7px 12px; }
}

/* ══════════════════════════════════════════
   STATS — Bouton "Tous les articles" + RAZ
══════════════════════════════════════════ */
.btn-toggle-produits {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    min-height: 44px;
    background: #fff;
    border: 2px solid #4a90d9;
    border-radius: 10px;
    color: #4a90d9;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-toggle-produits:hover,
.btn-toggle-produits.active {
    background: #4a90d9;
    color: #fff;
}

/* Badge UVC dans le tableau produits */
.uvc-badge {
    display: inline-block;
    background: #fff3e0;
    color: #e65100;
    border: 1.5px solid #ffcc80;
    border-radius: 20px;
    padding: 3px 12px;
    font-weight: 800;
    font-size: 0.95rem;
    min-width: 36px;
    text-align: center;
}

/* Bouton RAZ par article */
.btn-raz {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    min-height: 36px;
    background: #fff8f0;
    border: 1.5px solid #ffab40;
    border-radius: 8px;
    color: #e65100;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.btn-raz:hover {
    background: #ffe0b2;
    border-color: #e65100;
}
