/* ====================================
   ÉTAPES SUR LA MÊME LIGNE
   ==================================== */

.import-steps-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.import-steps-row .import-step {
    flex: 1;
    margin-bottom: 0;
}

@media (max-width: 900px) {
    .import-steps-row {
        flex-direction: column;
    }
}

/* ====================================
   IMPORT DE DONNÉES
   ==================================== */

.import-page {
    padding: 30px;
    /*max-width: 1400px;*/
    margin: 0 auto;
}

.import-page h2 {
    color: #005068;
    font-size: 1.7rem;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ====================================
   ÉTAPES
   ==================================== */

.import-step {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.09);
    margin-bottom: 20px;
    overflow: hidden;
    width: 136%;
}

.step-header {
    background: linear-gradient(135deg, #003d5c 0%, #00546b 100%);
    color: #fff;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.step-number {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step-title {
    font-size: 1.05rem;
    font-weight: 600;
    flex: 1;
}

.preview-subtitle {
    font-size: 0.88rem;
    font-weight: 400;
    opacity: 0.85;
    margin-left: 6px;
}

.step-header-actions {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.step-body {
    padding: 20px 24px;
    /*height: 220px;*/
}

/* ====================================
   FORMULAIRE CONFIGURATION
   ==================================== */

.import-form-row {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.import-form-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    min-width: 220px;
}

.import-form-group label {
    font-weight: 600;
    color: #005068;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.import-select {
    padding: 9px 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: 'Saira Condensed', sans-serif;
    font-size: 0.95rem;
    color: #333;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s;
    min-width: 220px;
}

.import-select:focus {
    outline: none;
    border-color: #005068;
    box-shadow: 0 0 0 3px rgba(0, 80, 104, 0.1);
}

/* ====================================
   RADIOS MODE INSERT / UPDATE
   ==================================== */

.import-mode-group {
    display: flex;
    gap: 12px;
}

.mode-radio {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.mode-radio input[type="radio"] {
    display: none;
}

.mode-radio span {
    padding: 8px 18px;
    border: 2px solid #ccc;
    border-radius: 4px;
    font-family: 'Saira Condensed', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: #555;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.mode-radio input[type="radio"]:checked + span {
    border-color: #005068;
    background: #005068;
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 80, 104, 0.25);
}

.mode-radio:hover span {
    border-color: #005068;
    color: #005068;
}

.mode-radio input[type="radio"]:checked + span:hover {
    color: #fff;
}

/* ====================================
   ZONE DE DÉPÔT FICHIER
   ==================================== */

.import-drop-zone {
    border: 2px dashed #b0c4ce;
    border-radius: 6px;
    padding: 36px 24px;
    text-align: center;
    cursor: pointer;
    background: #f7fbfc;
    transition: border-color 0.2s, background 0.2s;
    color: #666;
}

.import-drop-zone:hover,
.import-drop-zone.drag-over {
    border-color: #005068;
    background: #e8f4f7;
    color: #005068;
}

.import-drop-zone i {
    font-size: 2.4rem;
    color: #005068;
    margin-bottom: 10px;
    display: block;
}

.import-drop-zone p {
    margin: 4px 0;
    font-size: 0.97rem;
}

.file-label {
    color: #005068;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

.file-hint {
    font-size: 0.83rem;
    color: #999;
}

/* ====================================
   FICHIER SÉLECTIONNÉ
   ==================================== */

#file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #eaf6ec;
    border: 1px solid #b7dfc0;
    border-radius: 4px;
    font-size: 0.97rem;
    color: #1d6f42;
    font-weight: 600;
}

#file-info i {
    font-size: 1.4rem;
    color: #1d6f42;
}

.btn-link {
    background: none;
    border: none;
    color: #e53935;
    cursor: pointer;
    font-size: 0.88rem;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: 'Saira Condensed', sans-serif;
    transition: color 0.2s;
}

.btn-link:hover {
    color: #b71c1c;
    text-decoration: underline;
}

/* ====================================
   SÉLECTEUR DE FEUILLE
   ==================================== */

#sheet-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

#sheet-selector label {
    font-weight: 600;
    color: #005068;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

/* ====================================
   TABLEAU D'APERÇU
   ==================================== */

/* ---- Rapport de couverture (avant le tableau) ---- */
.preview-report {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    background: #f0f4f8;
    border-bottom: 1px solid #d0dde6;
}
.preview-report-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 220px;
}
.preview-report-label {
    font-size: 0.78rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.preview-report-label i {
    margin-right: 4px;
    color: #005068;
}
.preview-report-value {
    font-size: 0.97rem;
    font-weight: 600;
}
.preview-report-hint {
    font-size: 0.82rem;
    font-weight: 400;
    color: #888;
}

.preview-table-wrap {
    width: 90%;
    max-height: 520px;
    overflow-x: auto;
    overflow-y: auto;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Saira Condensed', sans-serif;
    font-size: 0.88rem;
    background: #fff;
    white-space: nowrap;
}

.preview-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.preview-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.preview-table td {
    padding: 7px 14px;
    border-bottom: 1px solid #e8e8e8;
    border-right: 1px solid #f0f0f0;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-table tbody tr:hover {
    background: #f5f9fb;
}

/* Colonne présente en BDD — fond vert */
.preview-table th.col-in-db {
    background: #2e7d32;
    color: #fff;
}

/* Colonne absente en BDD — fond orange */
.preview-table th.col-not-in-db {
    background: #e65100;
    color: #fff;
}

.col-check-icon {
    font-size: 0.75rem;
    opacity: 0.85;
    margin-left: 4px;
}

.col-miss-icon {
    font-size: 0.75rem;
    opacity: 0.85;
    margin-left: 4px;
}

/* Ligne déjà présente en BDD — fond vert clair */
.preview-table tbody tr.row-existing {
    background: #e8f5e9;
}

.preview-table tbody tr.row-existing:hover {
    background: #d0edd2;
}

/* ====================================
   LÉGENDE
   ==================================== */

.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.82rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.92);
}

