/* 
 * CreativeMutant Chat Widget Styles
 * Widget embebible para asistentes de IA
 */

/* Reset básico para el widget */
#cm-widget-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Contenedor principal del widget */
#cm-widget-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    z-index: 999999;
    position: fixed;
}

/* Posiciones del widget */
#cm-widget-container.position-bottom-right {
    bottom: 20px;
    right: 20px;
}

#cm-widget-container.position-bottom-left {
    bottom: 20px;
    left: 20px;
}

#cm-widget-container.position-top-right {
    top: 20px;
    right: 20px;
}

#cm-widget-container.position-top-left {
    top: 20px;
    left: 20px;
}

/* Botón flotante (burbuja) */
.cm-widget-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--cm-primary-color, #007bff);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.cm-widget-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.cm-widget-button:active {
    transform: scale(0.95);
}

/* Indicador de estado (pulsing dot) */
.cm-widget-button::before {
    content: '';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 12px;
    height: 12px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid white;
    animation: cm-pulse 2s infinite;
}

@keyframes cm-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.1); }
}

/* Ventana de voz (voice-only interface) */
.cm-voice-window {
    display: none;
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    max-height: calc(100vh - 120px);
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    flex-direction: column;
    animation: cm-slideUp 0.3s ease-out;
}

.cm-voice-window.visible {
    display: flex;
}

#cm-widget-container.position-bottom-left .cm-voice-window,
#cm-widget-container.position-top-left .cm-voice-window {
    right: auto;
    left: 0;
}

#cm-widget-container.position-top-right .cm-voice-window,
#cm-widget-container.position-top-left .cm-voice-window {
    bottom: auto;
    top: 80px;
}

.cm-voice-window.open {
    display: flex;
}

@keyframes cm-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header del chat */
.cm-chat-header {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cm-chat-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.cm-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cm-status-indicator {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: cm-pulse 2s infinite;
}

.cm-provider-selector {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    outline: none;
}

.cm-provider-selector option {
    color: #333;
    background: white;
}

/* Voice Interface Elements */
.cm-voice-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 40px 20px;
}

.cm-blob-container {
    position: relative;
    width: 240px;
    height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
}

#cm-blob-canvas {
    width: 100%;
    height: 100%;
}

#cm-status-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 40px;
    text-align: center;
}

.cm-voice-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

#cm-mic-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 32px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#cm-mic-button:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.5);
}

#cm-mic-button:active {
    transform: scale(0.95);
}

#cm-mic-button.recording {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    animation: cm-pulse-recording 1.5s infinite;
}

@keyframes cm-pulse-recording {
    0%, 100% {
        box-shadow: 0 8px 24px rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 12px 36px rgba(239, 68, 68, 0.6);
    }
}

.cm-close-button {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.cm-close-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Área de mensajes */
.cm-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
}

.cm-message {
    margin-bottom: 12px;
    animation: cm-message-appear 0.3s ease-out;
}

@keyframes cm-message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cm-message-user {
    display: flex;
    justify-content: flex-end;
}

.cm-message-assistant {
    display: flex;
    justify-content: flex-start;
}

.cm-message-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
}

.cm-message-user .cm-message-bubble {
    background: var(--cm-primary-color, #007bff);
    color: white;
    border-bottom-right-radius: 4px;
}

.cm-message-assistant .cm-message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Emociones (Hume) */
.cm-emotions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.cm-emotion-tag {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    color: #666;
}

/* Indicador de typing */
.cm-typing-indicator {
    display: none;
    padding: 10px 14px;
    background: white;
    border-radius: 12px;
    width: fit-content;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.cm-typing-indicator.active {
    display: block;
}

.cm-typing-dots {
    display: flex;
    gap: 4px;
}

.cm-typing-dots span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: cm-typing 1.4s infinite;
}

.cm-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.cm-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes cm-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.7; }
    30% { transform: translateY(-10px); opacity: 1; }
}

/* Controles de entrada */
.cm-chat-controls {
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    align-items: center;
}

.cm-mic-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--cm-primary-color, #007bff);
    background: white;
    color: var(--cm-primary-color, #007bff);
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.cm-mic-button:hover {
    background: var(--cm-primary-color, #007bff);
    color: white;
}

.cm-mic-button.recording {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
    animation: cm-pulse 1s infinite;
}

.cm-text-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.cm-text-input:focus {
    border-color: var(--cm-primary-color, #007bff);
}

.cm-send-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--cm-primary-color, #007bff);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.cm-send-button:hover {
    transform: scale(1.05);
}

.cm-send-button:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* Powered by badge */
.cm-powered-by {
    text-align: center;
    padding: 8px;
    font-size: 11px;
    color: #9ca3af;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.cm-powered-by a {
    color: var(--cm-primary-color, #007bff);
    text-decoration: none;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .cm-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        bottom: 70px;
    }
    
    #cm-widget-container.position-bottom-left .cm-chat-window,
    #cm-widget-container.position-bottom-right .cm-chat-window {
        left: 20px;
        right: 20px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .cm-chat-window {
        background: #1f2937;
    }
    
    .cm-messages-container {
        background: #111827;
    }
    
    .cm-message-assistant .cm-message-bubble {
        background: #374151;
        color: #f3f4f6;
    }
    
    .cm-chat-controls {
        background: #1f2937;
        border-top-color: #374151;
    }
    
    .cm-text-input {
        background: #374151;
        border-color: #4b5563;
        color: #f3f4f6;
    }
    
    .cm-powered-by {
        background: #1f2937;
        border-top-color: #374151;
    }
}

/* Highlighted section (when navigating via tool call) */
.cm-highlighted {
    animation: cm-highlight-pulse 2s ease-in-out;
    outline: 3px solid #667eea;
    outline-offset: 8px;
    border-radius: 8px;
}

@keyframes cm-highlight-pulse {
    0%, 100% {
        outline-color: #667eea;
        outline-width: 3px;
    }
    50% {
        outline-color: #764ba2;
        outline-width: 5px;
    }
}
