/* ============================================================ */
/* TABLE TRANSFORMER PRO - STYLE ACCESSIBLE (RGAA / WCAG 2.1 AA) */
/* ============================================================ */

/* Container principal */
#table-transformer-container {
    max-width: 1000px;
    margin: 20px 0;
    padding: 20px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1a1a2e;
}

/* ============================================================ */
/* HEADER - Accessible                                           */
/* ============================================================ */

.tt-header {
    padding: 16px 20px;
    background: #f8fafc;
    border-radius: 8px 8px 0 0;
    border-bottom: 2px solid #e2e8f0;
    margin: -20px -20px 16px -20px;
    padding: 1.25rem 2rem;
}

.tt-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0 0 4px 0;
}

.tt-header p {
    font-size: 1rem;
    color: #475569;
    margin: 0 0 12px 0;
}

.tt-stats-bar {
    background: #ffffff;
    padding: 10px 16px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 0.9rem;
    color: #475569;
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    margin: 0;
}

.tt-stats-bar span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.tt-stats-bar strong {
    color: #1a1a2e;
    font-weight: 600;
}

/* ============================================================ */
/* ÉTAPES                                                       */
/* ============================================================ */

.tt-step {
    margin-bottom: 20px;
    padding: 16px 18px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #d1d5db;
}

.tt-step-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.tt-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #4f46e5;
    color: #ffffff;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.tt-step-header h4 {
    margin: 0;
    font-size: 1rem;
    color: #1a1a2e;
    font-weight: 600;
}

/* ============================================================ */
/* BOUTONS - Accessibles (WCAG 2.1 AA)                          */
/* ============================================================ */

.tt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px;
    border: 2px solid transparent;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    text-decoration: none;
    line-height: 1.2;
}

.tt-btn:focus-visible {
    outline: 3px solid #4f46e5;
    outline-offset: 3px;
}

.tt-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Primary */
.tt-btn-primary {
    background: #4f46e5;
    color: #ffffff;
    border-color: #4f46e5;
}

.tt-btn-primary:hover {
    background: #4338ca;
    border-color: #4338ca;
}

/* Success */
.tt-btn-success {
    background: #16a34a;
    color: #ffffff;
    border-color: #16a34a;
}

.tt-btn-success:hover {
    background: #15803d;
    border-color: #15803d;
}

/* Secondary */
.tt-btn-secondary {
    background: #f1f5f9;
    color: #1a1a2e;
    border-color: #64748b;
}

.tt-btn-secondary:hover {
    background: #e2e8f0;
    border-color: #475569;
}

/* Danger */
.tt-btn-danger {
    background: #fee2e2;
    color: #991b1b;
    border-color: #991b1b;
}

.tt-btn-danger:hover {
    background: #fecaca;
}

/* Small */
.tt-btn-sm {
    padding: 4px 16px;
    font-size: 0.85rem;
    min-height: 34px;
}

/* ============================================================ */
/* TABLEAU PREVIEW - Accessible                                 */
/* ============================================================ */

.tt-table-preview {
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    max-height: 400px;
    overflow: auto;
    margin-top: 8px;
}

.tt-table-preview .tt-placeholder {
    color: #94a3b8;
    text-align: center;
    padding: 20px;
    margin: 0;
    font-style: italic;
}

.tt-table-preview table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.tt-table-preview table th,
.tt-table-preview table td {
    border: 1px solid #d1d5db;
    padding: 8px 12px;
    text-align: left;
}

.tt-table-preview table th {
    background: #f1f5f9;
    font-weight: 600;
}

.tt-table-preview table caption {
    font-weight: 600;
    margin-bottom: 6px;
    text-align: left;
}

/* ============================================================ */
/* FORMATS GRID - Accessible                                    */
/* ============================================================ */

