/* ========================================
   RESPONSIVE - CORREGIDO (VERSIÓN DINÁMICA)
   ======================================== */

/* Variable global por defecto */
:root {
    --card-size: 100px;
}

/* Móvil vertical (menos de 600px) */
@media (max-width: 600px) and (orientation: portrait) {
    body {
        padding: 0.5rem;
    }
    
    .container {
        padding: 0.2rem;
        width: 100%;
        box-sizing: border-box;
    }
    
    .top-bar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.3rem;
        flex-wrap: nowrap;
        margin-bottom: 0.8rem;
        width: 100%;
    }
    
    .icon-btn {
        order: 1;
        width: 40px;
        height: 40px;
        flex-shrink: 0;
    }
    
    /* SLIDER DE TAMAÑO OCULTO EN VERTICAL */
    .size-control {
        display: none !important;
    }
    
    .toggle-switch {
        order: 2;
        margin: 0;
        padding: 0.2rem 0.5rem;
        flex-shrink: 0;
    }
    
    .toggle-switch label {
        font-size: 0.6rem;
    }
    
    .toggle-switch input {
        width: 32px;
        height: 18px;
    }
    
    .toggle-switch input::before {
        width: 14px;
        height: 14px;
    }
    
    .toggle-switch input:checked::before {
        left: 18px;
    }
    
    /* VOLUMEN OCULTO EN VERTICAL */
    .volume-control {
        display: none !important;
    }
    
    /* Grids: 3 columnas fijas estrictas (Aquí NO afecta el slider) */
    #favoritesGrid,
    #allSoundsGrid,
    .sound-grid {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 0.6rem;
        width: 100%;
    }
    
    .favorites-section {
        padding: 0.6rem;
        margin-bottom: 0.6rem;
        width: 100%;
        box-sizing: border-box;
    }
    
    .section-title {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }
    
    .card-title {
        font-size: 0.65rem;
        word-break: break-word;
    }
}

/* ========================================
   MÓVIL HORIZONTAL - SLIDER DINÁMICO
   ======================================== */
@media (max-width: 950px) and (orientation: landscape) {
    .top-bar {
        display: flex !important;
        position: relative !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        height: 60px !important;
        padding: 0 15px !important;
        box-sizing: border-box !important;
    }
    
    .icon-btn {
        order: 1 !important;
        flex-shrink: 0 !important;
        z-index: 2 !important;
    }
    
    /* CONTENEDOR DEL SLIDER CENTRADO */
    .size-control {
        position: absolute !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        display: flex !important;
        align-items: center !important;
        width: auto !important;
        margin: 0 !important;
        z-index: 5 !important;
        pointer-events: auto !important;
    }
    
    .size-control label {
        display: inline-block !important;
        font-size: 0.75rem !important;
        margin-right: 10px !important;
        white-space: nowrap !important;
    }
    
    /* Slider un poco más grande y funcional */
    .size-slider {
        width: 200px !important;
        cursor: pointer !important;
        touch-action: pan-x !important;
        pointer-events: auto !important;
        z-index: 10 !important;
    }
    
    .toggle-switch {
        order: 3 !important;
        flex-shrink: 0 !important;
        z-index: 2 !important;
    }
    
    .volume-control {
        display: none !important;
    }
    
    /* Grids en horizontal: SIN !important para que applyScale() pueda modificarlos */
    #favoritesGrid,
    #allSoundsGrid,
    .sound-grid {
        display: grid;
        gap: 0.8rem;
        width: 100%;
    }
}

/* Tablet (769px - 1023px) */
@media (min-width: 769px) and (max-width: 1023px) {
    body {
        padding: 1rem;
    }
    
    .container {
        padding: 0.5rem;
    }
    
    .sound-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(130px, 150px));
        gap: 1rem;
        justify-content: start;
    }
    
    .volume-control {
        display: flex;
    }
    
    .volume-slider {
        width: 180px;
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    body {
        padding: 1.5rem;
    }
    
    .sound-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(150px, 170px));
        gap: 1.2rem;
        justify-content: start;
    }
    
    .volume-control {
        display: flex;
    }
    
    .volume-slider {
        width: 220px;
    }
}

/* Estilos para drag & drop móvil */
@media (max-width: 768px) {
    .drag-clone {
        position: fixed !important;
        z-index: 99999 !important;
        opacity: 0.95 !important;
        pointer-events: none !important;
        border: 2px solid #5f7aff !important;
        border-radius: 0.8rem !important;
        transform: scale(1.05) !important;
        box-shadow: 0 20px 40px rgba(0,0,0,0.3) !important;
    }
    
    .sound-card.dragging {
        opacity: 0 !important;
    }
    
    .sound-card {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
}

/* Utilidades */
html {
    -webkit-overflow-scrolling: touch;
}

.dragging-active * {
    user-select: none !important;
    -webkit-user-select: none !important;
}

input[type="range"] {
    user-select: auto !important;
    -webkit-user-select: auto !important;
}
