/* ==========================================================================
   Grille de documents (devis, factures, documents) et tutoriels
   ========================================================================== */

.card-box {
    padding: 20px;
    border-radius: var(--radius, 16px);
    margin-bottom: 30px;
    background-color: #fff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.card-box>.row {
    --bs-gutter-x: 16px;
    --bs-gutter-y: 16px;
}

.file-man-box {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
}

.file-man-box:hover {
    transform: translateY(-2px);
    border-color: var(--brand-100);
    box-shadow: var(--shadow-md);
    cursor: pointer;
}

.file-man-box .file-img-box {
    display: grid;
    place-items: center;
    height: 96px;
    margin-bottom: 12px;
    border-radius: 10px;
    background: var(--surface-2);
}

.file-man-box .file-img-box img {
    height: 52px;
}

.file-man-title {
    min-width: 0;
}

.file-man-box h5 {
    font-size: 13.5px !important;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 4px;
}

.file-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 8px;
    font-size: 12px;
    color: var(--muted);
}

.file-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
    min-height: 40px;
}

.file-man-box .file-download {
    width: 32px;
    height: 32px;
    margin-left: auto;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--muted);
    background: var(--brown-10);
    font-size: 13px;
    text-decoration: none;
    transition: background 150ms ease, color 150ms ease;
}

.file-man-box .file-download:hover {
    background: var(--brand);
    color: #fff;
}

.file-man-box .file-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #fff;
    color: var(--danger);
    font-size: 16px;
    box-shadow: var(--shadow-sm);
    opacity: 0;
    transition: opacity 150ms ease;
}

.file-man-box:hover .file-close,
.file-man-box .file-close:focus {
    opacity: 1;
}

@media (hover: none) {
    .file-man-box .file-close {
        opacity: 1;
    }
}

.file-admin {
    margin-top: 8px;
    padding: 0 4px;
    font-size: 12px;
    color: var(--muted);
}

.file-admin .form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 0;
    margin: 0 0 4px;
}

.file-admin .form-check-input {
    position: static;
    margin: 0;
    float: none;
    cursor: pointer;
}

.file-admin .form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}

.file-admin .form-check-label {
    font-size: 12px !important;
}

/* Carte "ajouter une pièce" (admin) */
.file-man-box.addFile {
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 196px;
    border: 2px dashed var(--brand-50p);
    background: var(--brand-50);
    color: var(--brand-700);
    text-align: center;
}

.file-man-box.addFile:hover {
    border-color: var(--brand);
    background: var(--brand-100);
}

.addFile-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: #fff;
    font-size: 20px;
}

.addFile-label {
    font-size: 13.5px;
    font-weight: 600;
}

.empty-state {
    padding: 48px 16px;
    text-align: center;
    color: var(--muted);
}

.empty-state i {
    display: block;
    margin-bottom: 12px;
    font-size: 36px;
    color: var(--brown-25);
}

.text-overflow {
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    width: 100%;
    overflow: hidden;
}

/* Visionneuse PDF */
#modalVisionneuse .modal-dialog {
    max-width: 92vw !important;
}

#modalVisionneuse .close {
    position: absolute;
    right: 0 !important;
    z-index: 5;
    color: white !important;
    text-shadow: none !important;
    opacity: 1 !important;
    font-size: 64px !important;
    background: transparent;
    border: 0;
}

#modalVisionneuse .modal-dialog .modal-content {
    border: 0 !important;
    box-shadow: none;
    background-color: transparent !important;
}

#modalVisionneuse .modal-dialog .modal-body {
    height: 90vh !important;
    padding: 0 !important;
    background-color: transparent !important;
}

#viewerFile {
    width: 100%;
    height: 100%;
}

/* Tutoriels */
.tuto-box .file-img-box {
    height: auto;
    padding: 0;
    overflow: hidden;
    background: var(--brown);
}

.tuto-thumb {
    position: relative;
}

.tuto-thumb img {
    height: auto !important;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    transition: transform 300ms ease;
}

.tuto-box:hover .tuto-thumb img {
    transform: scale(1.04);
}

.tuto-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .92);
    color: var(--ink);
    font-size: 18px;
    padding-left: 3px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
    transition: transform 200ms ease, background 200ms ease, color 200ms ease;
}

.tuto-box:hover .tuto-play {
    transform: translate(-50%, -50%) scale(1.1);
    background: var(--brand);
    color: #fff;
}

.tuto-box h5 {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.tuto-admin {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 20px;
    margin: 0 0 24px;
    padding: 14px 18px;
    border-radius: var(--radius, 16px);
    background: var(--brown-10);
    border: 1px solid var(--brown-25);
}

.tuto-admin .form-check {
    display: flex;
    align-items: center;
    padding-left: 0;
    margin: 0 !important;
    min-height: 0;
}

.tuto-admin .form-check-input {
    position: static;
    width: 2.8em;
    height: 1.5em;
    margin: 0 10px 0 0;
    float: none;
    cursor: pointer;
}

.tuto-admin .form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}

.tuto-admin .form-check-input:focus {
    box-shadow: 0 0 0 .25rem rgb(146 173 65 / 30%);
}

.tuto-admin .form-check-label {
    font-size: 15px !important;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
}

.tuto-admin-etat {
    font-size: 13px;
    color: var(--muted);
}

.tuto-admin-etat.on {
    color: var(--brand-700);
}

#modalTuto .modal-body {
    padding: 0;
    overflow: hidden;
    border-radius: 0 0 var(--radius, 16px) var(--radius, 16px);
}

/* Dropzone */
.dropzone {
    border: 2px dashed var(--brand-50p) !important;
    border-radius: 14px;
    background: var(--brand-50) !important;
    color: var(--brand-700);
    font-weight: 500;
}

@media (max-width: 575.98px) {
    .card-box {
        padding: 12px;
    }

    .card-box>.row {
        --bs-gutter-x: 10px;
        --bs-gutter-y: 10px;
    }

    .file-man-box {
        padding: 10px;
    }

    .file-man-box .file-img-box {
        height: 72px;
    }

    .file-man-box .file-img-box img {
        height: 40px;
    }

    .tuto-box .file-img-box {
        height: auto;
    }
}

/* Aperçu PDF (première page) */
.file-man-box .file-img-box {
    height: 150px;
    overflow: hidden;
}

.file-man-box .file-img-box.has-preview {
    background: #fff;
    border: 1px solid var(--border);
}

.file-man-box .file-img-box.has-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}

@media (max-width: 575.98px) {
    .file-man-box .file-img-box {
        height: 120px;
    }
}

.file-man-box.tuto-box .file-img-box {
    height: auto;
    border: 0;
}

/* La carte occupe la hauteur de la colonne, le bloc admin reste dessous */
.card-box>.row>div {
    display: flex;
    flex-direction: column;
}

.card-box>.row>div>.file-man-box {
    flex: 1;
    height: auto;
}

.file-admin .form-check.form-switch {
    padding-left: 0;
}

.file-admin .form-check.form-switch .form-check-input {
    margin-left: 0;
    width: 2.2em;
    height: 1.2em;
}

/* Accents orange */
.file-man-box:hover {
    border-color: var(--accent-100);
}

.file-man-box .file-download:hover {
    background: var(--accent);
}

.tuto-box:hover .tuto-play {
    background: var(--accent);
}
