/* CSS pour la table dynamique générée par le composant */

/* Pré-bouton espèce actif (filtre ARRAY niveau 1) */
.array-species-btn.active-species {
    background: #005068;
    color: #fff;
    border-color: #005068;
}

.dynamic-table-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
}

.filter-panel {
    position: relative;
}

.filter-panel .filter-toggle-btn {
    padding: 10px 15px;
    background-color: #005068;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-family: "Saira Condensed", sans-serif;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-panel .filter-toggle-btn:hover {
    background-color: #003d52;
}

.filter-panel .filter-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
}

.filter-panel .filter-overlay.open {
    display: block;
}

.filter-panel .filter-content {
    display: none;
    position: fixed;
    background-color: white;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    padding: 20px;
    max-width: 600px;
    max-height: 500px;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.filter-panel .filter-content.open {
    display: flex;
}

.filter-panel .filter-group {
    flex: 1;
    min-width: 140px;
}

.filter-panel .filter-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.filter-panel .filter-title {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #005068;
    font-size: 0.9rem;
}

.filter-panel .filter-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    cursor: pointer;
}

.filter-panel .filter-checkbox input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.filter-panel .filter-checkbox label {
    cursor: pointer;
    font-size: 0.9rem;
    color: #333;
    margin: 0;
}

.dynamic-table-wrapper .search-box {
    display: none !important;
    padding: 12px 15px;
    background-color: white;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.dynamic-table-wrapper .search-box i {
    color: #999;
    font-size: 1rem;
}

.dynamic-table-wrapper .search-box input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-family: "Saira Condensed", sans-serif;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.dynamic-table-wrapper .search-box input:focus {
    outline: none;
    border-color: #005068;
    box-shadow: 0 0 0 3px rgba(0, 80, 104, 0.1);
}

.dynamic-table-wrapper .table-container {
    flex: 1;
    position: relative;
    overflow-y: auto;
    height: calc(100vh - 250px);
    max-height: calc(100vh - 250px);
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    scrollbar-gutter: stable;
}

.table-search-loader {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.82);
    color: #005068;
    font-weight: 600;
}

.table-search-loader[hidden] {
    display: none;
}

.table-search-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #d5e2e5;
    border-top-color: #005068;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.dynamic-table {
    width: auto;
    border-collapse: collapse;
    font-family: "Saira Condensed", sans-serif;
    background-color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    table-layout: auto;
}

.dynamic-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #005068;
    color: white;
    border-radius: 4px 4px 0 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15), inset 0 -2px 0 rgba(0, 61, 92, 1);
}

/* Rail de scroll horizontal collé sous la ligne des <th>
   (barre unique, synchronisée avec le défilement du conteneur) */
.dynamic-table .hscroll-rail-row td {
    padding: 0;
    background-color: #005068;
    border: none;
}

/* Colonnes RESULT_OBS (en-tetes, couleur differente des colonnes RESULT #6a966d) */
.dynamic-table th.result-obs-header {
    background-color: #2f6db3;
    color: #fff;
    text-align: center;
    font-weight: 600;
    border-bottom: 2px solid #7fb3d8;
}
.dynamic-table th.result-obs-header:hover {
    background-color: #245a8c;
}
.dynamic-table td.result-obs-cell {
    text-align: center;
}

.dynamic-table .hscroll-rail {
    position: sticky;
    left: 0;
    display: block;
    height: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    background-color: #005068;
    scrollbar-width: thin;
    scrollbar-color: #ffffff rgba(255, 255, 255, 0.2);
    background-color: #69bad3;
}

.dynamic-table .hscroll-rail-spacer {
    height: 1px;
}

.dynamic-table .hscroll-rail::-webkit-scrollbar {
    height: 10px;
}

.dynamic-table .hscroll-rail::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
}

.dynamic-table .hscroll-rail::-webkit-scrollbar-thumb {
    background: #ffffff;
    border-radius: 5px;
    border: 2px solid #005068;
}

.dynamic-table .hscroll-rail::-webkit-scrollbar-thumb:hover {
    background: #cfe9f2;
}

.dynamic-table th {
    padding: 5px;
    text-align: left;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
    position: relative;
}

.dynamic-table th .header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    width: 100%;
}

.dynamic-table th .column-resize-handle {
    position: absolute;
    top: 0;
    right: -4px;
    z-index: 5;
    width: 8px;
    height: 24px;
    cursor: col-resize;
    touch-action: none;
}

