/* Styles pour la modal des logbooks EDEC */
#documentModal,
#deleteConfirmModal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 14, 188, 0.15);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
}

.modal[style*="display: block"] {
    display: flex !important;
}

#documentModal .modal-content,#deleteConfirmModal .modal-content {
    background: #fff;
    margin: 5% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 14, 188, 0.15);
    animation: modalSlideIn 0.3s ease-out;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #E0E0E0;
}

.modal-title {
    font-family: "Fira Sans", sans-serif;
    font-size: 24px;
    color: #000EBC;
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    color: #666;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    transition: all 0.3s ease;
}

.modal-close:hover {
    color: #000EBC;
    transform: rotate(90deg);
}

#editRepeaterItemForm {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#editRepeaterItemForm p,
#addDocumentForm p {
    margin: 0;
}

#editRepeaterItemForm label,
#addDocumentForm label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
    font-family: "Fira Sans", sans-serif;
}

#editRepeaterItemForm input[type="file"] {
    padding: 10px;
    border: 2px dashed #000EBC;
    border-radius: 8px;
    background: rgba(0, 14, 188, 0.05);
    cursor: pointer;
}

#editRepeaterItemForm input[type="text"],
#editRepeaterItemForm input[type="text"],
#editRepeaterItemForm select,
#editRepeaterItemForm textarea,
#addDocumentForm input[type="text"],
#addDocumentForm select,
#addDocumentForm textarea,
#addDocumentForm input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    font-family: inherit;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

#editRepeaterItemForm input[type="text"]:focus,
#editRepeaterItemForm select:focus,
#editRepeaterItemForm textarea:focus {
    outline: none;
    border-color: #000EBC;
    box-shadow: 0 0 0 2px rgba(0, 14, 188, 0.1);
}

#editRepeaterItemForm textarea {
    min-height: 100px;
    resize: vertical;
}

#editRepeaterItemForm select {
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23000EBC' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

#editRepeaterItemForm .file-info {
    margin: 10px 0;
    padding: 10px;
    background: #F5F5F5;
    border-radius: 8px;
    word-break: break-all;
}



/* Styles communs pour tous les boutons des modales */
.btn-primary,
.btn-secondary,
.btn-danger,
#editRepeaterItemForm button[type="submit"],
#addDocumentForm button[type="submit"] {
    padding: 12px 24px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-width: 120px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Style primaire (boutons de soumission) */
.btn-primary,
#editRepeaterItemForm button[type="submit"],
#addDocumentForm button[type="submit"] {
    background: #000EBC;
    color: white;
    border: none;
    margin-top: 10px;
    padding: 12px 24px;
    font-size: 14px;
    letter-spacing: 0.5px;
    font-weight: 500;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-primary:hover,
#editRepeaterItemForm button[type="submit"]:hover,
#addDocumentForm button[type="submit"]:hover {
    background: #5500F9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 14, 188, 0.2);
}

.btn-primary:disabled,
#editRepeaterItemForm button[type="submit"]:disabled,
#addDocumentForm button[type="submit"]:disabled {
    background: rgba(0, 14, 188, 0.6);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* État de chargement pour tous les boutons */
.btn-primary.loading,
.btn-danger.loading,
#editRepeaterItemForm button[type="submit"].loading,
#addDocumentForm button[type="submit"].loading {
    background: rgba(0, 14, 188, 0.1);
    color: transparent !important;
    pointer-events: none;
}

/* Masquer le texte pendant le chargement */
.btn-primary.loading span,
.btn-danger.loading span,
#editRepeaterItemForm button[type="submit"].loading span,
#addDocumentForm button[type="submit"].loading span {
    visibility: hidden;
}

/* Texte de chargement pour tous les boutons */
.btn-primary.loading::before,
.btn-danger.loading::before,
#editRepeaterItemForm button[type="submit"].loading::before,
#addDocumentForm button[type="submit"].loading::before {
    content: attr(data-loading-text);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #000EBC;
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    transition: color 0.3s ease;
}

/* Loader pour tous les boutons */
.btn-primary.loading::after,
.btn-danger.loading::after,
#editRepeaterItemForm button[type="submit"].loading::after,
#addDocumentForm button[type="submit"].loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid #000EBC;
    border-radius: 50%;
    border-right-color: transparent;
    animation: buttonLoader 0.8s linear infinite;
}

@keyframes buttonLoader {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Hover pour tous les boutons */
.btn-primary:hover,
#editRepeaterItemForm button[type="submit"]:hover,
#addDocumentForm button[type="submit"]:hover {
    background: #5500F9;
    transform: translateY(-1px);
}

#editRepeaterItemForm button[type="submit"].loading:hover,
#addDocumentForm button[type="submit"].loading:hover {
    background: #5500F9;
}

#editRepeaterItemForm button[type="submit"].loading:hover::before,
#addDocumentForm button[type="submit"].loading:hover::before {
    color: #fff;
}

