/**
 * WooCommerce MIDI Player - Estilos
 * Compatible con cualquier theme de WordPress/WooCommerce
 */

/* ============================================
   VARIABLES CSS
   ============================================ */
:root {
    --wc-midi-primary: #0073aa;
    --wc-midi-primary-hover: #005a87;
    --wc-midi-danger: #dc3232;
    --wc-midi-danger-hover: #a00;
    --wc-midi-success: #46b450;
    --wc-midi-bg: #f7f7f7;
    --wc-midi-border: #ddd;
    --wc-midi-text: #333;
    --wc-midi-text-light: #666;
}

/* ============================================
   REPRODUCTOR INDIVIDUAL [midiplay]
   ============================================ */

.wc-midi-player-single {
    margin: 20px 0;
    padding: 24px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
}

.wc-midi-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    font-size: 16px;
    color: var(--wc-midi-text);
}

.wc-midi-icon {
    font-size: 20px;
}

.wc-midi-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Botones de control */
.wc-midi-btn {
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wc-midi-primary) 0%, var(--wc-midi-primary-hover) 100%);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
    position: relative;
    overflow: hidden;
}

.wc-midi-btn:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 115, 170, 0.4);
}

.wc-midi-btn:active {
    transform: scale(1.02) translateY(0);
    box-shadow: 0 4px 15px rgba(0, 115, 170, 0.3);
}

.wc-midi-btn:focus {
    outline: 2px solid var(--wc-midi-primary);
    outline-offset: 2px;
}

.wc-midi-btn svg {
    width: 20px;
    height: 20px;
    pointer-events: none;
}

/* Botón Stop - color rojo */
.wc-midi-stop {
    background: var(--wc-midi-danger);
}

.wc-midi-stop:hover {
    background: var(--wc-midi-danger-hover);
}

/* Estado activo - color verde */
.wc-midi-player-single.is-playing .wc-midi-pause {
    background: var(--wc-midi-success);
}

/* Contenedor de progreso */
.wc-midi-progress-wrapper {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Barra de progreso */
.wc-midi-seek {
    width: 100%;
    height: 10px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(90deg, #e0e0e0 0%, #f0f0f0 100%);
    border-radius: 5px;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.wc-midi-seek:hover {
    opacity: 0.9;
}

.wc-midi-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, var(--wc-midi-primary) 0%, var(--wc-midi-primary-hover) 100%);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.4);
    border: 2px solid #fff;
}

.wc-midi-seek::-webkit-slider-thumb:hover {
    transform: scale(1.3);
    box-shadow: 0 6px 20px rgba(0, 115, 170, 0.6);
}

.wc-midi-seek::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, var(--wc-midi-primary) 0%, var(--wc-midi-primary-hover) 100%);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.4);
}

.wc-midi-seek::-moz-range-thumb:hover {
    transform: scale(1.3);
    box-shadow: 0 6px 20px rgba(0, 115, 170, 0.6);
}

/* Display de tiempo */
.wc-midi-time-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--wc-midi-text-light);
    font-family: 'Courier New', monospace;
    font-weight: 500;
}

.wc-midi-separator {
    margin: 0 4px;
}

/* Loading indicator */
.wc-midi-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.98);
    padding: 20px 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--wc-midi-primary);
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.wc-midi-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 115, 170, 0.2);
    border-top-color: var(--wc-midi-primary);
    border-radius: 50%;
    animation: wc-midi-spin 0.8s linear infinite;
}

@keyframes wc-midi-spin {
    to { transform: rotate(360deg); }
}

/* Error message */
.wc-midi-error {
    padding: 15px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #856404;
    text-align: center;
    margin: 10px 0;
}

/* ============================================
   REPRODUCTOR GRID [midiplay_grid]
   ============================================ */

.wc-midi-grid-player {
    margin: 10px 0 !important;
    text-align: center !important;
    position: relative !important;
    min-height: 60px !important;
}

.wc-midi-grid-btn {
    position: relative !important;
    display: block !important;
    margin: 10px auto !important;
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(2px) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    color: #fff !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    overflow: hidden !important;
    z-index: 10 !important;
}

.wc-midi-grid-btn:hover {
    background: rgba(0, 0, 0, 0.8) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
    transform: scale(1.1) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5) !important;
}

.wc-midi-grid-btn:active {
    transform: scale(1.05) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
}

.wc-midi-grid-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.wc-midi-grid-btn:hover svg {
    transform: scale(1.1);
}