.dynamic-table th .column-resize-handle::after {
    position: absolute;
    top: 6px;
    bottom: 6px;
    left: 3px;
    width: 2px;
    background: rgba(255, 255, 255, 0.3);
    content: "";
}

.dynamic-table th .column-resize-handle:hover::after {
    background: #fff;
}

.dynamic-table th .column-search-control {
    display: flex;
    align-items: center;
    gap: 2px;
    width: 100%;
    margin-top: 3px;
}

.dynamic-table th .column-search-input {
    display: block;
    box-sizing: border-box;
    width: 0;
    flex: 1;
    min-width: 0;
    height: 19px;
    margin-top: 0;
    padding: 1px 4px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 3px;
    outline: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font: 11px inherit;
    font-weight: 400;
    cursor: text;
    text-align: center;
}

.dynamic-table th .column-search-reset {
    flex: 0 0 17px;
    width: 17px;
    height: 19px;
    padding: 0;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.dynamic-table th .column-search-reset:hover {
    color: #fff;
}

.dynamic-table th .column-search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.dynamic-table th .column-search-input:focus {
    border-color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.2);
}

.dynamic-table th .header-icons {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dynamic-table th:hover {
    background-color: #003d52;
}

.dynamic-table th i.fa-sort {
    font-size: 0.8rem;
    opacity: 0.7;
}

.dynamic-table td {
    padding: 0 5px;
    border-bottom: 1px solid #d0d0d0;
}

.dynamic-table tbody tr:hover {
    background-color: #f9f9f9;
}

.dynamic-table tbody tr.selected {
    background-color: #005068 !important;
    color: #fff;
}

.dynamic-table tbody tr.selected:hover {
    background-color: #005068 !important;
    color: #fff;
}

.dynamic-table tbody tr.selected td[data-column="CULTURE_UNIT"] a {
    color: #fff !important;
}

.dynamic-table tbody tr.selected .btn-edit-record,
.dynamic-table tbody tr.selected .btn-view-trial,
.dynamic-table tbody tr.selected .fa-search {
    color: #fff !important;
}

.status-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e3eaff;
    color: #005068;
    border: 1px solid #b0c4de;
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 0.97em;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
    margin-right: 2px;
}

.status-filter-btn:hover,
.status-filter-btn.active {
    background: #005068;
    color: #fff;
    border-color: #005068;
}

.context-menu-item:hover {
    background-color: #f5f5f5;
}
.submenu-item:hover {
    background-color: #f5f5f5;
}

.form-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: row;
}

.form-group label {
    display: flex;
    align-items: center;
    margin-right: 50px;
    color: #333;
    font-weight: 500;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #b0c4de;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #005068;
    box-shadow: 0 0 3px rgba(0, 80, 104, 0.3);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.record-modal-fields .form-group {
    display: grid;
    grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
    align-items: center;
    gap: 14px;
    width: 100%;
    margin-bottom: 12px;
}

.record-modal-fields .form-group label {
    min-width: 0;
    margin: 0;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.record-modal-fields .form-group input,
.record-modal-fields .form-group select,
.record-modal-fields .form-group textarea {
    width: 100%;
    min-width: 0;
}

@media (max-width: 560px) {
    .record-modal-fields .form-group {
        grid-template-columns: minmax(0, 1fr);
        gap: 5px;
    }
}

/* ===== ÉDITION INLINE DES CELLULES ===== */
td[data-editable="true"] {
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s ease;
}

td[data-editable="true"]:hover {
    background-color: #e8f1ff !important;
    box-shadow: inset 0 0 3px rgba(0, 80, 104, 0.2);
}

td[data-editable="true"] input {
    box-sizing: border-box;
    font-size: 14px;
    border: 2px solid #005068;
    border-radius: 3px;
    padding: 4px 8px;
}

td[data-editable="true"] input:focus {
    outline: none;
    border-color: #0078d4;
    box-shadow: 0 0 5px rgba(0, 120, 212, 0.5);
}

td[style*="background-color: #fff3cd"] {
    position: relative;
}

td[style*="background-color: #fff3cd"]::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 3px;
    height: 100%;
    background-color: #ff9800;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ===== UNIVERSAL LOADER ===== */
.universal-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(50, 50, 50, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    font-family: "Saira Condensed", sans-serif;
}

.universal-loader.show {
    display: flex;
}

.universal-loader-overlay {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.universal-loader-box {
    background-color: white;
    padding: 40px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.universal-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #114073;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.universal-loader-message {
    margin: 0;
    font-size: 16px;
    color: #333;
    font-weight: bold;
}
