/* Mobile First Responsive Design */

/* Extra Small devices (phones, 320px and up) */
@media (max-width: 575.98px) {
    .app-container {
        padding: 10px;
    }
    
    .app-header h1 {
        font-size: 2rem;
    }
    
    .app-header p {
        font-size: 1rem;
    }
    
    .main-content {
        padding: 20px;
    }
    
    /* Transport Controls */
    .transport-section {
        flex-direction: column;
        align-items: stretch;
        position: sticky;
bottom: 0;
z-index: 100;

    }
    
    .transport-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .transport-btn {
        flex: 1;
        min-width: 80px;
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .tempo-control {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    #tempo-slider {
        width: 120px;
    }
    
    /* Pattern Controls */
    .pattern-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .pattern-btn {
        flex: 1;
        min-width: 80px;
        font-size: 0.9rem;
    }
    
    .pattern-info {
        flex-direction: column;
        align-items: stretch;
    }
    
    #pattern-name {
        margin-bottom: 10px;
    }
    
    /* Grids */
    .presets-grid, .songs-grid, .user-patterns-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    /* Cards */
    .preset-card, .song-card, .user-pattern-card {
        padding: 15px;
    }
    
    /* Songs Filter */
    .songs-filter {
        flex-direction: column;
    }
    
    /* User Patterns Controls */
    .user-patterns-controls {
        flex-direction: column;
    }
    
    .action-btn {
        width: 100%;
    }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .presets-grid, .songs-grid, .user-patterns-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .transport-controls {
        justify-content: center;
    }
    
    .pattern-controls {
        justify-content: center;
    }

    /* On cache tous les points d'interrogation d'aide */
    .help-icon, .fa-question-circle, [title] + span { 
        display: none !important; 
    }
    
    /* Si tu as mis des ? directement dans le texte, on cible leur classe spécifique */
    .info-bubble {
        display: none !important;
    }

    /* Boutons sticky : faire vérif sur smartphone */
    .transport-section {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--white);
    z-index: 1000;
    padding: 15px;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.1);
    margin: 0;
}
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .presets-grid, .songs-grid, .user-patterns-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* On cache tous les points d'interrogation d'aide */
    .help-icon, .fa-question-circle, [title] + span { 
        display: none !important; 
    }
    
    /* Si tu as mis des ? directement dans le texte, on cible leur classe spécifique */
    .info-bubble {
        display: none !important;
    }
    
   /* Boutons sticky : faire vérif sur tablette */ 
.transport-section {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--white);
    z-index: 1000;
    padding: 15px;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.1);
    margin: 0;
}
    
    .sequencer-controls {
        flex-direction: row;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .presets-grid, .songs-grid, .user-patterns-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .transport-section {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--white);
    z-index: 1000;
    padding: 15px;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.1);
    margin: 0;
}
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .presets-grid, .songs-grid, .user-patterns-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .app-container {
        max-width: 1400px;
    }

    /* Boutons sticky : faire vérif sur grand écran */
    .transport-section {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--white);
    z-index: 1000;
    padding: 15px;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.1);
    margin: 0;
}
}

/* Landscape Orientation */
@media (orientation: landscape) and (max-height: 500px) {
    .app-header {
        margin-bottom: 20px;
    }
    
    .app-header h1 {
        font-size: 2rem;
    }
    
    .app-header p {
        display: none;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .sequencer-section {
        padding: 20px;
    }
    
    section {
        margin-bottom: 20px;
        padding-bottom: 15px;
    }

    /* Boutons sticky : faire vérif en landscape mode */
    .transport-section {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--white);
    z-index: 1000;
    padding: 15px;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.1);
    margin: 0;
}
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .step-btn {
        border-width: 2px;
    }
    
    .playhead {
        border-width: 1px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .step-btn:hover {
        transform: none;
    }
    
    .transport-btn:hover {
        transform: none;
    }
    
    .preset-card:hover, 
    .song-card:hover, 
    .user-pattern-card:hover {
        transform: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --white: #1a1a1a;
        --gray-100: #2d2d2d;
        --gray-200: #3d3d3d;
        --gray-300: #4d4d4d;
        --dark-color: #ffffff;
        --light-color: #2c3e50;
    }
    
    body {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    }
    
    .main-content {
        background: var(--gray-100);
        color: var(--dark-color);
    }
    
    .step-btn.empty {
        background: var(--gray-200);
        color: var(--gray-400);
    }
}

