.modal.pdf-viewer-modal {
    padding: 0.6rem;
    background: rgba(15, 23, 42, 0.72);
}

.modal.pdf-viewer-modal .modal-content {
    display: flex !important;
    flex-direction: column !important;
    width: min(1400px, calc(100vw - 1.2rem)) !important;
    max-width: min(1400px, calc(100vw - 1.2rem)) !important;
    height: calc(100dvh - 1.2rem) !important;
    max-height: calc(100dvh - 1.2rem) !important;
    margin: 0 !important;
    overflow: hidden !important;
    border-radius: 0.85rem !important;
}

.modal.pdf-viewer-modal .modal-header {
    flex: 0 0 auto;
    padding: 0.7rem 0.9rem;
}

.modal.pdf-viewer-modal .modal-header h2 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1rem;
}

.modal.pdf-viewer-modal .modal-body {
    display: flex;
    flex: 1;
    min-height: 0;
    padding: 0 !important;
    overflow: hidden !important;
}

.pdf-viewer-shell,
.pdf-viewer-frame-wrap {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 0;
}

.pdf-viewer-shell {
    flex-direction: column;
}

.pdf-viewer-toolbar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.pdf-viewer-filename {
    min-width: 0;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 0.86rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdf-viewer-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 0.4rem;
}

.pdf-viewer-action {
    display: inline-flex;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    background: var(--background);
    color: var(--primary);
    cursor: pointer;
}

.pdf-viewer-action:hover,
.pdf-viewer-action:focus-visible {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, var(--surface));
}

.pdf-viewer-action:disabled {
    opacity: 0.55;
    cursor: wait;
}

.pdf-viewer-action svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.pdf-viewer-frame-wrap {
    background: #525659;
}

.pdf-viewer-frame {
    width: 100%;
    height: 100%;
    border: 0;
    background: #525659;
}

.pdf-viewer-attachment {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background: var(--background);
}

.pdf-viewer-attachment span {
    padding: 0.25rem 0.4rem;
    border-radius: 0.35rem;
    background: #fee2e2;
    color: #b91c1c;
    font-size: 0.72rem;
    font-weight: 800;
}

.pdf-viewer-email-hint {
    margin: 0.65rem 0 0;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

/* Le composeur empilé garde sa taille de formulaire au-dessus du PDF. */
.modal:has(#pdf-viewer-email-form) {
    align-items: center;
    justify-content: center;
    padding: 0.6rem;
}

.modal:has(#pdf-viewer-email-form) .modal-content {
    width: min(680px, calc(100vw - 1.2rem)) !important;
    max-width: min(680px, calc(100vw - 1.2rem)) !important;
    height: auto !important;
    max-height: calc(100dvh - 1.2rem) !important;
}

.modal:has(#pdf-viewer-email-form) .modal-body {
    display: block;
    padding: 1rem !important;
    overflow-y: auto !important;
}

#pdf-viewer-email-form { width: 100%; min-width: 0; }
#pdf-viewer-email-form .form-textarea { font-family: inherit; }
#pdf-viewer-email-form .pdf-viewer-attachment strong { min-width: 0; overflow-wrap: anywhere; }
#pdf-viewer-email-form .pdf-viewer-attachment + .pdf-viewer-attachment { margin-top: 0.5rem; }

.pdf-email-extra {
    display: grid;
    gap: 0.65rem;
    margin-top: 0.85rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.65rem;
}

.pdf-email-extra > strong { font-size: 0.9rem; }
.pdf-email-extra > small, [data-pdf-email-saved] { color: var(--text-secondary); font-size: 0.82rem; }
.pdf-email-extra [data-pdf-email-saved] .form-checkbox { color: var(--text); min-height: 44px; }
.pdf-email-file-picker { position: relative; justify-self: start; min-height: 44px; cursor: pointer; }
.pdf-email-file-picker input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.pdf-email-file-picker:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.pdf-email-extra-file { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; min-height: 44px; }
.pdf-email-extra-file span { min-width: 0; overflow-wrap: anywhere; }
.pdf-email-extra-file button { flex: none; min-height: 44px; }
.rental-contract-file.form-checkbox { min-height: 44px; justify-content: flex-start; flex-direction: row; }

.pdf-print-root {
    position: fixed;
    top: 0;
    left: -100000px;
    width: 210mm;
    visibility: hidden;
    pointer-events: none;
}

.pdf-print-page,
.pdf-print-page canvas,
.pdf-print-page img {
    display: block;
    width: 100%;
}

.pdf-print-page {
    aspect-ratio: var(--pdf-page-ratio);
}

.pdf-print-page canvas,
.pdf-print-page img {
    height: 100%;
    object-fit: contain;
}

html.trucklist-native-print,
html.trucklist-native-print body {
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
}

html.trucklist-native-print body > :not(.pdf-print-root) {
    display: none !important;
}

html.trucklist-native-print .pdf-print-root {
    position: static;
    left: auto;
    width: 100%;
    visibility: visible;
}

html.trucklist-native-print .pdf-print-page {
    break-after: page;
    page-break-after: always;
}

html.trucklist-native-print .pdf-print-page:last-child {
    break-after: auto;
    page-break-after: auto;
}

@media print {
    @page {
        margin: 0;
    }

    html,
    body {
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        background: #fff !important;
    }

    body > :not(.pdf-print-root) {
        display: none !important;
    }

    .pdf-print-root {
        position: static;
        left: auto;
        width: 100%;
        visibility: visible;
    }

    .pdf-print-page {
        break-after: page;
        page-break-after: always;
    }

    .pdf-print-page:last-child {
        break-after: auto;
        page-break-after: auto;
    }
}

@media (max-width: 700px) {
    .modal.pdf-viewer-modal {
        padding: 0;
    }

    .modal.pdf-viewer-modal .modal-content {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
    }

    .modal.pdf-viewer-modal .modal-header {
        padding: calc(0.6rem + env(safe-area-inset-top, 0px)) 0.7rem 0.6rem;
    }

    .pdf-viewer-toolbar {
        padding: 0.45rem 0.6rem;
    }

    .pdf-viewer-action {
        width: 44px;
        height: 44px;
    }
}
.email-address-book { position: relative; min-width: 0; }
.email-address-menu {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    z-index: 12;
    max-height: 220px;
    overflow-y: auto;
    padding: 6px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #17212f);
    border: 1px solid var(--border-color, #d8dee7);
    border-radius: 8px;
    box-shadow: 0 5px 18px #0002;
}
.email-address-menu[hidden] { display: none; }
.email-address-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.email-address-row button {
    border: 0;
    border-radius: 5px;
    padding: 8px;
    min-height: 36px;
    cursor: pointer;
    color: inherit;
    background: transparent;
}
.email-address-row button:hover, .email-address-row button:focus-visible { background: var(--bg-secondary, #edf2f7); }
.email-address-choice { flex: 1; min-width: 0; text-align: left; overflow-wrap: anywhere; }
.email-address-proposals .email-address-row { flex-wrap: wrap; padding-top: 6px; font-size: .85rem; }
.email-address-proposals span { flex: 1 1 180px; overflow-wrap: anywhere; }
.email-address-proposals button { color: var(--primary, #2563eb); }
