/**
 * VMO AI Voice - Jarvis-Style Floating Chat Panel
 * Bottom-left corner floating panel with chat history and voice controls
 */

.vmo-ai-voice-panel {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 320px;
    background: linear-gradient(135deg, #0a2540 0%, #0f3460 100%);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    max-height: 600px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.vmo-ai-voice-panel.collapsed {
    max-height: 60px;
    overflow: hidden;
}

.vmo-ai-voice-panel.collapsed .vmo-voice-status,
.vmo-ai-voice-panel.collapsed .vmo-voice-chat-history,
.vmo-ai-voice-panel.collapsed .vmo-voice-text-input-container,
.vmo-ai-voice-panel.collapsed .vmo-voice-attachment-preview,
.vmo-ai-voice-panel.collapsed .vmo-voice-input-controls,
.vmo-ai-voice-panel.collapsed .vmo-voice-start-btn,
.vmo-ai-voice-panel.collapsed .vmo-voice-note {
    display: none;
}

/* Header */
.vmo-voice-header {
    background: linear-gradient(135deg, #00ffff 0%, #0088cc 100%);
    padding: 12px 16px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
}

.vmo-voice-title {
    font-weight: 600;
    font-size: 14px;
    color: #0a2540;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.vmo-voice-collapse {
    background: rgba(0, 0, 0, 0.2);
    border: none;
    color: #0a2540;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: all 0.2s;
}

.vmo-voice-collapse:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Status */
.vmo-voice-status {
    padding: 10px 16px;
    text-align: center;
    font-size: 12px;
    color: #00ffff;
    background: rgba(0, 255, 255, 0.1);
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
}

/* Chat History */
.vmo-voice-chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    min-height: 200px;
    max-height: 350px;
    background: rgba(0, 0, 0, 0.3);
}

.vmo-voice-chat-history::-webkit-scrollbar {
    width: 6px;
}

.vmo-voice-chat-history::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.vmo-voice-chat-history::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 255, 0.3);
    border-radius: 3px;
}

.vmo-voice-chat-history::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 255, 0.5);
}

/* Chat Messages */
.vmo-voice-message {
    margin-bottom: 12px;
    animation: slideInMessage 0.3s ease-out;
}

@keyframes slideInMessage {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.vmo-voice-message.user {
    text-align: right;
}

.vmo-voice-message.ai {
    text-align: left;
}

.vmo-voice-message-content {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 85%;
    word-wrap: break-word;
    font-size: 13px;
    line-height: 1.4;
}

.vmo-voice-message.ai .vmo-voice-message-content {
    background: rgba(0, 255, 255, 0.2);
    color: #00ffff;
    border: 1px solid rgba(0, 255, 255, 0.3);
}

.vmo-voice-message.user .vmo-voice-message-content {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.vmo-voice-message.system .vmo-voice-message-content {
    background: rgba(255, 165, 0, 0.2);
    color: #ffaa00;
    border: 1px solid rgba(255, 165, 0, 0.3);
    text-align: center;
    font-size: 12px;
    font-style: italic;
}

.vmo-voice-message-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
}

/* Text Input Container */
.vmo-voice-text-input-container {
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(0, 255, 255, 0.2);
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.vmo-voice-text-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 8px;
    padding: 10px 12px;
    color: #ffffff;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    resize: none;
    transition: all 0.2s;
    min-height: 42px;
    max-height: 120px;
}

.vmo-voice-text-input:focus {
    outline: none;
    border-color: #00ffff;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.2);
}

.vmo-voice-text-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.vmo-voice-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    background: rgba(0, 255, 255, 0.2);
    color: #00ffff;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.vmo-voice-send-btn:hover {
    background: rgba(0, 255, 255, 0.3);
    border-color: #00ffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 255, 0.4);
}

.vmo-voice-send-btn:active {
    transform: translateY(0);
}

.vmo-voice-send-btn svg {
    width: 16px;
    height: 16px;
}

.vmo-voice-attachment-preview {
    display: grid;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.24);
    border-top: 1px solid rgba(0, 255, 255, 0.2);
}

.vmo-voice-attachment-chip {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 24px;
    align-items: center;
    gap: 8px;
    padding: 7px;
    border: 1px solid rgba(0, 255, 255, 0.28);
    border-radius: 8px;
    background: rgba(0, 255, 255, 0.08);
}

.vmo-voice-attachment-thumb {
    width: 42px;
    height: 42px;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 255, 255, 0.12);
    color: #00ffff;
    font-size: 10px;
    font-weight: 700;
}

.vmo-voice-attachment-thumb img,
.vmo-voice-attachment-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vmo-voice-attachment-label {
    min-width: 0;
    display: grid;
    gap: 2px;
    color: #fff;
    font-size: 12px;
}

.vmo-voice-attachment-label strong,
.vmo-voice-attachment-label span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vmo-voice-attachment-label span {
    color: rgba(255, 255, 255, 0.62);
    font-size: 10px;
}

.vmo-voice-attachment-remove {
    width: 24px;
    height: 24px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    line-height: 1;
}

.vmo-voice-attachment-remove:hover {
    border-color: #00ffff;
    color: #00ffff;
}

/* Input Controls */
.vmo-voice-input-controls {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(0, 255, 255, 0.2);
    justify-content: center;
}