.legend-dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.legend-green {
    background: #2e7d32;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.legend-orange {
    background: #e65100;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.legend-row-existing {
    width: 24px;
    height: 13px;
    background: #e8f5e9;
    border: 1px solid #2e7d32;
    border-radius: 2px;
    display: inline-block;
    flex-shrink: 0;
}

/* ====================================
   BOUTON IMPORT + LOADER
   ==================================== */

#import-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
}

.btn-import {
    padding: 11px 28px;
    background: linear-gradient(135deg, #003d5c 0%, #00546b 100%);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-family: 'Saira Condensed', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 6px rgba(0, 80, 104, 0.3);
    letter-spacing: 0.02em;
    margin-bottom: 10px;
}

.btn-import:hover:not(:disabled) {
    opacity: 0.88;
    box-shadow: 0 4px 12px rgba(0, 80, 104, 0.4);
}

.btn-import:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

#import-loader {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #005068;
    font-weight: 600;
    font-size: 0.97rem;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ====================================
   POPUP RÉSULTATS / ERREURS
   ==================================== */

.import-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    animation: fadeIn 0.15s ease;
}

.import-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
    z-index: 1001;
    min-width: 380px;
    max-width: 680px;
    width: 90%;
    animation: slideIn 0.18s ease;
    overflow: hidden;
}

@keyframes slideIn {
    from { opacity: 0; transform: translate(-50%, -54%); }
    to   { opacity: 1; transform: translate(-50%, -50%); }
}

.import-popup-header {
    background: linear-gradient(135deg, #003d5c 0%, #00546b 100%);
    color: #fff;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 1rem;
}

.import-popup-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}

.import-popup-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.import-popup-body {
    padding: 20px 24px;
    max-height: 55vh;
    overflow-y: auto;
    font-size: 0.97rem;
    color: #333;
}

.import-popup-footer {
    padding: 14px 24px;
    border-top: 1px solid #e8e8e8;
    display: flex;
    justify-content: flex-end;
}

/* Résultats dans la popup */
.import-result-ok {
    color: #2e7d32;
    font-weight: 600;
    margin: 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05rem;
}

.import-result-skip {
    color: #1565c0;
    font-weight: 600;
    margin: 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
}

.import-result-warn {
    color: #e65100;
    font-weight: 600;
    margin: 12px 0 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.import-error-list {
    margin: 0;
    padding-left: 20px;
    font-size: 0.9rem;
    color: #555;
}

.import-error-list li {
    margin-bottom: 4px;
    line-height: 1.5;
}

/* ====================================
   CHECKBOX PERSONNALISÉ
   ==================================== */

.import-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin-right: 6px;
    accent-color: #005068;
}