/* Print Styles */
@media print {
    body {
        background: white !important;
        color: black !important;
    }
    
    .transport-section,
    .pattern-controls,
    .user-patterns-controls {
        display: none !important;
    }
    
    .main-content {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
    
    .sequencer-section {
        break-inside: avoid;
    }
}

/* Accessibility Enhancements */
@media (prefers-contrast: high) {
    .step-btn {
        border-width: 3px;
    }
    
    .step-btn.down {
        background: #cc0000;
        border-color: #990000;
    }
    
    .step-btn.up {
        background: #006600;
        border-color: #004400;
    }
}

/* Touch Device Optimizations */
@media (pointer: coarse) {
    .step-btn {
        min-height: 60px;
    }
    
    .transport-btn {
        min-height: 48px;
        padding: 12px 20px;
    }
    
    .pattern-btn, .action-btn {
        min-height: 44px;
        padding: 12px 20px;
    }
    
    #tempo-slider {
        height: 8px;
    }
    
    #tempo-slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
}

.transport-section {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px; /* Espace réduit entre les éléments */
    padding: 10px;
}

/* On transforme le gros bouton Play/Pause en un cercle élégant */
#play-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    padding: 0;
}

/* On cache le mot "Play" ou "Pause" pour ne garder QUE l'icône ▶️ ou ⏸️ */
#play-btn .btn-text {
    display: none; 
}

/* 1. La console globale (Le fond gris rassemble tous les éléments) */
.transport-section {
    display: flex;
    flex-wrap: wrap; /* S'adapte sur mobile */
    justify-content: center;
    align-items: center;
    gap: 25px; /* Espace parfait entre les éléments */
    background-color: var(--gray-300); /* Petit fond gris pour unifier */
    padding: 20px 0;
    border-radius: 15px;
    margin: 5px 0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); /* Ombre légère */
    width: 100%;    
}

/* 2. Le bouton Play circulaire parfait */
#play-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%; /* Le rend rond */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    font-size: 1.8rem;
    box-shadow: 0 4px 10px rgba(var(--primary-color-rgb), 0.3); /* Ombre de couleur */
    transition: transform 0.1s ease, background-color 0.2s;
}

/* L'astuce secrète d'optique : on pousse le triangle de 4px vers la droite ! */
#play-btn:not(.active) .btn-icon {
    padding-left: 4px; 
}

/* Quand c'est en pause (II), c'est symétrique, on remet le padding à zéro */
#play-btn.active .btn-icon {
    padding-left: 0;
}

/* On cache le texte "Play/Pause" pour ne garder que l'icône */
#play-btn .btn-text {
    display: none;
}

/* 3. L'effet "clic" sur mobile (le bouton s'enfonce) */
#play-btn:active, #loop-btn:active {
    transform: scale(0.92);
}

/* 4. On ajuste le bouton Loop pour qu'il soit élégant à côté */
#loop-btn {
    height: 45px;
    border-radius: 25px; /* Bords très arrondis (pilule) */
    padding: 0 20px;
    font-weight: bold;
}

#loop-btn:not(.active) .btn-icon {
    padding-right: 4px; 
}

/* Le design des petits volumes drums */
.mini-volumes-control {
    display: flex;
    gap: 15px;
    align-items: center;
    background-color: var(--gray-100);
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid var(--gray-200);
}

.mini-volumes-control label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 1.2rem;
}

.mini-volumes-control input[type="range"] {
    width: 80px; /* Curseurs compacts */
    cursor: pointer;
}

/* On crée une classe commune pour les volumes et le tempo */
.mini-control-pill {
    display: flex;
    gap: 10px;
    align-items: center;
    background-color: var(--gray-100);
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid var(--gray-200);
}

/* Le petit champ nombre à côté du curseur */
.mini-number-input {
    width: 45px;
    border: none;
    background: transparent;
    font-weight: bold;
    color: var(--primary-color);
    font-family: inherit;
    font-size: 0.9rem;
    text-align: center;
}

