/* --------------------------------------------------------------------------
   Thème FT — palette conservée : rouge brique #c0392b, fond rosé #fff6f8
   -------------------------------------------------------------------------- */
:root {
    --ft-brand: #c0392b;
    --ft-brand-hover: #a93226;
    --ft-brand-soft: rgba(192, 57, 43, 0.09);
    --ft-brand-border: rgba(192, 57, 43, 0.18);
    --ft-bg-page: #fff6f8;
    --ft-bg-header: #ffffff;
    --ft-text: #2a2a2a;
    --ft-text-muted: #5c5c5c;
    --ft-radius: 0.75rem;
    --ft-radius-sm: 0.5rem;
    --ft-shadow: 0 1px 3px rgba(42, 42, 42, 0.06);
    --ft-shadow-md: 0 4px 20px rgba(42, 42, 42, 0.07);
}

/* Boutons danger alignés sur la marque (au lieu du rouge Bootstrap par défaut) */
.btn-danger {
    --bs-btn-bg: var(--ft-brand);
    --bs-btn-border-color: var(--ft-brand);
    --bs-btn-hover-bg: var(--ft-brand-hover);
    --bs-btn-hover-border-color: var(--ft-brand-hover);
    --bs-btn-active-bg: var(--ft-brand-hover);
    --bs-btn-active-border-color: var(--ft-brand-hover);
    --bs-btn-focus-shadow-rgb: 192, 57, 43;
}

.btn-outline-danger {
    --bs-btn-color: var(--ft-brand);
    --bs-btn-border-color: var(--ft-brand-border);
    --bs-btn-hover-bg: var(--ft-brand-soft);
    --bs-btn-hover-border-color: var(--ft-brand);
    --bs-btn-hover-color: var(--ft-brand-hover);
    --bs-btn-active-bg: var(--ft-brand);
    --bs-btn-active-border-color: var(--ft-brand);
}

body.app-body {
    font-family:
        system-ui,
        -apple-system,
        "Segoe UI",
        Roboto,
        "Helvetica Neue",
        Arial,
        sans-serif;
    color: var(--ft-text);
    background: linear-gradient(180deg, #fffdfb 0%, var(--ft-bg-page) 35%, var(--ft-bg-page) 100%);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-header {
    background: var(--ft-bg-header);
    box-shadow: var(--ft-shadow);
}

.app-header .btn-link-ft {
    color: var(--ft-brand);
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
    transition:
        color 0.2s ease,
        opacity 0.2s ease;
}

.app-header .btn-link-ft:hover {
    color: var(--ft-brand-hover);
    opacity: 0.95;
}

.app-page-title {
    font-weight: 700;
    font-size: clamp(1.25rem, 2.5vw, 1.5rem);
    letter-spacing: -0.02em;
    color: var(--ft-brand);
}

/* Miniature logo barre d’en-tête + page de connexion (ratio préservé, aligné au titre) */
.app-header-logo {
    height: clamp(2rem, 4.2vw, 2.625rem);
    width: auto;
    max-height: 2.75rem;
    object-fit: contain;
    object-position: left center;
    flex-shrink: 0;
}

.app-login-logo {
    max-height: 100px;
    width: auto;
    object-fit: contain;
}

.app-main {
    background: transparent;
    min-height: calc(100vh - 8rem);
}

/* Champs — focus cohérent avec la marque */
.form-control:focus,
.form-select:focus {
    border-color: var(--ft-brand);
    box-shadow: 0 0 0 0.2rem rgba(192, 57, 43, 0.18);
}

/* Déclaration mise à jour annuelle — sans .btn Bootstrap (évite double bordure / cadre noir) */
.btn-ft-maj-toggle {
    display: inline-block;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
    line-height: inherit;
}

.btn-ft-maj-toggle:focus-visible {
    outline: 2px solid var(--ft-brand);
    outline-offset: 3px;
    border-radius: var(--ft-radius-sm);
}

.btn-ft-maj-toggle:disabled,
.btn-ft-maj-toggle[disabled] {
    cursor: default;
    opacity: 1;
}

.btn-ft-maj-toggle__label {
    display: inline-block;
    padding: 0.55rem 1.35rem;
    background-color: #fff;
    color: var(--ft-brand);
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: 999px;
    border: 1px solid var(--ft-brand-border);
    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.15s ease;
    user-select: none;
}

.btn-ft-maj-toggle:hover:not(:disabled) .btn-ft-maj-toggle__label {
    background: var(--ft-brand-soft);
    border-color: var(--ft-brand);
}

.btn-ft-maj-toggle:active:not(:disabled) .btn-ft-maj-toggle__label {
    transform: scale(0.99);
}

.btn-ft-maj-toggle--done:disabled .btn-ft-maj-toggle__label,
.btn-ft-maj-toggle:disabled.btn-ft-maj-toggle--done .btn-ft-maj-toggle__label {
    background: rgba(25, 135, 84, 0.1);
    color: #0f5132;
    border: 1px solid rgba(25, 135, 84, 0.35);
    box-shadow: none;
    font-weight: 600;
}

/* Barre d’actions sur la sélection (fournisseur) */
.ft-selection-toolbar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--ft-radius);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, var(--ft-brand-soft) 100%);
    border: 1px solid rgba(192, 57, 43, 0.12);
    box-shadow: var(--ft-shadow);
}