#editRepeaterItemForm button[type="submit"].loading:hover::after,
#addDocumentForm button[type="submit"].loading:hover::after {
    border-color: #fff;
    border-right-color: transparent;
}

/* Styles pour les boutons de la modale de confirmation */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.btn-secondary {
    background: transparent;
    color: #000EBC;
    border: 1px solid #000EBC;
    padding: 12px 24px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(0, 14, 188, 0.1);
    transform: translateY(-1px);
}

.btn-danger {
    background: #000EBC;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.btn-danger:hover {
    background: #5500F9;
    transform: translateY(-1px);
}

.btn-danger.loading {
    color: transparent;
    background: rgba(0, 14, 188, 0.1);
}

.btn-danger.loading span {
    visibility: hidden;
}

.btn-danger.loading::before {
    content: 'Suppression...';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #000EBC;
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    transition: color 0.3s ease;
}

.btn-danger.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 12px;
    margin-top: -8px;
    border: 2px solid #000EBC;
    border-radius: 50%;
    border-right-color: transparent;
    animation: buttonLoader 0.8s linear infinite;
}

.btn-danger.loading:hover {
    background: #5500F9;
}

.btn-danger.loading:hover::before {
    color: #fff;
}

.btn-danger.loading:hover::after {
    border-color: #fff;
    border-right-color: transparent;
}

/* Styles pour les champs fichier */
.file-info,
.file-field {
    background: rgba(0, 14, 188, 0.05);
    padding: 12px;
    border-radius: 8px;
    word-break: break-word;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    margin-bottom: 15px;
}

.modal-content .file-info,
.modal-content .file-field {
    width: calc(100% - 24px);
    margin: 15px 0;
}

.file-info a,
.file-field a {
    color: #000EBC;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    font-weight: 500;
    overflow: hidden;
}

.file-info a span,
.file-field a span {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.file-info a:hover,
.file-field a:hover {
    text-decoration: underline;
}

/* Styles pour les statuts */
.status-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.status-label {
    color: #666;
    font-weight: 500;
}

.status-item[data-status="approved"] {
    color: #28a745;
}

.status-item[data-status="pending"] {
    color: #ffc107;
}

.status-item[data-status="rejected"] {
    color: #dc3545;
}

/* Styles pour le tableau des logbooks */
.document-logbook {
    background: #fff;
    border-radius: 15px;
    padding: 30px;
    margin: 30px 0;
    box-shadow: 0 4px 20px rgba(0, 14, 188, 0.1);
}

.totalLogbook {
    background: linear-gradient(90deg, rgba(0, 113, 245, 0.1) 0%, rgba(14, 0, 186, 0.1) 100%);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
    font-family: "Fira Sans", sans-serif;
    font-size: 18px;
    color: #000EBC;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

#openAddModal {
    background: #000EBC;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-family: "Fira Sans", sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 25px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#openAddModal::before {
    content: '+';
    font-size: 20px;
    font-weight: 400;
}

#openAddModal:hover {
    background: #5500F9;
    transform: translateY(-1px);
}

.document-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 20px 0 0;
    width: 100%;
}

.document-table {
    width: 100%;
    min-width: 600px;
    border-collapse: separate;
    border-spacing: 0;
    font-family: "Fira Sans", sans-serif;
}

.document-table thead {
    background: #F5F5F5;
}

.document-table th {
    color: #333;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.document-table th:first-child {
    border-top-left-radius: 10px;
}

.document-table th:last-child {
    border-top-right-radius: 10px;
}

.document-table td {
    padding: 15px;
    border-bottom: 1px solid rgba(0, 14, 188, 0.1);
    font-size: 14px;
    color: #333;
    vertical-align: middle;
}

.document-table tbody tr {
    transition: all 0.3s ease;
}

.document-table tbody tr:hover {
    background-color: rgba(85, 0, 249, 0.05);
}