.tt-formats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.tt-format-card {
    background: #ffffff;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tt-format-card:hover {
    border-color: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.tt-format-card:focus-visible {
    outline: 3px solid #4f46e5;
    outline-offset: 2px;
}

.tt-format-card.selected {
    border-color: #4f46e5;
    background: #eef2ff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.tt-format-card .tt-format-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.tt-format-card .tt-format-name {
    font-weight: 600;
    color: #1a1a2e;
    font-size: 0.95rem;
}

.tt-format-card .tt-format-desc {
    font-size: 0.85rem;
    color: #475569;
    margin: 4px 0 10px 0;
}

/* ============================================================ */
/* RÉSULTAT - Accessible                                        */
/* ============================================================ */

.tt-result-container {
    margin-top: 8px;
}

.tt-result-content {
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    max-height: 400px;
    overflow: auto;
    font-size: 0.95rem;
    line-height: 1.7;
}

.tt-result-content .tt-loading {
    color: #4f46e5;
    text-align: center;
    padding: 20px;
}

.tt-result-content pre {
    background: #f1f5f9;
    padding: 10px 14px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
}

.tt-result-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.tt-result-content table th,
.tt-result-content table td {
    border: 1px solid #d1d5db;
    padding: 8px 12px;
    text-align: left;
}

.tt-result-content table th {
    background: #f1f5f9;
    font-weight: 600;
}

.tt-result-content table caption {
    font-weight: 600;
    margin-bottom: 6px;
    text-align: left;
}

/* ============================================================ */
/* ACTIONS - Accessible                                         */
/* ============================================================ */

.tt-result-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.tt-format-label {
    font-size: 0.85rem;
    color: #475569;
    background: #f1f5f9;
    padding: 4px 12px;
    border-radius: 4px;
    margin-left: auto;
}

/* ============================================================ */
/* DEBUG - Accessible (admin only)                              */
/* ============================================================ */

.tt-debug {
    margin-top: 12px;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 0.85rem;
    font-family: monospace;
    max-height: 150px;
    overflow-y: auto;
}

.tt-debug strong {
    color: #475569;
    font-weight: 700;
}

.tt-debug .debug-line .time {
    color: #64748b;
    margin-right: 8px;
}

.tt-debug .debug-line .success {
    color: #16a34a;
}

.tt-debug .debug-line .error {
    color: #991b1b;
}

.tt-debug .debug-line .warning {
    color: #b45309;
}

.tt-debug .debug-line .info {
    color: #475569;
}

/* ============================================================ */
/* FOCUS VISIBLE - Accessible                                   */
/* ============================================================ */

*:focus-visible {
    outline: 3px solid #4f46e5;
    outline-offset: 2px;
}

/* ============================================================ */
/* SCROLLBAR - Accessible                                       */
/* ============================================================ */

.tt-table-preview::-webkit-scrollbar,
.tt-result-content::-webkit-scrollbar,
.tt-debug::-webkit-scrollbar {
    width: 8px;
}

.tt-table-preview::-webkit-scrollbar-track,
.tt-result-content::-webkit-scrollbar-track,
.tt-debug::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.tt-table-preview::-webkit-scrollbar-thumb,
.tt-result-content::-webkit-scrollbar-thumb,
.tt-debug::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 4px;
}

.tt-table-preview::-webkit-scrollbar-thumb:hover,
.tt-result-content::-webkit-scrollbar-thumb:hover,
.tt-debug::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}
/* ============================================================ */
/* ONGLETS - Accessible                                          */
/* ============================================================ */

.tt-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    padding: 4px;
    background: #f1f5f9;
    border-radius: 8px;
    border: 1px solid #d1d5db;
}

.tt-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #475569;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.tt-tab:hover {
    background: rgba(79, 70, 229, 0.08);
    color: #1a1a2e;
}

.tt-tab:focus-visible {
    outline: 3px solid #4f46e5;
    outline-offset: 2px;
}

.tt-tab-active {
    background: #ffffff;
    color: #1a1a2e;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ============================================================ */
/* ZONE DE DESCRIPTION - Accessible                              */
/* ============================================================ */

.tt-desc-area {
    padding: 12px 0;
}

.tt-desc-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #64748b;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    color: #1a1a2e;
    background: #ffffff;
}

.tt-desc-textarea:focus {
    border-color: #4f46e5;
    outline: 3px solid rgba(79, 70, 229, 0.3);
    outline-offset: 2px;
}

.tt-desc-textarea::placeholder {
    color: #94a3b8;
}

/* ============================================================ */
/* PANNEAUX                                                     */
/* ============================================================ */

.tt-panel {
    display: block;
}

.tt-panel-active {
    display: block;
}

.tt-panel[style*="display:none"] {
    display: none !important;
}
/* ============================================================ */
/* RESPONSIVE - Accessible                                      */
/* ============================================================ */

@media (max-width: 768px) {
    #table-transformer-container {
        padding: 12px;
    }
    
    .tt-header {
        margin: -12px -12px 12px -12px;
        padding: 1rem 1.25rem;
    }
    
    .tt-stats-bar {
        flex-direction: column;
        gap: 6px;
    }
    
    .tt-formats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .tt-result-actions {
        flex-direction: column;
    }
    
    .tt-result-actions .tt-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    #table-transformer-container {
        padding: 10px;
    }
    
    .tt-header {
        margin: -10px -10px 10px -10px;
        padding: 0.75rem 1rem;
    }
    
    .tt-header h3 {
        font-size: 1.1rem;
    }
    
    .tt-formats-grid {
        grid-template-columns: 1fr;
    }
    
    .tt-step {
        padding: 12px 14px;
    }
    
    .tt-step-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .tt-format-label {
        margin-left: 0;
        width: 100%;
    }
}

/* ============================================================ */
/* IMPRESSION - Accessible                                      */
/* ============================================================ */

@media print {
    #table-transformer-container {
        border: 1px solid #000;
        background: #fff;
    }
    
    .tt-btn {
        border: 1px solid #000;
        background: #fff !important;
        color: #000 !important;
    }
    
    .tt-debug {
        display: none !important;
    }
}

/* ============================================================ */
/* RÉDUCTION DE MOUVEMENT - Accessible                          */
/* ============================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================ */
/* CONTRAST ÉLEVÉ - Accessible                                  */
/* ============================================================ */

@media (prefers-contrast: high) {
    #table-transformer-container {
        border-width: 2px;
        border-color: #000;
    }
    
    .tt-btn {
        border-width: 2px;
    }
    
    .tt-btn-primary {
        background: #000;
        color: #fff;
        border-color: #000;
    }
    
    .tt-btn-secondary {
        background: #fff;
        color: #000;
        border-color: #000;
    }
    
    .tt-format-card {
        border-width: 2px;
        border-color: #000;
    }
    
    .tt-format-card.selected {
        border-color: #000;
        background: #eef2ff;
    }
}