@media (min-width: 992px) {
    .ft-selection-toolbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 1.5rem;
    }
}

.ft-selection-toolbar__head {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ft-text-muted);
    flex-shrink: 0;
}

.ft-selection-toolbar__head i {
    font-size: 1.1rem;
    color: var(--ft-brand);
    opacity: 0.85;
}

.ft-selection-toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.ft-selection-toolbar__select {
    flex: 1 1 12rem;
    min-width: 10rem;
    max-width: 22rem;
    border-radius: var(--ft-radius-sm);
    border-color: rgba(0, 0, 0, 0.1);
    background-color: #fff;
}

.ft-selection-toolbar__submit {
    flex-shrink: 0;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.875rem;
    min-height: 2.375rem;
    padding: 0.45rem 1.15rem;
    border: none;
    background: var(--ft-brand);
    color: #fff;
    box-shadow: 0 2px 10px rgba(192, 57, 43, 0.25);
    transition:
        background 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.15s ease;
}

.ft-selection-toolbar__submit:hover:not(:disabled) {
    background: var(--ft-brand-hover);
    box-shadow: 0 4px 14px rgba(192, 57, 43, 0.3);
    color: #fff;
}

.ft-selection-toolbar__submit:active:not(:disabled) {
    transform: translateY(1px);
}

.ft-selection-toolbar__submit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
    background: #adb5bd;
}

/* Table fiches fournisseur */
.table-ft {
    --bs-table-hover-bg: rgba(192, 57, 43, 0.04);
}

.table-ft thead th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    color: var(--ft-text-muted);
    border-bottom-width: 1px;
    background: var(--ft-brand-soft) !important;
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

.table-ft tbody td {
    vertical-align: middle;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.table-ft .badge {
    font-weight: 600;
    padding: 0.4em 0.65em;
    border-radius: var(--ft-radius-sm);
}

/* Pagination */
.pagination-ft .btn-pagination-ft {
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--ft-radius-sm);
    border: 1px solid var(--ft-brand-border);
    background: #fff;
    color: var(--ft-text);
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease;
}

.pagination-ft .btn-pagination-ft:hover:not(:disabled) {
    border-color: var(--ft-brand);
    color: var(--ft-brand);
    background: var(--ft-brand-soft);
}

.pagination-ft .btn-pagination-ft:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pagination-ft .pagination-ft-current {
    font-weight: 700;
    border-radius: var(--ft-radius-sm);
    background: var(--ft-brand) !important;
    color: #fff !important;
    border: 1px solid var(--ft-brand) !important;
    box-shadow: 0 2px 8px rgba(192, 57, 43, 0.25);
}

/* Modales */
.modal-content {
    border: none;
    border-radius: var(--ft-radius);
    box-shadow: var(--ft-shadow-md);
}

.modal-header .modal-title.text-danger {
    color: var(--ft-brand) !important;
    font-weight: 700;
}

/* Cartes grille fiches (vue interne) */
.fiche-card {
    min-width: 0;
    border-radius: var(--ft-radius) !important;
    transition:
        box-shadow 0.25s ease,
        transform 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.04) !important;
}

.fiche-card:hover {
    box-shadow: var(--ft-shadow-md) !important;
    transform: translateY(-2px);
}

.fiche-card.is-selected {
    outline: 2px solid var(--ft-brand);
    outline-offset: 2px;
    box-shadow: 0 4px 20px rgba(192, 57, 43, 0.15) !important;
}

.fiche-card .card-title.text-danger {
    color: var(--ft-brand) !important;
}

/* Filtres statut fournisseur (checkbox + label) */
.fiche-filtres-statut input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.fiche-filtres-statut label {
    cursor: pointer;
    margin-bottom: 0;
}