/* On cache les flèches du champ nombre pour gagner de la place */
.mini-number-input::-webkit-inner-spin-button {
    display: none;
}

.mini-control-pill input[type="range"] {
    width: 80px;
}

.unit-label {
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--gray-500);
}

/* --- MONDE 1 : DESIGN PC (Par défaut) --- */
.transport-section {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    padding: 20px;
    background: var(--gray-100);
}

/* On garde tes textes et tes boutons larges sur PC */
.btn-text { display: inline; }
.unit-label { display: inline; }
#play-btn { width: auto; padding: 10px 25px; border-radius: 8px; }

/* --- MONDE 2 : DESIGN MOBILE (Écrans < 800px) --- */
@media (max-width: 800px) {
    .transport-section {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        padding: 8px 5px;
        gap: 10px;
        flex-wrap: nowrap; /* Force tout sur une seule ligne fine */
        justify-content: space-around;
    }

    /* On cache les textes pour ne garder que les icônes */
    .btn-text, .unit-label, .bpm-label { 
        display: none !important; 
    }

    /* Transformation du Play en cercle compact */
    #play-btn {
        width: 45px;
        height: 45px;
        border-radius: 50%;
        padding: 0;
        min-width: 45px;
    }

    /* Réduction drastique des sliders sur mobile */
    input[type="range"] {
        width: 50px;
    }

    /* On réduit la taille des "pilules" de contrôle */
    .mini-control-pill, .mini-volumes-control {
        padding: 4px 8px;
        gap: 5px;
    }
}

/* On simplifie la règle : le rideau ne s'affiche plus automatiquement via le CSS */
@media (max-width: 900px) and (orientation: portrait) {
    #orientation-overlay {
        display: none; /* On laisse le JS décider du moment opportun */
    }
    
    /* On ne cache plus l'appli, pour permettre de régler les volumes et choisir les chansons */
    #app-container {
        display: block; 
    }
}

/* Garde seulement le look pro du rideau */
#orientation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--primary-color);
    color: white;
    z-index: 9999;
    display: none; /* Par défaut, il reste caché */
    justify-content: center;
    align-items: center;
    flex-direction: column;
}


/* --- OPTIMISATION BARRE DE CONTRÔLES MOBILE --- */
/* --- OPTIMISATION BARRE DE CONTRÔLES MOBILE --- */
@media (max-width: 900px) {
    /* 1. On force la barre à être fine et tout sur une ligne */
    .transport-section {
        padding: 5px 10px !important;
        gap: 15px !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        height: 60px !important; /* Hauteur parfaite pour les doigts */
        align-items: center !important;
        justify-content: space-between !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    /* 2. On cache les mots inutiles pour gagner de la place */
    .btn-text,
    .unit-label,
    .volume-control label,
    .count-in-control strong, /* Cache le mot "Décompte" pour ne garder que l'émoji ⏱️ */
    .help-icon,
    .tempo-control label {
        display: none !important;
    }

    /* 3. Ajustement du conteneur Décompte */
    .count-in-control {
        margin: 0 !important;
        font-size: 1.2rem !important;
    }

    /* 4. Miniaturise les boutons ronds Play/Loop */
    #play-btn, #loop-btn {
        height: 42px !important;
        width: 42px !important;
        min-width: 42px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        font-size: 1.2rem !important;
        margin: 0 !important;
    }
    

    /* 5. Miniaturise les sliders */
    input[type="range"] {
        width: 45px !important;
        height: 4px !important;
    }

    /* 6. On nettoie les fonds gris pour compacter */
    .mini-control-pill, .mini-volumes-control, .transport-controls {
        gap: 5px !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        background: transparent !important;
    }
}

/* --- CENTRAGE FORCE ICONE LOOP (MOBILE) --- */
@media (max-width: 900px) {
    #loop-btn {
        padding: 0 !important; /* Efface tes anciens padding: 0 20px qui décalent l'icône */
    }
    
    #loop-btn .btn-icon {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }
}

/* je sacrifie le bouton Loop en mode portrait pour aérer l'interface */
@media (max-width: 900px) and (orientation: portrait) {
    #loop-btn, .mini-volumes-control {
        display: none !important;
    }
}