/**
 * STLpricer - Styles
 * Layout responsive, couleurs axes RGB, bibliothèque STL
 */

/* === VARIABLES === */
:root {
    --stl-axis-x: #ff4444;
    --stl-axis-y: #44ff44;
    --stl-axis-z: #4488ff;
    --stl-bg-dark: #1a1a2e;
    --stl-primary: #007bff;
    --stl-success: #28a745;
    --stl-warning: #ffc107;
    --stl-danger: #dc3545;
}

/* === LAYOUT PRINCIPAL === */
.stl-main-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    margin-top: 1rem;
}

@media (max-width: 900px) {
    .stl-main-grid {
        grid-template-columns: 1fr;
    }
}

/* === HEADER UPLOAD === */
.stl-header-row {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch; /* Étirer tous les enfants */
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    min-height: 120px; /* Hauteur minimale pour centrage */
}

/* Colonne gauche : boutons d'import empilés */
.stl-import-column {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 280px;
}

.stl-file-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 2px dashed #ccc;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stl-file-label:hover {
    border-color: var(--stl-primary);
    background: #f0f7ff;
}

.stl-file-label.pulse {
    animation: labelPulse 2s ease-in-out infinite;
}

@keyframes labelPulse {
    0%, 100% { 
        border-color: #ccc;
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.4);
    }
    50% { 
        border-color: var(--stl-primary);
        box-shadow: 0 0 0 8px rgba(0, 123, 255, 0);
    }
}

.stl-file-label input[type="file"] {
    display: none;
}

.stl-file-label .material-icons {
    font-size: 24px;
    color: var(--stl-primary);
}

/* Bouton bibliothèque */
.stl-library-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #495057;
    transition: all 0.2s ease;
}

.stl-library-btn:hover {
    border-color: var(--stl-primary);
    color: var(--stl-primary);
    background: #f0f7ff;
}

.stl-library-btn.pulse {
    animation: labelPulse 2s ease-in-out infinite;
    border-style: dashed;
}

.stl-library-btn .material-icons {
    font-size: 20px;
}

.stl-library-btn .chevron {
    margin-left: auto;
    transition: transform 0.3s ease;
}

.stl-library-btn.open .chevron {
    transform: rotate(180deg);
}