.fiche-filtres-statut label span {
    display: inline-block;
    padding: 0.45rem 1rem;
    background-color: #fff;
    color: var(--ft-brand);
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 999px;
    border: 1px solid var(--ft-brand-border);
    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease;
    user-select: none;
}

/* input et label sont frères : input:checked + label span */
.fiche-filtres-statut input:checked + label span {
    background-color: var(--ft-brand);
    color: #fff;
    border-color: var(--ft-brand);
    box-shadow: 0 2px 8px rgba(192, 57, 43, 0.25);
}

.btn-toggle-filter input[type="checkbox"] {
    display: none;
}

/* Non coché : texte rouge sur fond blanc */
.btn-toggle-filter span {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    background-color: white;
    color: var(--ft-brand);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: var(--ft-radius-sm);
    border: 1px solid var(--ft-brand-border);
    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease;
    user-select: none;
}

/* Coché : fond rouge, texte blanc */
.btn-toggle-filter input:checked + span {
    background-color: var(--ft-brand);
    color: white;
    border-color: var(--ft-brand);
    box-shadow: 0 2px 8px rgba(192, 57, 43, 0.2);
}

/*
 * Fiches techniques — image contenue dans la card.
 * Sans min-width:0 sur colonne / card-body (flex), Bootstrap laisse min-width:auto
 * et la largeur intrinsèque de l’image impose le débordement de la grille.
 */
.fiche-card-col {
    min-width: 0;
}

.fiche-card .card-body {
    min-width: 0;
}

.fiche-card .fiche-card-media {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: 280px;
    overflow: hidden;
    flex-shrink: 1;
    border-radius: var(--ft-radius-sm);
}

/* Spécificité img + contrainte explicite largeur du bloc image */
.fiche-card img.fiche-card-image {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 280px;
    margin-left: auto;
    margin-right: auto;
    object-fit: contain;
    object-position: center;
    box-sizing: border-box;
}

.fiche-card .fiche-card-pdf-frame {
    max-height: 280px;
    width: 100%;
}

.fiche-card .fiche-card-pdf-frame .fiche-card-pdf-preview {
    display: block;
    width: 100%;
    height: 260px;
    max-height: 280px;
    /* Les clics traversent vers .fiche-card-media (ouverture modale), comme pour les images */
    pointer-events: none;
}

/* Slot image : fond neutre si pas de visuel (évite le « carré » sur fond rosé) */
.fiche-card-image-slot {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.fiche-card-no-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    min-height: 140px;
    max-height: 280px;
    padding: 1rem;
    box-sizing: border-box;
    background: #e8e8ea;
    color: var(--ft-text-muted);
    border-radius: var(--ft-radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
}

.fiche-card-no-image .bi {
    font-size: 2rem;
    line-height: 1;
    opacity: 0.45;
}

.fiche-modal-thumb-wrap {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}

.fiche-modal-thumb-wrap img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fiche-modal-no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #e8e8ea;
    color: var(--ft-text-muted);
}

.fiche-modal-no-image .bi {
    font-size: 1.35rem;
    opacity: 0.5;
}

/* Certifications : petits pictos directement sous la photo */
.fiche-card .fiche-card-certifs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-top: -0.25rem;
    margin-bottom: 0.25rem;
}

.fiche-card img.fiche-certif {
    display: block;
    max-height: 36px;
    max-width: 64px;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    flex: 0 0 auto;
}

/* Viewer PDF dans modale */
.fiche-technique-viewer .border.rounded.overflow-hidden.bg-light {
    border-radius: var(--ft-radius-sm) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

/* Bouton flottant export (grille fiches) */
.ft-fab-export {
    border-radius: 999px;
    padding: 0.65rem 1.15rem;
    background: #fff;
    border: 1px solid var(--ft-brand-border);
    box-shadow: var(--ft-shadow-md);
    transition:
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

.ft-fab-export:hover:not(:disabled) {
    box-shadow: 0 6px 24px rgba(42, 42, 42, 0.12);
    transform: translateY(-1px);
}

.ft-fab-export:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Titres et liens accent marque */
.text-danger {
    color: var(--ft-brand) !important;
}

/* Page de connexion */
.ft-login-card {
    border-radius: var(--ft-radius);
    box-shadow: var(--ft-shadow-md);
    transition: box-shadow 0.25s ease;
}

.ft-login-card:focus-within {
    box-shadow: 0 8px 32px rgba(42, 42, 42, 0.12);
}