.document-table td a {
    color: #000EBC;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}

.document-table td a::before {
    content: '';
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 11V14H2V11H0V14C0 15.1 0.9 16 2 16H14C15.1 16 16 15.1 16 14V11H14ZM13 7L11.59 5.59L9 8.17V0H7V8.17L4.41 5.59L3 7L8 12L13 7Z' fill='%23000EBC'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

.document-table td a:hover {
    text-decoration: underline;
}

.document-table button.editDoc,
.document-table button.deleteDoc {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-edit,
.icon-delete {
    width: 16px;
    height: 16px;
    display: inline-block;
    background-repeat: no-repeat;
    background-position: center;
}

.icon-edit {
    background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.7 0.3C12.3 -0.1 11.7 -0.1 11.3 0.3L5 6.6V11H9.4L15.7 4.7C16.1 4.3 16.1 3.7 15.7 3.3L12.7 0.3ZM8.6 10H6V7.4L11.3 2.1L13.9 4.7L8.6 10ZM2 2H8L10 0H2C0.9 0 0 0.9 0 2V14C0 15.1 0.9 16 2 16H14C15.1 16 16 15.1 16 14V6L14 8V14H2V2Z' fill='%23000EBC'/%3E%3C/svg%3E");
}

.icon-delete {
    background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 14C4 15.1 4.9 16 6 16H10C11.1 16 12 15.1 12 14V4H4V14ZM13 1H10.5L9.5 0H6.5L5.5 1H3V3H13V1Z' fill='%23dc3545'/%3E%3C/svg%3E");
}

.document-table button.editDoc {
    background-color: rgba(0, 14, 188, 0.1);
    color: #000EBC;
}

.document-table button.deleteDoc {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.document-table button.editDoc:hover {
    background: #5500F9;
    transform: translateY(-1px);
}

/* Styles pour gérer les noms de fichiers longs dans le tableau */
.document-table {
    table-layout: fixed;
    width: 100%;
}

.document-table th,
.document-table td {
    padding: 10px;
    vertical-align: middle;
}

.document-table th:nth-child(1) { width: 5%; }  /* ID */
.document-table th:nth-child(2) { width: 18%; } /* File */
.document-table th:nth-child(3) { width: 20%; } /* Report Type */
.document-table th:nth-child(4) { width: 30%; } /* Status */
.document-table th:nth-child(5) { width: 15%; } /* Date */
.document-table th:nth-child(6) { width: 15%; } /* Actions */

/* Show full filename on hover */
.document-table td a[title="Download the file"] {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    display: block;
    max-width: 100%;
}

.document-table td a[title="Download the file"]:hover::after {
    content: attr(title);
    position: absolute;
    background: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    white-space: normal;
    word-break: break-all;
    max-width: 300px;
}

.document-table td:nth-child(2) a {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-table button.editDoc:hover .icon-edit {
    background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.7 0.3C12.3 -0.1 11.7 -0.1 11.3 0.3L5 6.6V11H9.4L15.7 4.7C16.1 4.3 16.1 3.7 15.7 3.3L12.7 0.3ZM8.6 10H6V7.4L11.3 2.1L13.9 4.7L8.6 10ZM2 2H8L10 0H2C0.9 0 0 0.9 0 2V14C0 15.1 0.9 16 2 16H14C15.1 16 16 15.1 16 14V6L14 8V14H2V2Z' fill='%23ffffff'/%3E%3C/svg%3E");
}

.document-table button.deleteDoc:hover {
    background: #dc3545;
    transform: translateY(-1px);
}

.document-table button.deleteDoc:hover .icon-delete {
    background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 14C4 15.1 4.9 16 6 16H10C11.1 16 12 15.1 12 14V4H4V14ZM13 1H10.5L9.5 0H6.5L5.5 1H3V3H13V1Z' fill='%23ffffff'/%3E%3C/svg%3E");
}

.document-table td[data-status="Validated"] {
    color: #2E7D32;
    font-weight: 500;
}

.document-table td[data-status="Pending"] {
    color: #E65100;
    font-weight: 500;
}

.report-stat {
    display: flex;
    align-items: center;
    gap: 10px;
}

.report-stat strong {
font-weight: 600;
}

.stat-numbers {
background: rgba(255, 255, 255, 0.5);
padding: 4px 12px;
border-radius: 20px;
font-size: 14px;
}

.file-info,
.file-field {
background: rgba(0, 14, 188, 0.05);
padding: 12px;
border-radius: 8px;
word-break: break-word;
max-width: 100%;
box-sizing: border-box;
overflow: hidden;
}

.file-info a,
.file-field a {
color: #000EBC;
text-decoration: none;
display: inline-flex;
align-items: flex-start;
gap: 8px;
max-width: 100%;
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
}

.file-info a:hover,
.file-field a:hover {
text-decoration: underline;
}

.text-center {
text-align: center;
}

.report-type {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 13px;
    font-weight: 500;
}

.report-type.tte {
    background-color: rgba(0, 14, 188, 0.1);
    color: #000EBC;
}

.report-type.tee {
    background-color: rgba(85, 0, 249, 0.1);
    color: #5500F9;
}

.no-file,
.no-comment {
    color: #999;
    font-style: italic;
    font-size: 13px;
}

.comment-preview {
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.action-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
    align-items: center;
}

.no-records td {
    text-align: center;
    padding: 30px !important;
    color: #666;
    font-style: italic;
}

@media screen and (max-width: 1024px) {
    .document-logbook {
        padding: 15px;
    }
    
    .totalLogbook {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
}

@media screen and (max-width: 768px) {
    .document-logbook {
        padding: 15px;
        margin: 15px 0;
    }
    
    .document-table th,
    .document-table td {
        padding: 10px;
        font-size: 13px;
    }
    
    #openAddModal {
        width: 100%;
        justify-content: center;
    }
    
    .modal-content {
        margin: 10% 15px;
        padding: 20px;
    }
    
    .modal-title {
        font-size: 20px;
    }
}
