/* ==========================================================================
   SISPE - Finitions professionnelles (Bootstrap 5)
   Couche additive : ne remplace aucune règle existante, uniquement harmonise.
   ========================================================================== */
:root {
    --sp-radius: 12px;
    --sp-shadow: 0 2px 10px rgba(107, 85, 56, 0.08);
    --sp-shadow-hover: 0 8px 22px rgba(107, 85, 56, 0.14);
    --sp-focus: 0 0 0 0.22rem rgba(139, 111, 71, 0.28);
    --bs-link-color: #8B6F47;
    --bs-link-hover-color: #6B5538;
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: hidden; }
img, svg, canvas, video { max-width: 100%; }

/* Accessibilité : focus visible cohérent */
:focus-visible { outline: 2px solid #8B6F47; outline-offset: 2px; border-radius: 4px; }
.form-control:focus, .form-select:focus, .form-check-input:focus, .btn:focus-visible {
    border-color: #A0826D; box-shadow: var(--sp-focus); outline: 0;
}
.form-check-input:checked { background-color: #8B6F47; border-color: #8B6F47; }

/* Cartes */
.card { border-radius: var(--sp-radius); border: 1px solid #F0E6D2; box-shadow: var(--sp-shadow); overflow: hidden; }
.card-header { font-weight: 600; }
.card-header.bg-dark, .card-header.bg-primary { border-bottom: 0; }
.card .card-header + .card-body > .table-responsive:only-child { margin: -1px; }

/* Boutons */
.btn { border-radius: 9px; font-weight: 600; transition: transform .12s ease, box-shadow .15s ease, background-color .15s ease; }
.btn:not(:disabled):not(.disabled):hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12); }
.btn:not(:disabled):not(.disabled):active { transform: translateY(0); }
.btn-sm { border-radius: 8px; }
.btn i.fas:only-child, .btn i.far:only-child { margin: 0; }

/* Formulaires */
.form-label { font-weight: 600; color: #5a4a35; font-size: .875rem; }
.form-control, .form-select { border-radius: 9px; border-color: #E4D8C4; min-height: 40px; }
.form-control::placeholder { color: #a99f90; }
.invalid-feedback { font-size: .8rem; }

/* Tableaux */
.table { --bs-table-hover-bg: #FFF9F5; }
.table > thead > tr > th { font-size: .74rem; letter-spacing: .05em; text-transform: uppercase; color: #6B5538; white-space: nowrap; }
.table > :not(caption) > * > * { vertical-align: middle; }
.table-responsive { border-radius: var(--sp-radius); -webkit-overflow-scrolling: touch; }

/* Badges et alertes */
.badge { font-weight: 600; letter-spacing: .02em; border-radius: 999px; padding: .4em .7em; }
.alert { border-radius: var(--sp-radius); border-width: 0 0 0 4px; box-shadow: var(--sp-shadow); }
.alert-success { border-left-color: #2E7D32; } .alert-danger { border-left-color: #C62828; }
.alert-warning { border-left-color: #EF6C00; } .alert-info { border-left-color: #1565C0; }

/* Menus déroulants et pagination */
.dropdown-menu { border-radius: 12px; border: 1px solid #F0E6D2; box-shadow: var(--sp-shadow-hover); padding: .4rem; }
.dropdown-item { border-radius: 8px; }
.pagination { flex-wrap: wrap; gap: .25rem; }
.page-link { border-radius: 8px !important; color: #6B5538; }
.page-item.active .page-link { background: #8B6F47; border-color: #8B6F47; color: #fff; }

/* Titres de page */
.content-section > .container h1:first-child,
.content-section > .container-fluid h1:first-child { letter-spacing: -.01em; }

/* Barre de défilement discrète */
* { scrollbar-width: thin; scrollbar-color: #D4A574 transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #D4A574; border-radius: 8px; }

/* Grands écrans : contenu plus large, barre latérale confortable */
@media (min-width: 1600px) {
    .container-fluid, .container, .container-lg { max-width: 1560px; }
}

/* Tablettes : évite les débordements horizontaux */
@media (max-width: 991.98px) {
    .btn-group { flex-wrap: wrap; }
    .modal-dialog { max-width: calc(100vw - 1rem); }
    pre, code { white-space: pre-wrap; word-break: break-word; }
}

/* Mobile : cibles tactiles, graphiques et formulaires lisibles */
@media (max-width: 575.98px) {
    .btn { min-height: 42px; }
    .btn-sm { min-height: 34px; }
    .form-control, .form-select { font-size: 16px; } /* évite le zoom automatique sur iOS */
    .form-control, .form-select { min-height: 44px; }
    .card { border-radius: 10px; }
    .table > thead > tr > th { font-size: .7rem; }
    .dropdown-menu { max-width: calc(100vw - 1.5rem); }
    canvas { max-height: 300px; }
    .alert { font-size: .92rem; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .btn, .card { transition: none !important; }
    .btn:hover { transform: none !important; }
}

@media print {
    .sp-sidebar, .sp-side-backdrop, .sp-side-toggle-btn, .sp-filter-btn, #backToTop { display: none !important; }
    .card { box-shadow: none; }
}
