/* ========================================
   RESPONSIVE - VERSIÓN OPTIMIZADA
   ======================================== */

/* 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 */
    #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 - COMPACTO (6 COLUMNAS)
   ======================================== */
@media (max-width: 950px) and (orientation: landscape) {
    body {
        padding: 0.3rem !important; /* Reduce espacio exterior total */
    }

    .top-bar {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        height: 42px !important; /* Altura reducida (antes 60px) */
        padding: 0 10px !important;
        margin-bottom: 0.4rem !important; /* Menos espacio entre barra y sonidos */
        box-sizing: border-box !important;
    }
    
    .icon-btn {
        order: 1 !important;
        width: 36px !important;
        height: 36px !important;
        flex-shrink: 0 !important;
    }
    
    /* SLIDER DE TAMAÑO OCULTO EN HORIZONTAL */
    .size-control {
        display: none !important;
    }
    
    .toggle-switch {
        order: 3 !important;
        flex-shrink: 0 !important;
        transform: scale(0.9); /* Ligeramente más pequeño para ahorrar espacio */
    }
    
    .volume-control {
        display: none !important;
    }
    
    /* Grids en horizontal fijados a 6 columnas */
    #favoritesGrid,
    #allSoundsGrid,
    .sound-grid {
        display: grid !important;
        grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
        gap: 0.5rem !important; /* Gap más pequeño para maximizar visibilidad */
        width: 100%;
    }

    .favorites-section {
        margin-bottom: 0.5rem !important;
        padding: 0.4rem !important;
    }
}

/* 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;
}
