/**
 * ============================================
 * INSERT ZONE V2 - Style Livebook (CORRIGÉ)
 * Zone d'insertion entre cellules
 * FIX: Dropdown reste visible au survol
 * ============================================
 */

/* Container principal */
.insert-zone-v2 {
    position: relative;
    height: 1px;
    margin: 20px 0;
    width: 100%;
}

/* Zone hover invisible qui couvre toute la largeur */
.insert-hover-area {
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 40px;
    cursor: pointer;
    z-index: 1;
}

/* Container des boutons */
.insert-buttons-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;  /* Invisible par défaut */
    pointer-events: none;  /* Pas de clics */
    transition: opacity 0.15s ease;
    z-index: 10;
}

/* ✅ FIX: Afficher au hover sur la ZONE OU sur les boutons */
.insert-zone-v2:hover .insert-buttons-container,
.insert-buttons-container:hover {
    opacity: 1;  /* Visible au hover */
    pointer-events: all;  /* Cliquable */
}

/* ✅ NOUVEAU: Wrapper actif reste visible */
.insert-button-wrapper.active .insert-buttons-container {
    opacity: 1;
    pointer-events: all;
}

/* Groupe de boutons */
.insert-buttons-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Wrapper de bouton (pour dropdown) */
.insert-button-wrapper {
    position: relative;
}

/* ✅ NOUVEAU: Wrapper actif garde le hover */
.insert-button-wrapper.active {
    z-index: 101;
}

/* Bouton principal */
.insert-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #374151;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.insert-button:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* ✅ NOUVEAU: Bouton actif (dropdown ouvert) */
.insert-button-wrapper.active .insert-button {
    background: #f3f4f6;
    border-color: #3b82f6;
    color: #3b82f6;
}

.insert-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.insert-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Icône du bouton */
.button-icon {
    font-size: 16px;
    line-height: 1;
}

/* Texte du bouton */
.button-text {
    font-size: 13px;
    font-weight: 500;
}

/* Flèche dropdown */
.button-arrow {
    font-size: 10px;
    color: #6b7280;
    margin-left: 2px;
    transition: transform 0.2s ease;
}

/* ✅ NOUVEAU: Flèche tourne quand dropdown ouvert */
.insert-button-wrapper.active .button-arrow {
    transform: rotate(180deg);
}

/* ============================================
   DROPDOWN
   ============================================ */

.insert-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    padding: 6px;
    z-index: 100;
    animation: dropdownFadeIn 0.15s ease;
    /* ✅ FIX CRITIQUE: Assurer que le dropdown est cliquable */
    pointer-events: all;
}

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

/* Section du dropdown */
.dropdown-section {
    padding: 4px 0;
}

.dropdown-section + .dropdown-section {
    border-top: 1px solid #e5e7eb;
    margin-top: 4px;
    padding-top: 8px;
}

/* Titre de section */
.dropdown-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 12px;
    margin-bottom: 2px;
}

/* Item de dropdown */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s ease;
}

.dropdown-item:hover:not([disabled]) {
    background: #f3f4f6;
}

.dropdown-item[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Icône de l'item */
.item-icon {
    font-size: 18px;
    line-height: 1;
    width: 20px;
    text-align: center;
}

/* Label de l'item */
.item-label {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
}

/* Badge (Soon, etc.) */
.item-badge {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
}

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

@media (max-width: 768px) {
    .insert-buttons-group {
        flex-direction: column;
        gap: 6px;
    }
    
    .insert-button {
        width: 100%;
        justify-content: center;
    }
    
    .insert-dropdown {
        left: 50%;
        transform: translateX(-50%);
    }
}