/* Colonne action - centrée verticalement */
.stl-action-column {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

/* Bouton Calculer prix - même taille que le captcha */
.stl-action-column .btn-upload {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    width: 304px;  /* Largeur du captcha Google */
    height: 78px;  /* Hauteur du captcha Google */
    white-space: nowrap;
}

/* Bouton Annuler - même taille */
.stl-action-column .stl-cancel {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    width: 304px;
}

/* === BIBLIOTHÈQUE STL === */
.stl-library-section {
    margin: 0 0 1rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    animation: slideDown 0.3s ease-out;
    overflow: visible; /* Permettre aux tooltips de dépasser */
}

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

/* Header de la bibliothèque avec recherche */
.stl-library-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.stl-library-search {
    flex: 1;
    padding: 0.5rem 1rem;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.stl-library-search:focus {
    border-color: var(--stl-primary);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.stl-library-search::placeholder {
    color: #adb5bd;
}

.stl-library-count {
    font-size: 0.85rem;
    color: #6c757d;
    white-space: nowrap;
}

/* Ancien titre - masqué (remplacé par le bouton toggle) */
.stl-library-title {
    display: none;
}

/* Grille avec scrollbar */
.stl-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    max-height: 280px;
    overflow-y: auto;
    overflow-x: visible;
    padding-right: 0.5rem;
    padding-bottom: 80px; /* Espace pour les tooltips en bas */
}

/* Scrollbar stylisée */
.stl-library-grid::-webkit-scrollbar {
    width: 6px;
}

.stl-library-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.stl-library-grid::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.stl-library-grid::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Message aucun résultat */
.stl-library-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: #6c757d;
    font-style: italic;
}

/* Suppression de l'ancien comportement open/close */
.stl-library-grid.open {
    display: grid;
}

.stl-library-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    background: #fff;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.stl-library-item:hover {
    border-color: var(--stl-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stl-library-item.selected {
    border-color: var(--stl-success);
    background: #e8f5e9;
}

.stl-library-preview {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 4px;
}

.stl-library-placeholder {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e9ecef;
    border-radius: 4px;
}

.stl-library-placeholder .material-icons {
    font-size: 32px;
    color: #adb5bd;
}

.stl-library-name {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    text-align: center;
    color: #495057;
    word-break: break-word;
    max-width: 100%;
}

/* Infobulle crédits Creative Commons */
.stl-library-item {
    position: relative;
}

.stl-library-credits {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(0, 123, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    transition: transform 0.2s;
    z-index: 10;
}

.stl-library-credits .material-icons {
    font-size: 14px;
    color: #fff;
}

.stl-library-credits:hover {
    transform: scale(1.2);
}

/* Tooltip global (ajouté au body via JS) */
.stl-tooltip {
    position: fixed;
    background: #222;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    max-width: 320px;
    width: max-content;
    z-index: 100000;
    pointer-events: none;
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    word-wrap: break-word;
    text-align: left;
}

.stl-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Flèche du tooltip - positionnée dynamiquement */
.stl-tooltip::before {
    content: '';
    position: absolute;
    border: 8px solid transparent;
}

.stl-tooltip.arrow-top::before {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-color: #222;
}

.stl-tooltip.arrow-bottom::before {
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-top-color: #222;
}

.stl-tooltip.arrow-left::before {
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-right-color: #222;
}

.stl-tooltip.arrow-right::before {
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-left-color: #222;
}

/* Mobile : tooltip plus grand et mieux positionné */
@media (max-width: 768px) {
    .stl-tooltip {
        max-width: calc(100vw - 40px);
        font-size: 14px;
        padding: 12px 16px;
    }
    
    /* Sur mobile, l'icône reste visible mais le tap affiche le tooltip */
    .stl-library-credits {
        width: 24px;
        height: 24px;
    }
    
    .stl-library-credits .material-icons {
        font-size: 16px;
    }
}

/* === VIEWER === */
.stl-viewer-block {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stl-viewer {
    background: var(--stl-bg-dark);
    min-height: 420px;
    border-radius: 8px;
    overflow: hidden;
}

.stl-viewer canvas {
    display: block;
    width: 100% !important;
    height: 420px !important;
}

/* === CONTRÔLES ROTATION/TRANSLATION === */
.stl-rt-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.stl-rot-block,
.stl-trans-block {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.block-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
    text-align: center;
}

/* Grille rotation */
.rot-grid {
    display: grid;
    grid-template-columns: 30px auto;
    gap: 0.5rem 0.25rem;
    align-items: center;
}

.rot-grid .axis {
    font-weight: bold;
    font-size: 0.9rem;
    text-align: center;
    padding: 4px;
    border-radius: 4px;
    color: #fff;
}

.rot-grid .axis-x { background: var(--stl-axis-x); }
.rot-grid .axis-y { background: var(--stl-axis-y); color: #000; }
.rot-grid .axis-z { background: var(--stl-axis-z); }

.rot-grid .btns {
    display: flex;
    gap: 0.25rem;
}

/* Grille translation (joystick) - TAILLES FIXES */
.joy-grid {
    display: grid;
    grid-template-columns: 36px 36px 36px;
    grid-template-rows: 36px 36px 36px;
    gap: 4px;
    justify-content: center;
    width: fit-content;
    margin: 0 auto;
}

/* Boutons contrôle - tailles fixes */
.stl-ctl {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    max-width: 36px !important;
    max-height: 36px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    border-radius: 6px;
    border: 2px solid #dee2e6;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
}

/* ========================================
   RESPONSIVE ROTATION/TRANSLATION
   ======================================== */

@media (max-width: 768px) {
    .stl-rt-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    
    .stl-rot-block,
    .stl-trans-block {
        padding: 6px;
        min-width: 0;
        overflow: visible;
    }
    
    .block-title {
        font-size: 10px;
        margin-bottom: 4px;
    }
    
    /* Rotation : grille compacte et centrée */
    .rot-grid {
        grid-template-columns: 20px auto;
        gap: 2px;
        width: fit-content;
        margin: 0 auto;
    }
    
    .rot-grid .axis {
        font-size: 9px;
        padding: 2px 3px;
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .rot-grid .btns {
        gap: 2px;
    }
    
    /* Boutons plus petits sur mobile - TAILLES FIXES */
    .stl-ctl {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
        max-width: 28px !important;
        max-height: 28px !important;
        font-size: 0.8rem;
        border-radius: 4px;
    }
    
    /* Translation : grille compacte - TAILLES FIXES */
    .joy-grid {
        grid-template-columns: 28px 28px 28px;
        grid-template-rows: 28px 28px 28px;
        gap: 2px;
        width: fit-content;
        margin: 0 auto;
    }
    
    /* Scale block sur toute la largeur */
    .stl-scale-block {
        grid-column: 1 / -1;
        margin-top: 6px;
        padding: 6px;
    }
    
    .stl-scale-block .block-title {
        font-size: 11px;
        margin-bottom: 6px;
    }
    
    .scale-hint {
        font-size: 10px;
        margin-top: 4px;
    }
}

.joy-center {
    background: #dee2e6;
    border-radius: 50%;
}

.joy-center:hover:not(:disabled) {
    background: #4488ff;
    color: #fff;
    border-color: #4488ff;
}

/* Boutons contrôle - défini plus haut avec !important */

.stl-ctl:hover:not(:disabled) {
    transform: scale(1.1);
}

.stl-ctl:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Couleurs axes sur boutons */
.stl-ctl.axis-x-btn {
    border-color: var(--stl-axis-x);
    color: var(--stl-axis-x);
}
.stl-ctl.axis-x-btn:hover:not(:disabled) {
    background: var(--stl-axis-x);
    color: #fff;
}

.stl-ctl.axis-y-btn {
    border-color: var(--stl-axis-y);
    color: #2a8a2a;
}
.stl-ctl.axis-y-btn:hover:not(:disabled) {
    background: var(--stl-axis-y);
    color: #000;
}

.stl-ctl.axis-z-btn {
    border-color: var(--stl-axis-z);
    color: var(--stl-axis-z);
}
.stl-ctl.axis-z-btn:hover:not(:disabled) {
    background: var(--stl-axis-z);
    color: #fff;
}

/* === WARNING === */
.stl-warn-slot {
    min-height: 40px;
}

.stl-bed-warn {
    background: #fff3cd;
    border: 1px solid var(--stl-warning);
    color: #856404;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

/* === FORMULAIRE === */
.stl-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stl-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Ordre des éléments via grid pour garder le bon ordre visuel */
.stl-form-grid .form-group:nth-child(1) { order: 1; } /* Matériau - col 1 */
.stl-form-grid .form-group:nth-child(2) { order: 4; } /* Qualité - col 2 */
.stl-form-grid .form-group:nth-child(3) { order: 2; } /* Couleur - col 1 */
.stl-form-grid .form-group:nth-child(4) { order: 5; } /* Infill - col 2 */
.stl-form-grid .form-group:nth-child(5) { order: 3; } /* Quantité - col 1 */
.stl-form-grid .form-group:nth-child(6) { order: 6; } /* Murs - col 2 */

.stl-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stl-form label {
    font-weight: 500;
    font-size: 0.9rem;
    color: #495057;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.stl-form select,
.stl-form input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 0.95rem;
    width: 100%;
    box-sizing: border-box;
}

.stl-form select:focus,
.stl-form input:focus {
    border-color: var(--stl-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.15);
}

/* ========================================
   RESPONSIVE FORMULAIRE
   ======================================== */

@media (max-width: 600px) {
    .stl-form-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    /* Sur mobile, remettre l'ordre naturel */
    .stl-form-grid .form-group:nth-child(1) { order: 1; } /* Matériau */
    .stl-form-grid .form-group:nth-child(2) { order: 4; } /* Qualité */
    .stl-form-grid .form-group:nth-child(3) { order: 2; } /* Couleur */
    .stl-form-grid .form-group:nth-child(4) { order: 5; } /* Infill */
    .stl-form-grid .form-group:nth-child(5) { order: 3; } /* Quantité */
    .stl-form-grid .form-group:nth-child(6) { order: 6; } /* Murs */
    
    /* Layout inline : label + select sur même ligne */
    .stl-form .form-group {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }
    
    .stl-form label {
        flex: 0 0 auto;
        min-width: 90px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    .stl-form select,
    .stl-form input[type="number"] {
        flex: 1;
        min-width: 0;
        padding: 8px 10px;
        font-size: 14px;
    }
    
    /* Quantité input plus petit */
    .stl-form input[type="number"] {
        max-width: 80px;
    }
}

.info-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 11px;
    font-weight: 600;
    background: #333;
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    margin-left: 4px;
    vertical-align: middle;
    transition: transform 0.2s, background 0.2s;
    user-select: none;
}

.info-circle::before {
    content: '?';
}

.info-circle:hover {
    background: #000;
    transform: scale(1.15);
}

.info-circle:active {
    transform: scale(0.95);
}

/* === MÉTRIQUES === */
.stl-metrics-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.stl-metrics-row .metric {
    flex: 1;
    min-width: 100px;
    text-align: center;
}

.stl-metrics-row .metric label {
    display: block;
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.stl-metrics-row .metric .out {
    font-size: 1.25rem;
    font-weight: 600;
    color: #212529;
}

.stl-metrics-row .metric small {
    font-size: 0.8rem;
    color: #6c757d;
}

.stl-metrics-row .metric.total {
    background: #e8f5e9;
    padding: 0.75rem;
    border-radius: 6px;
}

.stl-metrics-row .metric.total .out {
    color: var(--stl-success);
}

/* === BOUTONS === */
.btn-upload,
.btn-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-upload {
    background: var(--stl-primary);
    color: #fff;
}

.btn-upload:hover {
    background: #0056b3;
}

.btn-add {
    width: 100%;
    background: var(--stl-success);
    color: #fff;
}

.btn-add:hover:not(:disabled) {
    background: #1e7e34;
}

.btn-add:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.btn-upload .material-icons,
.btn-add .material-icons {
    font-size: 20px;
}

.stl-actions {
    margin-top: 0.5rem;
}

/* === TOAST === */
.stl-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    z-index: 9999;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.stl-toast.ok {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.stl-toast.err {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* === PROGRESS === */
.stl-progress {
    position: relative;
    height: 28px;
    background: #e9ecef;
    border-radius: 6px;
    overflow: hidden;
    margin: 1rem 0;
}

.stl-progress .bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--stl-primary), #00c6ff);
    transition: width 0.3s;
}

.stl-progress .label {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 500;
    color: #212529;
}

/* === QUALITY INFO === */
.stl-quality-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.quality-score {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.quality-score .score-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.quality-score .score-grade {
    font-size: 1rem;
    font-weight: 500;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    background: #e9ecef;
}

.quality-score.grade-a .score-value,
.quality-score.grade-a .score-grade { color: var(--stl-success); }
.quality-score.grade-a .score-grade { background: #d4edda; }

.quality-score.grade-b .score-value,
.quality-score.grade-b .score-grade { color: #17a2b8; }
.quality-score.grade-b .score-grade { background: #d1ecf1; }

.quality-score.grade-c .score-value,
.quality-score.grade-c .score-grade { color: #856404; }
.quality-score.grade-c .score-grade { background: #fff3cd; }

.quality-score.grade-d .score-value,
.quality-score.grade-d .score-grade,
.quality-score.grade-f .score-value,
.quality-score.grade-f .score-grade { color: var(--stl-danger); }
.quality-score.grade-d .score-grade,
.quality-score.grade-f .score-grade { background: #f8d7da; }

.quality-detail {
    font-size: 0.85rem;
    color: #495057;
    margin-bottom: 0.25rem;
}

.quality-warning {
    font-size: 0.85rem;
    color: #856404;
    background: #fff3cd;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    margin-top: 0.5rem;
}

.quality-explain {
    font-size: 0.85rem;
    color: #495057;
    font-style: italic;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #6c757d;
}

/* === HELP BLOCK === */
.stl-help-block {
    grid-column: 1 / -1;
    background: #e7f3ff;
    border: 1px solid #b6d4fe;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #084298;
}

/* === NOTE === */
.form-row.note {
    color: #6c757d;
    font-size: 0.85rem;
}

.form-row.note .material-icons {
    color: #adb5bd;
}

/* === RESPONSIVE === */
@media (max-width: 600px) {
    .stl-header-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    /* .stl-rt-grid reste en 2 colonnes sur mobile - géré dans la section RESPONSIVE ROTATION/TRANSLATION */
    
    .stl-metrics-row {
        flex-direction: column;
    }
    
    .stl-toast {
        left: 10px;
        right: 10px;
        max-width: none;
    }
    
    .stl-library-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
}

/* ========================================
   AUTO-ORIENTATION BUTTON
   ======================================== */

.stl-auto-orient-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: #fff !important;
    border: none !important;
    font-size: 16px !important;
    transition: all 0.2s ease;
}

.stl-auto-orient-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%) !important;
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.stl-auto-orient-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.stl-auto-orient-btn:disabled {
    background: #e0e0e0 !important;
    color: #999 !important;
    cursor: not-allowed;
}

/* Animation pendant le traitement */
.stl-auto-orient-btn.processing {
    pointer-events: none;
    animation: autoOrientPulse 1s ease-in-out infinite;
}

@keyframes autoOrientPulse {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1);
    }
    50% { 
        opacity: 0.6; 
        transform: scale(0.98);
    }
}

/* Tooltip personnalisé */
.stl-auto-orient-btn::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    margin-bottom: 4px;
}

.stl-auto-orient-btn:hover::after {
    opacity: 1;
}

/* ========================================
   LOADING STATE - Blocage interactions
   ======================================== */

/* Formulaire en chargement */
.stl-loading {
    position: relative;
}

.stl-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    pointer-events: none;
    z-index: 10;
}

/* Zone de drop désactivée */
.stl-drop-zone.loading {
    opacity: 0.6;
    pointer-events: none;
    cursor: not-allowed;
}

.stl-drop-zone.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(0, 0, 0, 0.03) 10px,
        rgba(0, 0, 0, 0.03) 20px
    );
    animation: loadingStripes 1s linear infinite;
}

@keyframes loadingStripes {
    0% { background-position: 0 0; }
    100% { background-position: 28px 0; }
}

/* Bibliothèque en chargement */
.stl-library.loading {
    opacity: 0.6;
    pointer-events: none;
}

.stl-library-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(50%);
}

.stl-library-item.disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Toast info (pour conversion d'unités) */
.stl-toast.info {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: #fff;
}

/* Animation de chargement sur les items */
.stl-library-item.selected.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 5;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   WORKFLOW STEPS
   ======================================== */

.workflow-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 15px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    flex-wrap: wrap;
}

.workflow-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    background: #fff;
    border: 2px solid #dee2e6;
    transition: all 0.3s ease;
    opacity: 0.5;
    cursor: default;
    user-select: none;
}

.workflow-step .step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #dee2e6;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
    transition: all 0.3s ease;
}

.workflow-step .step-label {
    font-size: 13px;
    color: #6c757d;
    white-space: nowrap;
}

.workflow-connector {
    width: 30px;
    height: 2px;
    background: #dee2e6;
    transition: background 0.3s ease;
}

/* États des étapes */
.workflow-step.pending {
    opacity: 0.5;
}

/* Curseur cliquable uniquement pour l'étape active */
.workflow-step.active {
    opacity: 1;
    border-color: #007bff;
    background: #e7f1ff;
    cursor: pointer;
}

.workflow-step.active:hover {
    background: #d0e3ff;
    border-color: #0056b3;
}

.workflow-step.active .step-number {
    background: #007bff;
    color: #fff;
}

.workflow-step.active .step-label {
    color: #007bff;
    font-weight: 600;
}

.workflow-step.completed {
    opacity: 1;
    border-color: #28a745;
    background: #d4edda;
}

.workflow-step.completed .step-number {
    background: #28a745;
    color: #fff;
}

.workflow-step.completed .step-number::after {
    content: '✓';
    font-size: 14px;
}

.workflow-step.completed .step-label {
    color: #28a745;
}

/* Animation pulse pour l'étape active */
.workflow-step.pulse {
    animation: stepPulse 2s ease-in-out infinite;
}

@keyframes stepPulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.4);
    }
    50% { 
        box-shadow: 0 0 0 8px rgba(0, 123, 255, 0);
    }
}

/* Connecteur actif */
.workflow-step.completed + .workflow-connector {
    background: #28a745;
}

/* ========================================
   BOUTON ANNULER
   ======================================== */

.stl-cancel {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    border: none;
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stl-cancel:hover {
    background: linear-gradient(135deg, #c82333 0%, #bd2130 100%);
    transform: scale(1.02);
}

.stl-cancel::before {
    content: '✕';
    font-size: 14px;
}

/* ========================================
   SLIDER SCALE
   ======================================== */

.stl-scale-block {
    margin-top: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.stl-scale-block .block-title {
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.scale-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stl-scale-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #dee2e6;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.stl-scale-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.stl-scale-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.stl-scale-slider:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.stl-scale-slider:disabled::-webkit-slider-thumb {
    background: #adb5bd;
}

.scale-value {
    min-width: 50px;
    text-align: center;
    font-weight: 600;
    color: #007bff;
    font-size: 14px;
}

.scale-hint {
    font-size: 11px;
    color: #6c757d;
    margin-top: 6px;
    text-align: center;
}

#stl-scale-reset {
    padding: 4px 8px;
    font-size: 14px;
    line-height: 1;
}

/* ========================================
   WORKFLOW DISABLED STATE
   ======================================== */

.workflow-disabled {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(30%);
    position: relative;
}

.workflow-disabled::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: inherit;
}

/* Highlight pour le captcha */
.workflow-highlight {
    animation: highlightPulse 2s ease-in-out infinite;
    border-radius: 8px;
    position: relative;
}

.stl-captcha-wrapper.pulse {
    animation: captchaPulse 2s ease-in-out infinite;
}

@keyframes captchaPulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.5);
    }
    50% { 
        box-shadow: 0 0 0 12px rgba(0, 123, 255, 0);
    }
}

