/* ============================================================
   Sélecteur de Breloques - Styles
   ============================================================ */

/* --- Bouton "Choisir ma breloque" sur la fiche produit --- */
#breloque-selector-wrap {
    margin: 15px 0;
    padding: 0;
}

.breloque-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
    color: #fff !important;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 12px rgba(142, 68, 173, 0.3);
}

.breloque-trigger-btn:hover {
    background: linear-gradient(135deg, #7d3c98, #8e44ad);
    box-shadow: 0 5px 20px rgba(142, 68, 173, 0.4);
    transform: translateY(-1px);
}

.breloque-trigger-btn.has-selection {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    box-shadow: 0 3px 12px rgba(39, 174, 96, 0.3);
}

.breloque-trigger-btn.has-selection:hover {
    background: linear-gradient(135deg, #229954, #27ae60);
}

/* --- Aperçu de la breloque sélectionnée --- */
.breloque-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    padding: 12px 16px;
    background: #f8f4fc;
    border: 2px solid #8e44ad;
    border-radius: 10px;
    animation: breloque-fadein 0.3s ease;
}

.breloque-preview img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.breloque-preview-info {
    flex: 1;
}

.breloque-preview-info .name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.breloque-preview-info .details {
    color: #7f8c8d;
    font-size: 12px;
    margin-top: 2px;
}

.breloque-preview-remove {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.breloque-preview-remove:hover {
    background: #fde8e8;
}

/* --- Overlay / Modale --- */
.breloque-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999999;
    animation: breloque-fadein 0.2s ease;
}

.breloque-modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.breloque-modal {
    background: #fff;
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: breloque-slidein 0.3s ease;
    overflow: hidden;
}

/* --- Header de la modale --- */
.breloque-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
    color: #fff;
}

.breloque-modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.breloque-modal-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.breloque-modal-close:hover {
    background: rgba(255,255,255,0.3);
}

/* --- Filtres catégories --- */
.breloque-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 24px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.breloque-filter-btn {
    padding: 8px 16px;
    background: #fff;
    border: 2px solid #dee2e6;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #495057;
}

.breloque-filter-btn:hover {
    border-color: #9b59b6;
    color: #8e44ad;
}

.breloque-filter-btn.active {
    background: #8e44ad;
    border-color: #8e44ad;
    color: #fff;
}

/* --- Grille de breloques --- */
.breloque-grid-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.breloque-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.breloque-card {
    position: relative;
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.25s ease;
}

.breloque-card:hover {
    border-color: #9b59b6;
    box-shadow: 0 4px 16px rgba(142, 68, 173, 0.15);
    transform: translateY(-2px);
}

.breloque-card.selected {
    border-color: #8e44ad;
    border-width: 3px;
    box-shadow: 0 4px 20px rgba(142, 68, 173, 0.3);
}

.breloque-card.selected::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: #8e44ad;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    z-index: 2;
}

.breloque-card-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: #f0f0f0;
}

.breloque-card-info {
    padding: 10px;
    text-align: center;
}

.breloque-card-name {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.3;
    margin: 0 0 2px;
}

.breloque-card-numero {
    font-size: 11px;
    color: #7f8c8d;
}

.breloque-card-cat {
    display: inline-block;
    font-size: 10px;
    color: #8e44ad;
    background: #f3e8fa;
    padding: 2px 8px;
    border-radius: 10px;
    margin-top: 4px;
}

/* --- Footer modale --- */
.breloque-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

.breloque-selection-info {
    font-size: 14px;
    color: #495057;
}

.breloque-selection-info strong {
    color: #8e44ad;
}

.breloque-confirm-btn {
    padding: 12px 28px;
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.5;
    pointer-events: none;
}

.breloque-confirm-btn.enabled {
    opacity: 1;
    pointer-events: auto;
}

.breloque-confirm-btn.enabled:hover {
    background: linear-gradient(135deg, #7d3c98, #8e44ad);
    box-shadow: 0 4px 16px rgba(142, 68, 173, 0.3);
}

/* --- Loading --- */
.breloque-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #7f8c8d;
}

.breloque-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e9ecef;
    border-top-color: #8e44ad;
    border-radius: 50%;
    animation: breloque-spin 0.8s linear infinite;
    margin-bottom: 16px;
}

.breloque-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #95a5a6;
    font-size: 15px;
}

/* --- Animations --- */
@keyframes breloque-fadein {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes breloque-slidein {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

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

/* --- Responsive --- */
@media (max-width: 600px) {
    .breloque-modal {
        width: 95%;
        max-height: 90vh;
        border-radius: 12px;
    }

    .breloque-modal-header {
        padding: 16px;
    }

    .breloque-modal-header h2 {
        font-size: 17px;
    }

    .breloque-filters {
        padding: 12px 16px;
        gap: 6px;
    }

    .breloque-filter-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .breloque-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 10px;
    }

    .breloque-grid-container {
        padding: 16px;
    }

    .breloque-modal-footer {
        flex-direction: column;
        gap: 10px;
        padding: 12px 16px;
    }

    .breloque-confirm-btn {
        width: 100%;
        text-align: center;
    }
}

/* --- Zoom image au survol --- */
.breloque-card-img-wrap {
    position: relative;
    overflow: hidden;
}

.breloque-card-img-wrap .breloque-zoom-icon {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s;
}

.breloque-card:hover .breloque-zoom-icon {
    opacity: 1;
}

/* --- Lightbox zoom --- */
.breloque-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 9999999;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.breloque-lightbox.active {
    display: flex;
}

.breloque-lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

/* --- Barre de recherche --- */
.breloque-search-wrap {
    padding: 0 24px 12px;
    background: #f8f9fa;
}

.breloque-search-input {
    width: 100%;
    padding: 10px 16px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.breloque-search-input:focus {
    border-color: #9b59b6;
}

.breloque-search-input::placeholder {
    color: #adb5bd;
}
