/* ===============================================
   APERÇUS 3D DE LA BIBLIOTHÈQUE
   =============================================== */

.item-preview,
.item-preview-3d {
    width: 240px;
    height: 180px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    border-radius: 12px;
    border: 1px solid #444;
    position: relative;
    overflow: hidden;
}

.preview-3d,
.preview-3d-static {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.preview-3d-static {
    filter: brightness(0.9);
}

/* Animation au survol pour les aperçus statiques */
.library-item:hover .preview-3d-static {
    filter: brightness(1.1);
    transform: scale(1.05);
}

/* Effets visuels pour les aperçus dynamiques */
.library-item.dynamic-preview .item-preview,
.library-item.dynamic-preview .item-preview-3d {
    border-color: #4CAF50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
}

.library-item.dynamic-preview::after {
    content: "3D";
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(76, 175, 80, 0.8);
    color: white;
    font-size: 8px;
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: bold;
    z-index: 10;
}

/* Indicateur de chargement */
.preview-loading {
    position: relative;
}

.preview-loading::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #333;
    border-top-color: #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 5;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Amélioration des boutons de coupe avec aperçus */
.cut-buttons {
    display: flex;
    gap: 4px;
    margin-top: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Animation de survol améliorée - compatible avec library-professional.css */
.cut-btn-mini:hover {
    /* Amélioration de l'effet de survol sans écraser les styles principaux */
    box-shadow: var(--shadow-subtle), 0 2px 8px rgba(76, 175, 80, 0.15);
}

/* État actif amélioré */
.cut-btn-mini.active {
    /* Garde l'état actif défini dans library-professional.css */
    box-shadow: var(--shadow-light), 0 0 8px rgba(33, 150, 243, 0.3);
}

/* Amélioration de l'élément library-item */
.library-item {
    background: linear-gradient(135deg, #2e2e2e 0%, #1e1e1e 100%);
    border: 1px solid #404040;
    border-radius: 12px;
    padding: 16px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    min-height: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.library-item:hover {
    border-color: #4CAF50;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(76, 175, 80, 0.2);
}

.library-item.selected {
    border-color: #2196F3;
    background: linear-gradient(135deg, #1e3a5f 0%, #0d1929 100%);
    box-shadow: 0 0 12px rgba(33, 150, 243, 0.4), 0 0 0 2px rgba(33, 150, 243, 0.6);
    transform: scale(1.02);
    transition: all 0.3s ease;
}

/* Informations sur l'élément */
.item-info {
    text-align: center;
    margin: 8px 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.item-name {
    font-weight: bold;
    color: #fff;
    font-size: 14px;
    margin-bottom: 6px;
}

.item-dimensions {
    color: #aaa;
    font-size: 11px;
    font-family: 'Courier New', monospace;
}

/* Grille de la bibliothèque */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin: 16px 0;
}

/* Responsive pour les petits écrans */
@media (max-width: 768px) {
    .library-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 12px;
    }
    
    .library-item {
        min-height: 200px;
        padding: 12px;
    }
    
    .item-preview,
    .item-preview-3d {
        width: 200px;
        height: 150px;
    }
}

/* Animation de révélation progressive */
.library-item {
    animation: fadeInUp 0.3s ease forwards;
    opacity: 0;
    transform: translateY(20px);
}

.library-item:nth-child(1) { animation-delay: 0.1s; }
.library-item:nth-child(2) { animation-delay: 0.2s; }
.library-item:nth-child(3) { animation-delay: 0.3s; }
.library-item:nth-child(4) { animation-delay: 0.4s; }
.library-item:nth-child(5) { animation-delay: 0.5s; }
.library-item:nth-child(n+6) { animation-delay: 0.6s; }

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Indicateur de qualité de rendu */
.preview-quality-indicator {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4CAF50;
    opacity: 0.7;
}

.preview-quality-indicator.medium {
    background: #FF9800;
}

.preview-quality-indicator.low {
    background: #F44336;
}

/* État de chargement des aperçus */
.library-section.loading .library-item {
    pointer-events: none;
}

.library-section.loading .item-preview,
.library-section.loading .item-preview-3d {
    opacity: 0.5;
    position: relative;
}

/* Optimisation pour les performances */
.library-item.low-power .preview-3d-static {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Message d'erreur pour WebGL non disponible */
.webgl-error {
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid #F44336;
    border-radius: 8px;
    padding: 16px;
    margin: 16px;
    text-align: center;
    color: #F44336;
}

.webgl-error h4 {
    margin: 0 0 8px 0;
    color: #F44336;
}

.webgl-error p {
    margin: 0;
    font-size: 14px;
    opacity: 0.8;
}
