/* ============================================
   GRILLE-AFFICHAGE.CSS
   Gestion complète de l'affichage de la grille
   avec support des sections
   ============================================ */

/* ============================================
   ZONE D'AFFICHAGE PRINCIPALE
   ============================================ */

.content-display-area {
    width: 100%;
    max-width: 1300px;
    margin: clamp(1.5rem, 3vh, 2.5rem) auto;
    padding: 2rem;
    background: transparent;
    border-radius: var(--rayon-lg, 12px);
    min-height: 300px;
}

/* ============================================
   CONTAINER DES ACCORDS
   ============================================ */

.positions-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 1rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

/* Dernier container sans marge */
.positions-container:last-child {
    margin-bottom: 0;
}

/* ============================================
   WRAPPER ACCORD (header + carte)
   ============================================ */

.chord-card-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

/* État dragging */
.chord-card-wrapper.dragging {
    opacity: 0.5;
}

/* État drag-over */
.chord-card-wrapper.drag-over {
    border: 2px dashed var(--couleur-primaire, #808000);
    border-radius: var(--rayon-lg, 12px);
    padding: 0.25rem;
}

/* ✅ État dragging/drag-over pour les sections */
.grid-section-header.dragging {
    opacity: 0.5;
}

.grid-section-header.drag-over {
    border: 2px dashed var(--couleur-primaire, #808000);
    border-radius: var(--rayon-lg, 12px);
    padding: 0.25rem;
}

/* ============================================
   HEADER DE CARTE (nom d'accord)
   ============================================ */

.custom-grid-card-header {
    background: var(--couleur-primaire, #808000);
    border-radius: var(--rayon-lg, 12px);
    padding: 0.5rem 1rem;
    margin: 0 auto;
    position: relative;
    z-index: 2;
    max-width: 170px;
}

.custom-grid-chord-name {
    color: var(--texte-blanc, #FFFFFF);
    font-size: var(--texte-base, 1rem);
    font-weight: var(--poids-bold, 700);
    text-align: center;
    text-shadow: 0.0625rem 0.0625rem 0.1875rem rgba(0, 0, 0, 0.2);
    margin: 0;
}

/* ============================================
   CARTE DIAGRAMME
   ============================================ */

.diagram-card {
    background: var(--fond-creme, #FFF8DC);
    border: var(--bordure-normale, 2px) solid var(--bordure-claire, #DDD);
    border-radius: var(--rayon-lg, 12px);
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    transition: all var(--transition-normale, 0.3s ease);
    flex-direction: column;
    gap: 0;
}

.diagram-card:hover {
    box-shadow: var(--ombre-lg, 0 4px 12px rgba(0, 0, 0, 0.1));
    transform: translateY(-2px);
}

/* ============================================
   IMAGE DIAGRAMME
   ============================================ */

.diagram-image {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

/* Tailles spécifiques par instrument */

/* GUITARE */
body[data-current-instrument="guitare"] .diagram-card {
    width: 300px;

}

body[data-current-instrument="guitare"] .diagram-image {
    width: 100%;
    height: 100%;
}

/* PIANO */
body[data-current-instrument="piano"] .diagram-card {
    width: 350px;
    height: 140px;
}

body[data-current-instrument="piano"] .diagram-image {
    width: 180%;
    height: 180%;
}

/* UKULÉLÉ */
body[data-current-instrument="ukulele"] .diagram-card {
    width: 250px;
}

body[data-current-instrument="ukulele"] .diagram-image {
    width: 100%;
    height: 100%;
}

/* CHARANGO */
body[data-current-instrument="charango"] .diagram-card {
    width: 250px;
}

body[data-current-instrument="charango"] .diagram-image {
    width: 100%;
    height: 100%;
}

/* ============================================
   BOUTON SUPPRESSION ACCORD
   ============================================ */

.custom-grid-remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    opacity: 0;
    transition: all var(--transition-normale, 0.3s ease);
    z-index: 10;
}

/* Visible au hover sur desktop */
.diagram-card:hover .custom-grid-remove-btn {
    opacity: 1;
}

.custom-grid-remove-btn:hover {
    background: rgb(220, 53, 69);
    transform: scale(1.1);
}

/* ============================================
   HEADER DE SECTION
   ============================================ */

.grid-section-header {
    width: 100%;
    grid-column: 1 / -1; /* Prend toute la largeur de la grille */
    margin: 2.5rem 0 1.5rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
}

.grid-section-header:first-child {
    margin-top: 0.5rem;
}

.section-title {
    background: transparent;
    border: 2px solid var(--couleur-primaire, #808000);
    border-radius: var(--rayon-lg, 12px);
    padding: 0.5rem 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--couleur-primaire, #808000);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
    width: auto;
    text-align: center;
}

.section-delete-btn {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
    position: absolute;
    right: 0;
}

.section-delete-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* ============================================
   MESSAGE GRILLE VIDE
   ============================================ */

.empty-grid-message {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--texte-secondaire, #666);
    font-style: italic;
}

.empty-grid-message i {
    color: var(--couleur-primaire, #808000);
    opacity: 0.3;
    margin-bottom: 1rem;
    font-size: 3rem;
    display: block;
}

.empty-grid-message p {
    margin: 0.5rem 0;
    font-size: var(--texte-lg, 1.125rem);
}

.empty-grid-hint {
    font-size: var(--texte-sm, 0.875rem) !important;
    color: var(--texte-tertiaire, #999);
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */

@media (max-width: 47.9375rem) {
    .content-display-area {
        padding: 1rem;
    }
    
    .positions-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .chord-card-wrapper {
        gap: 0.5rem;
    }
    
    /* Guitare mobile */
    body[data-current-instrument="guitare"] .diagram-card {
        padding: 0.75rem;
        max-width: 100%;
        min-height: 240px;
    }
    
    body[data-current-instrument="guitare"] .diagram-image {
        width: 105%;
        height: 105%;
    }
    
    /* Piano mobile */
    body[data-current-instrument="piano"] .diagram-card {
        padding: 0.75rem;
        max-width: 100%;
        min-height: 260px;
    }
    
    body[data-current-instrument="piano"] .diagram-image {
        width: 120%;
        height: 120%;
    }
    
    /* Ukulélé mobile */
    body[data-current-instrument="ukulele"] .diagram-card {
        padding: 0.75rem;
        max-width: 100%;
        min-height: 220px;
    }
    
    body[data-current-instrument="ukulele"] .diagram-image {
        width: 105%;
        height: 105%;
    }
    
    /* Charango mobile */
    body[data-current-instrument="charango"] .diagram-card {
        padding: 0.75rem;
        max-width: 100%;
        min-height: 240px;
    }
    
    body[data-current-instrument="charango"] .diagram-image {
        width: 105%;
        height: 105%;
    }
    
    /* Bouton toujours visible sur mobile */
    .custom-grid-remove-btn {
        opacity: 1;
    }
    
    /* Sections responsive */
    .grid-section-header {
        margin: 1.5rem 0 0.75rem 0;
    }
    
    .section-title {
        font-size: 1.25rem;
        padding: 0.4rem 0.75rem;
    }
    
    .section-delete-btn {
        font-size: 1rem;
    }
}

/* ============================================
   RESPONSIVE - TABLETTE
   ============================================ */

@media (min-width: 48rem) and (max-width: 63.9375rem) {
    .positions-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   ACCESSIBILITÉ
   ============================================ */

.custom-grid-remove-btn:focus-visible,
.section-delete-btn:focus-visible {
    outline: 3px solid var(--couleur-primaire, #808000);
    outline-offset: 2px;
}

/* ============================================
   PRÉFÉRENCE MOUVEMENT RÉDUIT
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .custom-grid-remove-btn,
    .section-delete-btn,
    .diagram-card,
    .chord-card-wrapper {
        transition: none;
    }
    
    .custom-grid-remove-btn:hover,
    .section-delete-btn:hover,
    .diagram-card:hover {
        transform: none;
    }
}

/* ============================================
   PRINT
   ============================================ */

@media print {
    .custom-grid-remove-btn,
    .section-delete-btn {
        display: none !important;
    }
    
    .content-display-area {
        background: white;
    }
}
