/**
 * ESTILOS OPTIMIZADOS PARA MÓVILES - SISTEMA DE VOZ
 * Mejora la interfaz de usuario de voz en dispositivos móviles
 * Compatible con consultor-ai y botidinamix
 */

/* ========== INDICADORES DE VOZ OPTIMIZADOS PARA MÓVILES ========== */

/* Indicador principal de voz */
#mobile-voice-indicator {
    position: fixed;
    top: 15px;
    right: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 18px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    z-index: 10000;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    animation: voicePulse 2s infinite;
    transition: all 0.3s ease;
    max-width: 200px;
    text-align: center;
}

#mobile-voice-indicator.listening {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    animation: voicePulseActive 1s infinite;
}

#mobile-voice-indicator.processing {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    animation: voicePulseProcessing 1.5s infinite;
}

#mobile-voice-indicator.success {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    animation: voicePulseSuccess 0.8s ease-out;
}

#mobile-voice-indicator.error {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    animation: voiceShake 0.5s ease-out;
}

/* Animaciones de voz */
@keyframes voicePulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 12px 35px rgba(102, 126, 234, 0.6);
    }
}

@keyframes voicePulseActive {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
    }
    50% { 
        transform: scale(1.08);
        box-shadow: 0 15px 40px rgba(255, 107, 107, 0.7);
    }
}

@keyframes voicePulseProcessing {
    0%, 100% { 
        transform: scale(1) rotate(0deg);
        box-shadow: 0 8px 25px rgba(243, 156, 18, 0.4);
    }
    50% { 
        transform: scale(1.05) rotate(2deg);
        box-shadow: 0 12px 30px rgba(243, 156, 18, 0.6);
    }
}

@keyframes voicePulseSuccess {
    0% { 
        transform: scale(1);
        box-shadow: 0 8px 25px rgba(39, 174, 96, 0.4);
    }
    50% { 
        transform: scale(1.1);
        box-shadow: 0 15px 40px rgba(39, 174, 96, 0.8);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 8px 25px rgba(39, 174, 96, 0.2);
    }
}

@keyframes voiceShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

/* ========== PANEL DE CONTROL DE VOZ PARA MÓVILES ========== */

.voice-control-panel {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 25px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 9999;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-width: calc(100vw - 40px);
}

.voice-control-panel.minimal {
    bottom: auto;
    top: 70px;
    right: 15px;
    left: auto;
    transform: none;
    border-radius: 20px;
    padding: 10px 15px;
}

.voice-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.voice-button:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.voice-button.active {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    animation: voiceButtonActive 2s infinite;
}

.voice-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
}

@keyframes voiceButtonActive {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.7);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 0 15px rgba(255, 107, 107, 0);
        transform: scale(1.05);
    }
}

.voice-status-text {
    color: white;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* ========== COMANDOS RÁPIDOS PARA MÓVILES ========== */

.quick-commands-container {
    position: fixed;
    bottom: 100px;
    left: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    z-index: 9998;
    pointer-events: none;
}

.quick-command-chip {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 8px 15px;
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    pointer-events: all;
    white-space: nowrap;
}

.quick-command-chip:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.1);
}

.quick-command-chip.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
}

/* ========== BURBUJAS DE COMANDOS DE VOZ ========== */

.voice-command-bubble {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
    backdrop-filter: blur(15px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 12px 18px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    margin: 8px 0;
    position: relative;
    animation: voiceBubbleSlide 0.4s ease-out;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.voice-command-bubble.user {
    background: linear-gradient(135deg, rgba(0, 31, 63, 0.9) 0%, rgba(0, 55, 100, 0.9) 100%);
    margin-left: auto;
    margin-right: 0;
    max-width: 80%;
    border-radius: 20px 20px 5px 20px;
}

.voice-command-bubble.system {
    background: linear-gradient(135deg, rgba(46, 213, 115, 0.9) 0%, rgba(39, 174, 96, 0.9) 100%);
    margin-left: 0;
    margin-right: auto;
    max-width: 80%;
    border-radius: 20px 20px 20px 5px;
}

.voice-command-bubble.error {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.9) 0%, rgba(238, 90, 36, 0.9) 100%);
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    border-radius: 20px;
}

@keyframes voiceBubbleSlide {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ========== PANEL DE AJUSTES DE VOZ ========== */

.voice-settings-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 25px;
    z-index: 10001;
    max-width: 350px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.voice-settings-panel h3 {
    color: white;
    margin: 0 0 20px 0;
    font-size: 18px;
    text-align: center;
    font-weight: 600;
}

.voice-setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    transition: background 0.3s ease;
}

.voice-setting-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.voice-setting-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 500;
}

.voice-setting-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.voice-toggle {
    width: 50px;
    height: 26px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
}

.voice-toggle.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.voice-toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.voice-toggle.active .voice-toggle-slider {
    transform: translateX(24px);
}

.voice-select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 6px 10px;
    color: white;
    font-size: 12px;
    cursor: pointer;
}

