/**
 * progressions-ui-common.css
 * ðŸŽ¨ Styles communs pour le systÃ¨me de sauvegarde/chargement de progressions
 * UtilisÃ© par : mode Grille personnalisÃ©e ET mode Progressions
 */

/* ============================================
   BANNIÃˆRE NOM D'ACCORD - Dropdown activÃ©
   ============================================ */

body[data-mode="custom-grid"] .chord-name-banner,
body[data-mode="progressions"] .chord-name-banner {
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    user-select: none;
}

body[data-mode="custom-grid"] .chord-name-banner:hover,
body[data-mode="progressions"] .chord-name-banner:hover {
    background: #FFF5D6;
    border-color: #6b6b00;
}

/* Contenu cliquable avec icÃ´ne dropdown */
body[data-mode="custom-grid"] .chord-name-content,
body[data-mode="progressions"] .chord-name-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: normal;
    overflow: visible;
}

/* IcÃ´ne dropdown (chevron) */
.progression-dropdown-icon {
    display: none; /* MasquÃ© par dÃ©faut */
    font-size: 0.875rem;
    transition: transform 0.3s ease;
}

/* Afficher l'icÃ´ne en mode grille et progressions */
body[data-mode="custom-grid"] .progression-dropdown-icon,
body[data-mode="progressions"] .progression-dropdown-icon {
    display: inline-block;
}

/* Rotation de l'icÃ´ne quand le dropdown est ouvert */
body[data-mode="custom-grid"] .chord-name-banner.open .progression-dropdown-icon,
body[data-mode="progressions"] .chord-name-banner.open .progression-dropdown-icon {
    transform: rotate(180deg);
}

/* ============================================
   DROPDOWN - LISTE DES PROGRESSIONS
   ============================================ */

.progression-dropdown {
    position: fixed; /* âœ… ChangÃ© de absolute Ã  fixed */
    /* top et left seront dÃ©finis dynamiquement en JS */
    min-width: 16rem;
    max-width: 20rem;
    max-height: 20rem;
    overflow-y: auto;
    background: white;
    border: 2px solid var(--couleur-primaire);
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10001; /* âœ… AugmentÃ© Ã  10001 pour passer au-dessus de .control-zone (10000) */
    opacity: 0;
    visibility: hidden;
    /* transform sera dÃ©fini dynamiquement en JS */
    transition: opacity 0.3s ease, visibility 0.3s;
}

/* Dropdown ouvert */
.progression-dropdown.open {
    opacity: 1;
    visibility: visible;
}

/* Header du dropdown */
.progression-dropdown-header {
    padding: 0.75rem 1rem;
    background: var(--couleur-primaire);
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    border-bottom: 2px solid #6b6b00;
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Liste des progressions */
.progression-dropdown-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
}

/* Item de progression */
.progression-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progression-item:last-child {
    border-bottom: none;
}

.progression-item:hover {
    background: #f8f8f8;
}

/* Progression active */
.progression-item.active {
    background: #FFFAEB;
    border-left: 3px solid var(--couleur-primaire);
    padding-left: calc(1rem - 3px);
}

/* Info de la progression */
.progression-item-info {
    flex: 1;
}

.progression-item-name {
    font-weight: 600;
    color: #333;
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
}

.progression-item-meta {
    font-size: 0.75rem;
    color: #666;
}

/* IcÃ´ne checkmark pour la progression active */
.progression-item-check {
    color: var(--couleur-primaire);
    font-size: 1rem;
    display: none;
}

.progression-item.active .progression-item-check {
    display: block;
}

/* Message quand aucune progression */
.progression-dropdown-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: #666;
    font-style: italic;
    font-size: 0.875rem;
}

.progression-dropdown-empty i {
    font-size: 2rem;
    color: var(--couleur-primaire);
    opacity: 0.3;
    margin-bottom: 0.5rem;
    display: block;
}

/* Footer avec bouton "GÃ©rer" */
.progression-dropdown-footer {
    padding: 0.75rem 1rem;
    border-top: 2px solid #f0f0f0;
    background: #fafafa;
    position: sticky;
    bottom: 0;
}

.progression-manage-btn {
    width: 100%;
    padding: 0.5rem;
    background: var(--couleur-primaire);
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.progression-manage-btn:hover {
    background: #6b6b00;
}

/* ============================================
   SCROLLBAR CUSTOM
   ============================================ */

.progression-dropdown-list {
    scrollbar-width: thin;
    scrollbar-color: var(--couleur-primaire) #f0f0f0;
}

.progression-dropdown-list::-webkit-scrollbar {
    width: 6px;
}

.progression-dropdown-list::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.progression-dropdown-list::-webkit-scrollbar-thumb {
    background: var(--couleur-primaire);
    border-radius: 3px;
}

.progression-dropdown-list::-webkit-scrollbar-thumb:hover {
    background: #6b6b00;
}

/* ============================================
   MODALS - CARTES DE PROGRESSION
   ============================================ */

.progression-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.progression-card:hover {
    border-color: #808000;
    box-shadow: 0 2px 8px rgba(128, 128, 0, 0.1);
    transform: translateY(-2px);
}

.progression-info {
    flex: 1;
}

.progression-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 0.25rem 0;
}

.progression-meta {
    font-size: 0.875rem;
    color: #666;
    margin: 0;
}

.progression-actions {
    display: flex;
    gap: 0.5rem;
}

