/* Reset et styles de base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    font-size: 12px;
    line-height: 1.4;
    background-color: #f5f5f5;
}

/* ========================================
   INTERFACE DE SAISIE (cachée à l'impression)
   ======================================== */

#interface {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.interface-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 3px solid #2c3e50;
}

.interface-header h1 {
    font-size: 24px;
    color: #2c3e50;
}

.interface-actions {
    display: flex;
    gap: 10px;
}

/* ========================================
   2-COLUMN GRID LAYOUT
   ======================================== */

/* Single Column Container */
.interface-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-header h2 {
    font-size: 18px;
    color: #2c3e50;
    margin: 0;
}

.counter {
    font-size: 14px;
    color: #7f8c8d;
    font-weight: normal;
}

.filter-badge {
    display: inline-block;
    padding: 4px 12px;
    background-color: #3498db;
    color: white;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 40vh;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ========================================
   BANQUE AND SELECTED SECTIONS
   ======================================== */

/* Banque Section - auto height, no scroll (pour le grid de catégories) */
.banque-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Selected Section - flexible height */
.selected-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    max-height: 60vh; /* More space for expanded accordions with directives */
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Visibility states for Selected sections */
.selected-section[data-visible="false"] {
    display: none;
}

.selected-section[data-visible="true"] {
    display: block;
    animation: slideDown 0.3s ease-out;
}

/* Empty state message for Directives */
.empty-state-message {
    padding: 60px 20px;
    text-align: center;
    margin-top: 40px;
}

.empty-state-message p {
    color: #7f8c8d;
    font-size: 1.1em;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #ddd;
    padding: 30px;
    margin: 0;
}

/* State management for Directives Banque */
.banque-section[data-state="empty"] .active-state {
    display: none;
}

.banque-section[data-state="empty"] .empty-state-message {
    display: block;
}

.banque-section[data-state="active"] .empty-state-message {
    display: none;
}

.banque-section[data-state="active"] .active-state {
    display: block;
    animation: fadeIn 0.4s ease-in;
}

.filter-badge:empty {
    display: none;
}

.filter-badge.hidden {
    display: none;
}

.interface-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

.interface-section h2 {
    font-size: 20px;
    margin-bottom: 15px;
    color: #2c3e50;
}

.interface-section h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #34495e;
}

/* Boutons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-outline {
    background-color: white;
    color: #3498db;
    border: 2px solid #3498db;
}

.btn-outline:hover {
    background-color: #3498db;
    color: white;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-small {
    padding: 5px 10px;
    font-size: 12px;
}

/* Barre de recherche */
.search-bar {
    margin-bottom: 15px;
}

.search-bar input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.search-bar input:focus {
    outline: none;
    border-color: #3498db;
}
/* Banque d'items - auto height pour afficher le grid complet */
.banque-items {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px;
    background: white;
    border-radius: 4px;
}

.selected-section h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #34495e;
    margin-top: 0;
}

.accordion-container {
    flex: 1;
    overflow-y: auto;
    background: white;
    border-radius: 4px;
    padding: 10px;
    min-height: 100px;
}

/* ========================================
   ACCORDION STYLES
   ======================================== */

.accordion-item {
    background: #f8f9fa;
    border-left: 4px solid #3498db;
    border-radius: 4px;
    margin-bottom: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
}

.accordion-item.expanded {
    border-left-color: #27ae60;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    outline: none;
}

.accordion-header:hover {
    background-color: #ecf0f1;
}

/* Keyboard accessibility */
.accordion-header:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.accordion-header:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: -2px;
}

.accordion-title {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 8px;
}

.accordion-arrow {
    font-size: 12px;
    transition: transform 0.3s ease;
    color: #7f8c8d;
}

.accordion-item.expanded .accordion-arrow {
    transform: rotate(90deg);
}

.accordion-label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 13px;
}