/* Viewer et contrôles - jamais grisés complètement */
.stl-viewer-block.workflow-disabled {
    opacity: 0.7;
    pointer-events: auto;
    filter: none;
}

@keyframes highlightPulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.3);
    }
    50% { 
        box-shadow: 0 0 0 10px rgba(0, 123, 255, 0);
    }
}

/* ========================================
   BOUTON PULSE (prochaine action)
   ======================================== */

.btn.pulse {
    animation: btnPulse 2s ease-in-out infinite;
}

@keyframes btnPulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.5);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 0 12px rgba(0, 123, 255, 0);
        transform: scale(1.02);
    }
}

.btn-primary.pulse {
    animation: btnPulsePrimary 2s ease-in-out infinite;
}

@keyframes btnPulsePrimary {
    0%, 100% { 
        box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
    }
    50% { 
        box-shadow: 0 4px 25px rgba(0, 123, 255, 0.6);
    }
}

.btn-success.pulse {
    animation: btnPulseSuccess 2s ease-in-out infinite;
}

@keyframes btnPulseSuccess {
    0%, 100% { 
        box-shadow: 0 4px 15px rgba(40, 167, 69, 0.4);
    }
    50% { 
        box-shadow: 0 4px 25px rgba(40, 167, 69, 0.6);
    }
}