/* ============================================
   BOUTONS ICÃ”NES
   ============================================ */

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    color: #333;
}

.btn-icon:hover {
    background: #808000;
    border-color: #808000;
    color: white;
    transform: scale(1.05);
}

.btn-icon:active {
    transform: scale(0.95);
}

.btn-icon.btn-danger:hover {
    background: #dc3545;
    border-color: #dc3545;
}

/* ============================================
   MODAL SPÃ‰CIFIQUE PROGRESSIONS
   ============================================ */

#progressionsListContainer {
    min-height: 200px;
}

/* Input dans le modal de sauvegarde */
#progressionNameInput {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    transition: border-color 0.2s ease;
}

#progressionNameInput:focus {
    outline: none;
    border-color: #808000;
}

/* ============================================
   BOUTONS BANNIÃˆRE MODE
   ============================================ */

/* Conteneur des boutons d'action */
.mode-banner-actions {
    display: none; /* MasquÃ© par dÃ©faut */
    gap: 0.5rem;
    align-items: center;
}

/* Afficher les boutons en mode grille ET progressions */
body[data-mode="custom-grid"] .mode-banner-actions,
body[data-mode="progressions"] .mode-banner-actions {
    display: flex;
}

/* Style des boutons d'action */
.mode-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    height: 2rem;
    padding: 0 0.75rem;
    background: var(--couleur-primaire);
    color: white;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    white-space: nowrap;
    width: auto;
}

/* Boutons sans texte (icÃ´ne seule) - format carrÃ© */
.mode-action-btn:not(:has(span)) {
    width: 2rem;
    padding: 0;
}

.mode-action-btn:hover {
    background: #6b6b00;
    transform: scale(1.05);
}

.mode-action-btn:active {
    transform: scale(0.95);
}

/* Couleur spÃ©cifique pour le bouton exporter */
.mode-action-btn[data-action="export"] {
    background: #4a7c59;
}

.mode-action-btn[data-action="export"]:hover {
    background: #3a6147;
}

/* Bouton "Nouvelle grille/progression" en gras */
.mode-action-btn[data-action="new-grid"] span,
.mode-action-btn[data-action="new-progression"] span {
    font-weight: 700;
}

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

@media (max-width: 47.9375rem) {
    /* S'assurer que la banniÃ¨re reste cliquable */
    body[data-mode="custom-grid"] .chord-name-banner,
    body[data-mode="progressions"] .chord-name-banner {
        z-index: 1001;
        position: relative;
    }
    
    .progression-dropdown {
        max-width: 90vw;
        max-height: 60vh;
        min-width: auto;
    }
    
    .progression-item {
        padding: 0.625rem 0.875rem;
    }
    
    .progression-item-name {
        font-size: 0.875rem;
    }
    
    .progression-item-meta {
        font-size: 0.6875rem;
    }
    
    .progression-dropdown-header {
        padding: 0.625rem 0.875rem;
        font-size: 0.8125rem;
    }
    
    .progression-card {
        flex-direction: column;
        gap: 1rem;
    }
    
    .progression-actions {
        width: 100%;
        justify-content: center;
    }
    
    .mode-action-btn {
        height: 1.75rem;
        padding: 0 0.5rem;
        font-size: 0.75rem;
        gap: 0.25rem;
    }
    
    .mode-action-btn:not(:has(span)) {
        width: 1.75rem;
        padding: 0;
    }
}

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

@media (min-width: 48rem) and (max-width: 63.9375rem) {
    .progression-dropdown {
        min-width: 16rem;
    }
}

/* ============================================
   ACCESSIBILITÃ‰
   ============================================ */

body[data-mode="custom-grid"] .chord-name-banner:focus-visible,
body[data-mode="progressions"] .chord-name-banner:focus-visible {
    outline: 3px solid var(--couleur-primaire);
    outline-offset: 2px;
}

.progression-item:focus-visible {
    outline: 2px solid var(--couleur-primaire);
    outline-offset: -2px;
}

/* Support clavier */
.progression-item:focus {
    background: #f8f8f8;
}

.mode-action-btn:focus-visible {
    outline: 3px solid var(--couleur-primaire);
    outline-offset: 2px;
}

/* Afficher un tooltip au survol */
.mode-action-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

/* ============================================
   PRÃ‰FÃ‰RENCE MOUVEMENT RÃ‰DUIT
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    body[data-mode="custom-grid"] .chord-name-banner,
    body[data-mode="progressions"] .chord-name-banner,
    .progression-dropdown,
    .progression-dropdown-icon,
    .progression-item,
    .progression-manage-btn,
    .progression-card,
    .btn-icon,
    .mode-action-btn {
        transition: none;
    }
    
    body[data-mode="custom-grid"] .chord-name-banner.open .progression-dropdown-icon,
    body[data-mode="progressions"] .chord-name-banner.open .progression-dropdown-icon {
        transform: none;
    }
    
    .progression-card:hover,
    .btn-icon:hover,
    .mode-action-btn:hover,
    .mode-action-btn:active {
        transform: none;
    }
}

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

@media print {
    .progression-dropdown,
    .progression-dropdown-icon,
    .mode-banner-actions {
        display: none !important;
    }
    
    body[data-mode="custom-grid"] .chord-name-banner,
    body[data-mode="progressions"] .chord-name-banner {
        cursor: default;
    }
}