.voice-select option {
    background: #1a1a2e;
    color: white;
}

/* ========== INDICADOR DE PROGRESO DE VOZ ========== */

.voice-progress-indicator {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(0, 0, 0, 0.3);
    z-index: 10002;
}

.voice-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.8);
}

/* ========== MODO AHORRO DE BATERÍA ========== */

.battery-saver-mode .voice-control-panel {
    background: rgba(0, 0, 0, 0.7);
    border-color: rgba(255, 255, 255, 0.05);
}

.battery-saver-mode .voice-button {
    animation: none;
    box-shadow: none;
}

.battery-saver-mode #mobile-voice-indicator {
    animation: none;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.battery-saver-mode .voice-command-bubble {
    animation: none;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

/* ========== RESPONSIVE DESIGN ========== */

@media (max-width: 480px) {
    #mobile-voice-indicator {
        top: 10px;
        right: 10px;
        padding: 10px 14px;
        font-size: 12px;
        max-width: 160px;
    }
    
    .voice-control-panel {
        bottom: 15px;
        padding: 12px 15px;
        gap: 12px;
    }
    
    .voice-button {
        width: 45px;
        height: 45px;
        font-size: 16px;
    }
    
    .voice-status-text {
        font-size: 13px;
        max-width: 120px;
    }
    
    .quick-commands-container {
        bottom: 85px;
        gap: 8px;
    }
    
    .quick-command-chip {
        padding: 6px 12px;
        font-size: 11px;
    }
    
    .voice-settings-panel {
        padding: 20px;
        max-width: 320px;
    }
    
    .voice-setting-item {
        padding: 10px;
        margin-bottom: 12px;
    }
    
    .voice-setting-label {
        font-size: 13px;
    }
}

@media (max-width: 360px) {
    .voice-control-panel {
        bottom: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
    }
    
    .voice-status-text {
        display: none;
    }
    
    .quick-commands-container {
        display: none;
    }
}

/* ========== MODO PAISAJE ========== */

@media (orientation: landscape) and (max-height: 500px) {
    #mobile-voice-indicator {
        top: 10px;
    }
    
    .voice-control-panel {
        bottom: 10px;
        top: auto;
    }
    
    .quick-commands-container {
        bottom: 70px;
    }
    
    .voice-settings-panel {
        max-height: 90vh;
        top: 40%;
    }
}

/* ========== ACCESIBILIDAD ========== */

@media (prefers-reduced-motion: reduce) {
    #mobile-voice-indicator,
    .voice-button,
    .voice-command-bubble,
    .voice-setting-item {
        animation: none;
        transition: none;
    }
}

/* ========== ALTO CONTRASTE ========== */

@media (prefers-contrast: high) {
    #mobile-voice-indicator {
        background: #000;
        border: 2px solid #fff;
        color: #fff;
    }
    
    .voice-control-panel {
        background: #000;
        border: 2px solid #fff;
    }
    
    .voice-button {
        background: #fff;
        color: #000;
        border: 2px solid #000;
    }
    
    .voice-command-bubble {
        background: #000;
        border: 2px solid #fff;
        color: #fff;
    }
}

/* ========== OPTIMIZACIONES PARA PANTALLAS TÁCTILES ========== */

@media (pointer: coarse) {
    .voice-button {
        min-width: 50px;
        min-height: 50px;
    }
    
    .quick-command-chip {
        min-height: 36px;
        display: flex;
        align-items: center;
        padding: 10px 16px;
    }
    
    .voice-toggle {
        min-width: 54px;
        min-height: 28px;
    }
}

/* ========== VISUALIZADOR DE ONDAS DE VOZ ========== */

.voice-wave-visualizer {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 3px;
    z-index: 9997;
    height: 40px;
}

.voice-wave-bar {
    width: 3px;
    background: linear-gradient(to top, #667eea, #764ba2);
    border-radius: 3px;
    animation: voiceWave 0.5s ease-in-out infinite;
    transform-origin: bottom;
}

.voice-wave-bar:nth-child(1) { animation-delay: 0s; height: 10px; }
.voice-wave-bar:nth-child(2) { animation-delay: 0.1s; height: 20px; }
.voice-wave-bar:nth-child(3) { animation-delay: 0.2s; height: 15px; }
.voice-wave-bar:nth-child(4) { animation-delay: 0.3s; height: 25px; }
.voice-wave-bar:nth-child(5) { animation-delay: 0.4s; height: 18px; }

@keyframes voiceWave {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(1.5); }
}

/* ========== ESTADOS ESPECIALES ========== */

.voice-system-disconnected {
    opacity: 0.6;
    pointer-events: none;
}

.voice-system-connecting {
    animation: voiceSystemConnecting 1s infinite;
}

@keyframes voiceSystemConnecting {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.voice-system-error {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    animation: voiceSystemError 0.5s ease-out;
}

@keyframes voiceSystemError {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}