/* ========================================
   RESPONSIVE WORKFLOW
   ======================================== */

@media (max-width: 768px) {
    .workflow-steps {
        flex-direction: column;
        gap: 4px;
        padding: 12px 10px;
        margin-bottom: 12px;
    }
    
    .workflow-connector {
        width: 2px;
        height: 8px;  /* Réduit de 20px à 8px */
    }
    
    .workflow-step {
        width: 100%;
        justify-content: center;
        padding: 6px 12px;
    }
    
    .workflow-step .step-number {
        width: 20px;
        height: 20px;
        font-size: 11px;
    }
    
    .workflow-step .step-label {
        font-size: 12px;
    }
}

/* === FILTRAGE BIBLIOTHÈQUE === */
.stl-library-item.filtered-out {
    display: none !important;
}

.stl-library-item {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* État initial : import actif, reste grisé */
.stl-import-column.workflow-active .stl-file-label,
.stl-import-column.workflow-active .stl-library-btn {
    opacity: 1;
    pointer-events: auto;
}

/* Wrapper captcha - centré verticalement */
.stl-captcha-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

/* Responsive */
@media (max-width: 768px) {
    .stl-header-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .stl-import-column {
        min-width: 100%;
    }
    
    .stl-captcha-wrapper {
        justify-content: flex-start;
    }
    
    .stl-action-column {
        width: 100%;
    }
    
    .stl-action-column .btn {
        width: 100%;
    }
}

/* Animation de clignotement pour le bouton Centrer lors d'une erreur de plateau */
@keyframes blinkHighlight {
    0%, 100% {
        background-color: #f8f9fa;
        box-shadow: none;
    }
    50% {
        background-color: #ffc107;
        box-shadow: 0 0 12px rgba(255, 193, 7, 0.8);
    }
}

.blink-highlight {
    animation: blinkHighlight 0.4s ease-in-out 4;
}