/* ====================================
   BOUTON SECONDAIRE
   ==================================== */

.btn-secondary {
    padding: 11px 28px;
    background: #f5f5f5;
    color: #333;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-family: 'Saira Condensed', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #e8e8e8;
    border-color: #999;
}

/* ====================================
   STATUS DES LIGNES
   ==================================== */

.preview-table tbody tr.row-unchanged {
    background: #f5f5f5;
}

.preview-table tbody tr.row-error {
    background: #ffebee;
}

/* ====================================
   RÉSUMÉ RAPPORT
   ==================================== */

.preview-report {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    background: #f0f4f8;
    border-bottom: 1px solid #d0dde6;
    margin-bottom: 12px;
}

.preview-report-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 180px;
}

.preview-report-label {
    font-size: 0.78rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.preview-report-label i {
    margin-right: 4px;
    color: #005068;
}

.preview-report-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #005068;
}

.import-result-info {
    color: #1976d2;
    font-weight: 600;
    margin: 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
}

/* ====================================
   RESPONSIVE
   ==================================== */

@media (max-width: 768px) {
    .import-page {
        padding: 16px;
    }

    .import-form-row {
        flex-direction: column;
        gap: 16px;
    }

    .import-mode-group {
        flex-wrap: wrap;
    }

    .step-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .step-header-actions {
        gap: 10px;
    }

    .import-popup {
        min-width: 0;
        width: 95%;
    }

}

/* ====================================
   CONTROL BOXES (GENOTYPE & TRIAL)
   ==================================== */
.import-controls-row {
    display: flex;
    gap: 20px;
    align-items: stretch;
    margin-top: 20px;
    margin-bottom: 20px;
}

.import-controls-row .import-step {
    flex: 1;
    width: 100%;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
}

.import-controls-row .step-header {
    padding: 7px 14px;
    gap: 10px;
}

.import-controls-row .step-title {
    font-size: 0.95rem;
}

.import-controls-row .step-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 8px 10px;
}

.control-actions-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.btn-control-verify {
    padding: 5px 12px;
    background: linear-gradient(135deg, #003d5c 0%, #00546b 100%);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-family: 'Saira Condensed', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.2s, box-shadow 0.2s;
}

.btn-control-verify:hover:not(:disabled) {
    opacity: 0.9;
    box-shadow: 0 2px 8px rgba(0, 80, 104, 0.35);
}

.btn-control-verify:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-control-export {
    padding: 5px 12px;
    background: #fff;
    color: #2e7d32;
    border: 1px solid #2e7d32;
    border-radius: 4px;
    font-family: 'Saira Condensed', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-control-export:hover:not(:disabled) {
    background: #2e7d32;
    color: #fff;
}

.btn-control-export:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #fff;
    color: #888;
    border-color: #ccc;
}

.control-message {
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-message-ok {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.control-message-warn {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.control-list-box {
    max-height: 110px;
    overflow-y: auto;
    border: 1px solid #d0dde6;
    border-radius: 4px;
    background: #fff;
}

.control-code-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 3px 10px;
    font-size: 0.82rem;
    line-height: 1.55;
    border-bottom: 1px solid #eef2f5;
}

.control-code-item:nth-child(even) {
    background: #f7fafc;
}

.control-code-item:last-child {
    border-bottom: none;
}

.control-code-value {
    font-family: Consolas, 'Courier New', monospace;
    font-weight: 600;
    color: #003d5c;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.control-code-item.is-missing {
    background: linear-gradient(135deg, #c62828 0%, #e53935 100%);
    border-bottom-color: #b71c1c;
}

.control-code-item.is-missing .control-code-value {
    color: #fff;
}

.control-code-item.is-missing .control-badge-missing {
    color: #fff;
    background: rgba(0, 0, 0, 0.22);
}

.control-code-item.is-ok .control-code-value {
    color: #1b5e20;
}

.control-badge-missing {
    color: #c62828;
    background: rgba(198, 40, 40, 0.1);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.control-badge-ok {
    color: #2e7d32;
    opacity: 0.7;
    font-size: 0.72rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

@media (max-width: 900px) {
    .import-controls-row {
        flex-direction: column;
    }

    .control-list-box {
        max-height: 90px;
    }
}