/* Estado activo en grid */
.wc-midi-grid-player.is-playing .wc-midi-grid-btn {
    background: rgba(76, 175, 80, 0.8);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
    animation: wc-midi-pulse 2s infinite;
}

@keyframes wc-midi-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.85;
    }
}

/* ============================================
   INTEGRACIÓN CON WOOCOMMERCE
   ============================================ */

/* En listado de productos */
.woocommerce ul.products li.product .wc-midi-grid-player {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--wc-midi-border);
}

/* En página de producto individual */
.woocommerce div.product .wc-midi-player-single {
    margin: 30px 0;
}

/* Compatibilidad con diferentes themes */
.product .wc-midi-grid-player,
.product-small .wc-midi-grid-player {
    width: 100%;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Tablets */
@media (max-width: 768px) {
    .wc-midi-player-single {
        padding: 15px;
    }
    
    .wc-midi-controls {
        gap: 8px;
    }
    
    .wc-midi-btn {
        width: 40px;
        height: 40px;
    }
    
    .wc-midi-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .wc-midi-title {
        font-size: 15px;
    }
}

/* Móviles */
@media (max-width: 480px) {
    .wc-midi-player-single {
        padding: 12px;
    }
    
    .wc-midi-controls {
        gap: 6px;
    }
    
    .wc-midi-btn {
        width: 38px;
        height: 38px;
    }
    
    .wc-midi-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .wc-midi-progress-wrapper {
        width: 100%;
        order: 3;
        margin-top: 8px;
    }
    
    .wc-midi-time-display {
        font-size: 12px;
    }
    
    /* Grid button en móvil */
    .wc-midi-grid-btn {
        width: 32px;
        height: 32px;
    }

    .wc-midi-grid-btn svg {
        width: 18px;
        height: 18px;
    }
}

/* Extra pequeño */
@media (max-width: 360px) {
    .wc-midi-grid-btn {
        width: 30px;
        height: 30px;
    }

    .wc-midi-grid-btn svg {
        width: 16px;
        height: 16px;
    }
}

/* ============================================
   TEMA OSCURO
   ============================================ */

@media (prefers-color-scheme: dark) {
    :root {
        --wc-midi-bg: #2c2c2c;
        --wc-midi-border: #444;
        --wc-midi-text: #e0e0e0;
        --wc-midi-text-light: #aaa;
    }
    
    .wc-midi-player-single {
        background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
        border-color: var(--wc-midi-border);
    }

    .wc-midi-seek {
        background: linear-gradient(90deg, #444 0%, #555 100%);
    }
    
    .wc-midi-loading {
        background: rgba(44, 44, 44, 0.98);
        color: #fff;
    }
    
    .wc-midi-error {
        background: #3e2723;
        border-color: #ff6f00;
        color: #ffccbc;
    }
}

/* ============================================
   ACCESIBILIDAD
   ============================================ */

/* Modo de alto contraste */
@media (prefers-contrast: high) {
    .wc-midi-btn {
        border: 2px solid #fff;
    }
    
    .wc-midi-seek {
        border: 1px solid #333;
    }
}

/* Reducir animaciones si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
    .wc-midi-btn,
    .wc-midi-grid-btn,
    .wc-midi-seek::-webkit-slider-thumb,
    .wc-midi-seek::-moz-range-thumb {
        transition: none;
    }
    
    .wc-midi-pulse,
    .wc-midi-spinner {
        animation: none;
    }
}

/* Focus visible para teclado */
.wc-midi-btn:focus-visible,
.wc-midi-grid-btn:focus-visible,
.wc-midi-seek:focus-visible {
    outline: 3px solid var(--wc-midi-primary);
    outline-offset: 3px;
}

/* ============================================
   UTILIDADES
   ============================================ */

.wc-midi-hidden {
    display: none !important;
}

.wc-midi-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
    COMPATIBILIDAD CON THEMES ESPECÍFICOS
    ============================================ */


/* ============================================
    COMPATIBILIDAD CON THEMES POPULARES
    ============================================ */

/* Astra Theme */
.ast-woocommerce-container .wc-midi-grid-player {
    margin: 15px 0;
}

/* OceanWP */
.oceanwp-toolbar .wc-midi-grid-player {
    padding: 10px 0;
}

/* Storefront */
.storefront-product-section .wc-midi-player-single {
    margin: 25px 0;
}

/* Flatsome */
.product-small .wc-midi-grid-player {
    padding: 10px;
}

/* Divi */
.et_pb_module .wc-midi-player-single {
    margin: 20px auto;
}