.accordion-preview {
    color: #7f8c8d;
    font-size: 12px;
    margin-left: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

.accordion-badges {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-left: 10px;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-directives {
    background: #27ae60;
    color: white;
}

.badge-resolved {
    background: #95a5a6;
    color: white;
}

.badge-suggestions {
    background: #f39c12;
    color: white;
}

.accordion-delete {
    padding: 4px 8px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: background-color 0.2s ease;
}

.accordion-delete:hover {
    background-color: #c0392b;
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 12px;
}

.accordion-item.expanded .accordion-content {
    max-height: 1200px; /* Augmenté pour afficher plus de directives */
    overflow-y: auto; /* Permet le scroll si nécessaire */
    padding: 12px;
    padding-top: 0;
}

.accordion-content .content-textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-family: Arial, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    margin-bottom: 10px;
}

.accordion-content .content-textarea:focus {
    outline: none;
    border-color: #3498db;
}

.accordion-metadata {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.accordion-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 100px;
}

.accordion-field label {
    font-size: 11px;
    font-weight: 600;
    color: #34495e;
}

.accordion-field input,
.accordion-field select {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 12px;
}

.accordion-field input:focus,
.accordion-field select:focus {
    outline: none;
    border-color: #3498db;
}

.accordion-field.field-wide {
    flex: 1;
    min-width: 200px;
}

/* ========================================
   DIRECTIVES INSIDE ACCORDIONS
   ======================================== */

.accordion-directives {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px solid #ecf0f1;
}

.accordion-directives-header {
    font-size: 13px;
    font-weight: 600;
    color: #34495e;
    margin-bottom: 10px;
}

.accordion-directive-item {
    padding: 10px 12px;
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.accordion-directive-item:hover {
    background: #e8f4f8;
    border-color: #3498db;
}

.accordion-directive-item.selected {
    background: #d4edda;
    border-color: #28a745;
}

.accordion-directive-checkbox {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid #95a5a6;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
    background: white;
    transition: all 0.2s ease;
}

.accordion-directive-item.selected .accordion-directive-checkbox {
    background: #28a745;
    border-color: #28a745;
}

.accordion-directive-checkbox::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.accordion-directive-item.selected .accordion-directive-checkbox::after {
    opacity: 1;
}

.accordion-directive-content {
    flex: 1;
}

.accordion-directive-text {
    font-size: 13px;
    color: #2c3e50;
    margin-bottom: 4px;
}

.accordion-directive-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* Directive groups by relevance */
.directive-group {
    margin-top: 15px;
}

.directive-group-header {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    padding: 8px 0;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.directive-group-high .directive-group-header {
    color: #27ae60;
}

.directive-group-medium .directive-group-header {
    color: #3498db;
}

.directive-group-low .directive-group-header {
    color: #95a5a6;
    cursor: pointer;
    user-select: none;
}

.directive-group-low summary {
    list-style: none;
}

.directive-group-low summary::-webkit-details-marker {
    display: none;
}

.directive-group-low summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 6px;
    transition: transform 0.2s;
}

.directive-group-low[open] summary::before {
    transform: rotate(90deg);
}

/* Matched tags highlighting */
.item-tag.tag-matched {
    box-shadow: 0 0 0 2px #f39c12;
    font-weight: 700;
}

.banque-item {
    padding: 12px;
    background: white;
    border: 2px solid #ecf0f1;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    transform: scale(1);
}

.banque-item:hover {
    border-color: #3498db;
    background-color: #f8f9fa;
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
}

.banque-item:active {
    transform: scale(0.98);
}

.banque-item.selected {
    border-color: #27ae60;
    background-color: #d5f4e6;
}

.banque-item-text {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 8px;
    color: #2c3e50;
}

.banque-item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.item-tag {
    padding: 2px 8px;
    color: white;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}

/* Color coding by category */
.item-tag.tag-mobilite { background-color: #e67e22; }
.item-tag.tag-plaies { background-color: #e74c3c; }
.item-tag.tag-medication { background-color: #9b59b6; }
.item-tag.tag-diabete { background-color: #c0392b; }
.item-tag.tag-nutrition { background-color: #f39c12; }
.item-tag.tag-elimination { background-color: #16a085; }
.item-tag.tag-douleur { background-color: #e74c3c; }
.item-tag.tag-cardio-respi { background-color: #2980b9; }
.item-tag.tag-psychosocial { background-color: #8e44ad; }
.item-tag.tag-postop { background-color: #27ae60; }
.item-tag.tag-onco { background-color: #d35400; }
.item-tag.tag-general { background-color: #95a5a6; }
.item-tag.tag-evaluation { background-color: #34495e; }
.item-tag.tag-bouche { background-color: #1abc9c; }

/* Default for unknown tags */
.item-tag:not([class*="tag-"]) {
    background-color: #95a5a6;
}

/* ========================================== */
/* CATEGORIES GRID */
/* ========================================== */

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    padding: 5px 0;
}

.category-card {
    background: white;
    border: 2px solid #ecf0f1;
    border-radius: 6px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.category-card:hover {
    border-color: #3498db;
    background-color: #f8f9fa;
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

.category-card:active {
    transform: translateY(-2px);
}

.category-icon {
    font-size: 32px;
    flex-shrink: 0;
    line-height: 1;
}

.category-content {
    flex: 1;
}

.category-name {
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
}

.category-count {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 6px;
}

.category-description {
    font-size: 11px;
    color: #95a5a6;
    line-height: 1.3;
}

/* Category detail view */
.category-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #ecf0f1;
}

.category-back-btn {
    background: #ecf0f1;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: #2c3e50;
    transition: all 0.2s ease;
    margin-bottom: 15px;
}

.category-back-btn:hover {
    background: #3498db;
    color: white;
}

.category-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
}

.category-title .category-icon {
    font-size: 28px;
}

.category-title .category-count {
    font-size: 14px;
    color: #7f8c8d;
    font-weight: normal;
}

.constats-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 12px;
}

/* Items sélectionnés */
.selected-items {
    margin-top: 20px;
    padding: 15px;
    background: white;
    border-radius: 4px;
}

.selected-item {
    padding: 15px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-left: 4px solid #3498db;
    border-radius: 4px;
}

.selected-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.selected-item-number {
    font-weight: bold;
    color: #2c3e50;
}

.selected-item-actions {
    display: flex;
    gap: 5px;
}

.selected-item-content {
    margin-bottom: 10px;
}

.selected-item-content .content-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #34495e;
    font-size: 13px;
}

.selected-item-content .content-textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.selected-item-content .content-textarea:focus {
    outline: none;
    border-color: #3498db;
}

.selected-item-metadata {
    margin-top: 15px;
}

.metadata-row {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-group-compact {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 120px;
}

.form-group-compact label {
    font-size: 12px;
    font-weight: 600;
    color: #34495e;
    margin: 0;
}

.form-group-compact input,
.form-group-compact select {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    transition: border-color 0.3s ease;
}

.form-group-compact input:focus,
.form-group-compact select:focus {
    outline: none;
    border-color: #3498db;
}

.form-group-wide {
    flex: 1;
    min-width: 250px;
}

.input-narrow {
    max-width: 80px;
}

.date-input-group {
    display: flex;
    gap: 5px;
}

.date-input-group input[type="date"] {
    flex: 1;
}

.btn-today {
    background-color: #3498db;
    color: white;
    white-space: nowrap;
    padding: 8px 12px;
}

.btn-today:hover {
    background-color: #2980b9;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #2c3e50;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
}

.form-group-inline {
    display: flex;
    gap: 10px;
    align-items: center;
}

.form-group-inline label {
    margin-bottom: 0;
    min-width: 120px;
}

.form-group-inline input,
.form-group-inline select {
    flex: 1;
}

.interface-footer {
    background: #f9f9f9;
    padding: 15px 20px;
    border-radius: 8px;
}

.interface-footer h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.interface-footer .form-group {
    display: inline-block;
    margin-right: 20px;
    margin-bottom: 0;
}

.interface-footer input {
    width: auto;
    min-width: 150px;
}

/* ========================================
   FORMULAIRE PTI (pour impression)
   ======================================== */

#pti-form {
    width: 100%;
    margin: 0;
    padding: 0;
    background: white;
}

.pti-page {
    width: 215.9mm;
    min-height: 279.4mm;
    margin: 0 auto;
    padding: 0;
    position: relative;
    page-break-after: always;
    background: white;
}

.pti-page:last-of-type {
    page-break-after: auto;
}

.pti-page-front {
    padding-bottom: 10mm;
}

.pti-page-back {
    padding: 12mm 0 10mm 0;
}

/* Bande verte uniquement sur le recto */
.pti-page-front::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 12mm;
    background-color: #00853f;
}

/* Header PTI */
.pti-header {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    margin-bottom: 0;
    padding: 10mm 0 0 0;
    min-height: 45mm;
}

/* Zone centrale: titre et code-barres */
.header-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: center;
    flex: 1;
    padding: 0 15mm 0 10mm;
}

.barcode-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1mm;
    align-self: flex-end;
}

.pti-barcode {
    width: 150px;
    height: 52px;
}

.pti-barcode rect {
    fill: #000;
}

.barcode-label {
    font-size: 11px;
    letter-spacing: 1px;
    margin-top: 1mm;
}

.pti-title {
    font-size: 17px;
    font-weight: bold;
    text-align: right;
    margin: 8mm 0 0 0;
    text-transform: uppercase;
    line-height: 1.3;
}

/* Ligne verticale séparatrice à droite avec ligne horizontale en bas */
.header-separator {
    width: 1px;
    background-color: #000;
    margin-right: 90mm;
    align-self: stretch;
    position: relative;
}

/* Ligne horizontale en bas du séparateur */
.header-separator::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 68mm;
    height: 1px;
    background-color: #000;
}

/* Tables PTI */
.pti-table {
    width: calc(100% - 32mm);
    margin-left: 10mm;
    margin-right: 22mm;
    border-collapse: collapse;
    margin-bottom: 0;
    font-size: 10px;
    line-height: 1.2;
}

/* Premier tableau (Constats) - espacement plus important après l'en-tête */
.pti-table:first-of-type {
    margin-top: 6mm;
}


.pti-page-back .pti-table:first-of-type {
    margin-top: 0;
}

/* Dernier tableau (Suivi clinique) - pas d'espacement avant signatures */
.pti-table:last-of-type {
    margin-bottom: 0;
}

.pti-table th,
.pti-table td {
    border: 1px solid #000;
    padding: 3px 4px;
    vertical-align: top;
}

.pti-table th {
    font-weight: bold;
    text-align: center;
}

.pti-table .header-row {
    background-color: #000;
    color: #fff;
}

.pti-table .header-row th {
    padding: 5px 4px;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    text-transform: uppercase;
}

.pti-table .subheader-row th {
    background-color: #eee9e2;
    color: #000;
    padding: 4px;
    font-size: 9px;
    font-weight: bold;
    text-align: center;
    vertical-align: middle;
    border: 1px solid #000;
}

.pti-table .subheader-detail th {
    font-weight: normal;
    font-size: 8px;
}

.pti-table tbody tr:nth-child(odd),
.pti-table tbody tr:nth-child(even) {
    background-color: transparent;
}

.pti-table tbody td {
    background-color: #ffffff;
}

/* Forcer une hauteur minimale avec un contenu invisible */
.pti-table tbody td:empty::after {
    content: "\00a0";
    visibility: hidden;
}

/* Column widths - Constats table */
.pti-table .col-date {
    width: 7%;
    text-align: center;
}

.pti-table .col-heure {
    width: 6%;
    text-align: center;
}

.pti-table .col-numero {
    width: 3%;
    text-align: center;
    border-right: 1px dashed #000 !important;
}

.pti-table .col-probleme {
    width: 33%;
    min-width: 250px;
    line-height: 1.2;
    word-wrap: break-word;
    text-align: left;
}

.pti-table .col-initiales {
    width: 6%;
    text-align: center;
}

.pti-table .col-services {
    width: 15%;
    line-height: 1.2;
    word-wrap: break-word;
    text-align: center;
    vertical-align: middle;
    border-left-width: 4px !important;
    border-left-style: double !important;
    border-left-color: #000 !important;
}

/* Bordure double pour la colonne Professionnels/Services uniquement dans le tableau des constats */
.pti-table-constats .col-services,
.pti-table-constats tbody tr td:nth-child(9) {
    border-left-width: 4px !important;
    border-left-style: double !important;
    border-left-color: #000 !important;
}

/* Column widths - Directives table */
.pti-table .col-directive {
    width: auto;
    min-width: 350px;
    line-height: 1.2;
    word-wrap: break-word;
}

/* Table rows */
.pti-table tbody td {
    min-height: 18px;
    line-height: 1.2;
    font-size: 10px;
    padding: 4px 4px;
}

/* Text wrapping in cells */
.pti-table tbody td {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Footer table - Section Signatures */
.pti-footer {
    width: calc(100% - 32mm);
    margin-left: 10mm;
    margin-right: 22mm;
    border-collapse: collapse;
    margin-top: 9px;
    font-size: 10px;
}

.pti-footer th,
.pti-footer td {
    border: 1px solid #000;
    padding: 4px;
    vertical-align: top;
}

/* En-têtes de la section signatures - fond gris clair */
.pti-footer .signature-header th {
    background-color: #e2e0dc;
    font-weight: 600;
    font-size: 9px;
    text-align: left;
    padding: 3px 4px;
}

/* Cellules de données - fond blanc, hauteur réduite pour correspondre au formulaire */
.pti-footer td {
    background-color: #ffffff;
    height: 18px;
    min-height: 18px;
    padding: 3px 4px;
}

/* Proportions des colonnes - 6 colonnes (2 groupes de 3) */
.pti-footer .col-signature {
    width: 28%;
}

.pti-footer .col-initiales-footer {
    width: 8%;
}

.pti-footer .col-programme {
    width: 14%;
}

/* Footer text */
.pti-footer-text {
    width: calc(100% - 32mm);
    margin-top: 3px;
    margin-left: 10mm;
    margin-right: 22mm;
    margin-bottom: 8mm;
    font-size: 9px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto auto;
    column-gap: 6mm;
    row-gap: 1px;
    align-items: start;
}

.footer-block {
    font-size: 8px;
}

.footer-block.copyright {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 1.2em;
}

.footer-block.form-number {
    grid-column: 1;
    grid-row: 3;
}

.footer-block.form-title {
    grid-column: 2;
    grid-row: 3;
    font-weight: bold;
    font-size: 10px;
    text-align: center;
}

.footer-block.page-number {
    grid-column: 3;
    grid-row: 3;
    justify-self: end;
    font-size: 8px;
}

.page-underline {
    display: inline-block;
    min-width: 8mm;
    border-bottom: 1px solid #000;
    margin-left: 4px;
    padding-bottom: 2px;
}

/* ========================================
   MEDIA QUERIES POUR IMPRESSION
   ======================================== */

@media print {
    body {
        background: white;
        margin: 0;
        padding: 0;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    }

    /* Police plus fiable pour l'impression PDF */
    .pti-table,
    .pti-table th,
    .pti-table td,
    .pti-footer,
    .pti-footer th,
    .pti-footer td,
    .pti-title {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    }

    /* Cacher l'interface */
    .no-print {
        display: none !important;
    }

    /* Afficher le formulaire PTI */
    .print-only {
        display: block !important;
    }

    #pti-form {
        max-width: 100%;
        margin: 0;
        padding: 0;
        box-shadow: none;
    }

    /* Bande verte à l'impression - centrée verticalement */
    .pti-page-front::after {
        background-color: #00853f !important;
        height: auto !important;
        top: 3.75% !important;
        bottom: 2% !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    /* Page PTI pour impression */
    .pti-page {
        width: 100%;
        min-height: auto;
        height: auto;
        margin: 0;
        padding: 0;
        overflow: hidden;
    }

    .pti-page-front {
        padding-bottom: 0;
    }

    .pti-page-back {
        padding-top: 45mm; /* Espace équivalent au header du recto */
    }

    /* Marges horizontales - 22mm de chaque côté */
    .pti-table {
        width: calc(100% - 44mm) !important;
        margin-left: 22mm !important;
        margin-right: 22mm !important;
    }

    .pti-footer {
        width: calc(100% - 44mm) !important;
        margin-left: 22mm !important;
        margin-right: 22mm !important;
        margin-top: 8px !important;
    }

    .pti-footer-text {
        width: calc(100% - 44mm) !important;
        margin-left: 22mm !important;
        margin-right: 22mm !important;
        margin-bottom: 3mm;
        margin-top: 2mm;
    }

    .pti-header {
        padding-left: 22mm;
        padding-right: 22mm;
        min-height: 60mm !important; /* Augmenté pour aligner le footer en bas */
        padding-top: 18mm !important;
    }

    /* Titre PTI réduit pour tenir sur une ligne */
    .pti-title {
        font-size: 14px !important;
        margin-top: 6mm !important;
    }

    /* Code-barres réduit */
    .pti-barcode {
        width: 150px !important;
        height: 52px !important;
    }

    /* Lignes du header */
    .header-separator {
        background-color: #000 !important;
        margin-right: 80mm !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    .header-separator::after {
        background-color: #000 !important;
        width: 80mm !important;
        height: 1px !important;
        left: 0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    /* Réduire les espacements pour tenir sur une page */
    .pti-table {
        margin-bottom: 0;
    }

    /* Optimisation pour l'impression */
    .pti-table {
        page-break-inside: avoid;
    }

    .pti-table th,
    .pti-table td {
        page-break-inside: avoid;
    }

    /* Forcer les bordures et couleurs à l'impression */
    .pti-table,
    .pti-table th,
    .pti-table td,
    .pti-footer,
    .pti-footer th,
    .pti-footer td {
        border-color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    /* Headers noirs */
    .pti-table .header-row {
        background-color: #000 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    .pti-table .header-row th {
        background-color: #000 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    /* Subheaders */
    .pti-table .subheader-row th {
        background-color: #eee9e2 !important;
        border: 1px solid #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    .pti-table tbody td {
        background-color: #ffffff !important;
        padding: 3px 4px !important;
        line-height: 1.2 !important;
        font-size: 10px !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    /* Forcer une hauteur minimale avec un contenu invisible */
    .pti-table tbody td:empty::after {
        content: "\00a0"; /* espace insécable */
        visibility: hidden;
    }

    /* Fond blanc pour les cellules de signature aussi */
    .pti-footer td {
        background-color: #ffffff !important;
        padding: 3px 4px !important;
        height: 18px !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    /* Ligne pointillée après N° */
    .pti-table .col-numero {
        border-right: 1px dashed #000 !important;
    }

    /* Bordure double pour Professionnels/Services uniquement dans le tableau des constats */
    .pti-table-constats .col-services,
    .pti-table-constats tbody tr td:nth-child(9) {
        border-left-width: 4px !important;
        border-left-style: double !important;
        border-left-color: #000 !important;
    }

    /* Zone d'identification patient pour impression */
    .patient-id-box,
    .patient-id-box::before,
    .patient-id-box::after {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    /* Section signatures pour impression */
    .pti-footer th,
    .pti-footer td {
        border: 1px solid #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    .pti-footer .signature-header th {
        background-color: #e2e0dc !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    /* Fond blanc pour toutes les lignes */
    .pti-footer td {
        background-color: #ffffff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    /* Bordure double pour Professionnels/Services - simulation avec box-shadow */
    .pti-table-constats .col-services,
    .pti-table-constats tbody tr td:nth-child(9) {
        border-left: 1px solid #000 !important;
        box-shadow: inset 3px 0 0 0 #fff, inset 4px 0 0 0 #000 !important;
    }

    @page {
        size: letter;
        margin: 0;
    }
}

/* ========================================
   STYLES UTILITAIRES
   ======================================== */

.hidden {
    display: none;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}