.vmo-voice-btn {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    background: rgba(0, 255, 255, 0.1);
    color: #00ffff;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Wide buttons - same combined width as Start Voice button */
.vmo-voice-btn-wide {
    flex: 1;
    width: auto;
}

.vmo-voice-btn:hover:not(:disabled) {
    background: rgba(0, 255, 255, 0.2);
    border-color: #00ffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 255, 0.3);
}

.vmo-voice-btn:active:not(:disabled) {
    transform: translateY(0);
}

.vmo-voice-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.vmo-voice-btn svg {
    width: 18px;
    height: 18px;
}

/* Start Voice Button */
.vmo-voice-start-btn {
    margin: 12px 16px;
    padding: 14px;
    background: linear-gradient(135deg, #00ffff 0%, #0088cc 100%);
    border: none;
    border-radius: 8px;
    color: #0a2540;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0, 255, 255, 0.3);
}

.vmo-voice-start-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 255, 255, 0.5);
}

.vmo-voice-start-btn:active:not(:disabled) {
    transform: translateY(0);
}

.vmo-voice-start-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.vmo-voice-start-icon {
    font-size: 18px;
}

/* Note */
.vmo-voice-note {
    padding: 8px 16px 12px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    line-height: 1.3;
}

/* ========================================
   LISTENING MODAL (For AI Speaking)
   ======================================== */
.vmo-listening-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    /* Raise above Business Wizard (1000000+) and other UI */
    z-index: 2000000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.vmo-listening-content {
    text-align: center;
    max-width: 600px;
    padding: 40px;
}

.vmo-listening-icon {
    margin-bottom: 24px;
}

.vmo-sound-wave {
    width: 120px;
    height: 120px;
    margin: 0 auto;
    border-radius: 50%;
    background: linear-gradient(135deg, #00ffff 0%, #0088cc 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    animation: pulse 2s infinite;
}

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

.vmo-sound-wave::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #00ffff;
    animation: ripple 2s infinite;
}

@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.vmo-listening-text {
    font-size: 32px;
    font-weight: 600;
    color: #00ffff;
    margin-bottom: 16px;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

.vmo-listening-transcript {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
    min-height: 60px;
    padding: 20px;
    background: rgba(0, 255, 255, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    max-width: 500px;
    margin: 0 auto;
}

/* Responsive */
@media (max-width: 768px) {
    .vmo-ai-voice-panel {
        width: 280px;
        bottom: 10px;
        left: 10px;
    }
    
    .vmo-listening-content {
        padding: 20px;
    }
    
    .vmo-sound-wave {
        width: 80px;
        height: 80px;
    }
    
    .vmo-listening-text {
        font-size: 24px;
    }
    
    .vmo-listening-transcript {
        font-size: 14px;
    }
}

/* Active States */
.vmo-voice-btn.active {
    background: rgba(0, 255, 255, 0.3);
    border-color: #00ffff;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

.vmo-voice-start-btn.recording {
    background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%);
    color: white;
    animation: recordingPulse 1.5s infinite;
}

@keyframes recordingPulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(255, 68, 68, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(255, 68, 68, 0.6);
    }
}

/* Voice-synced Jarvis transcript: text waits for audio, then reveals with speech. */
.vmo-voice-message-content.vmo-voice-sync-pending {
    opacity: 0.72;
    font-style: italic;
}

.vmo-voice-message-content.vmo-voice-sync-active::after {
    content: '▌';
    display: inline-block;
    margin-left: 2px;
    animation: vmoVoiceSyncCaret 0.8s steps(1) infinite;
}

@keyframes vmoVoiceSyncCaret {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* Jarvis gear panel: default/premium voice mode selector */
.vmo-voice-settings-popover {
    position: fixed;
    z-index: 100000;
    width: 340px;
    max-width: calc(100vw - 24px);
    background: rgba(10, 14, 24, 0.98);
    color: #f4fbff;
    border: 1px solid rgba(0, 255, 255, 0.24);
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 24px rgba(0, 255, 255, 0.12);
    padding: 14px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.vmo-voice-settings-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.vmo-voice-settings-subtitle {
    margin-top: 3px;
    color: rgba(244, 251, 255, 0.65);
    font-size: 12px;
}

.vmo-voice-settings-close {
    background: transparent;
    border: none;
    color: rgba(244, 251, 255, 0.75);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px;
}

.vmo-voice-settings-section {
    display: grid;
    gap: 8px;
    margin: 12px 0;
}

.vmo-voice-settings-label {
    color: rgba(244, 251, 255, 0.72);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.vmo-voice-mode-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.vmo-voice-mode-option.selected {
    border-color: rgba(0, 255, 255, 0.55);
    background: rgba(0, 255, 255, 0.08);
    box-shadow: 0 0 18px rgba(0, 255, 255, 0.12);
}

.vmo-voice-mode-option input {
    margin-top: 3px;
}

.vmo-voice-mode-option strong {
    display: block;
    color: #ffffff;
    font-size: 13px;
}

.vmo-voice-mode-option small {
    display: block;
    margin-top: 3px;
    color: rgba(244, 251, 255, 0.68);
    font-size: 11px;
    line-height: 1.35;
}

.vmo-voice-settings-list {
    display: grid;
    gap: 6px;
}

.vmo-voice-choice-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: rgba(244, 251, 255, 0.9);
    font-size: 13px;
}

.vmo-voice-settings-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.vmo-voice-save {
    background: linear-gradient(135deg, #00d1ff, #15ffb1);
    color: #001014;
    border: none;
    border-radius: 8px;
    padding: 7px 12px;
    cursor: pointer;
    font-weight: 800;
}
