/**
 * ElevenLabs Voice Assistant - Frontend Styles
 */

/* Base Styles */
#elva-chat-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Chat Button */
.elva-chat-button {
    position: relative;
    width: 60px;
    height: 60px;
    background: var(--elva-primary-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--elva-shadow);
    transition: var(--elva-transition);
    overflow: hidden;
    user-select: none;
}

.elva-chat-button:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--elva-shadow-hover);
}

.elva-chat-button.elva-active {
    background: #e74c3c;
}

.elva-chat-button.elva-active .elva-microphone-icon {
    display: none;
}

.elva-chat-button.elva-active .elva-close-icon {
    display: block !important;
}

/* Button Icon */
.elva-button-icon {
    position: relative;
    z-index: 2;
    transition: var(--elva-transition);
}

.elva-button-icon svg {
    transition: var(--elva-transition);
}

.elva-chat-button:hover .elva-button-icon {
    transform: scale(1.1);
}

/* Pulse Animation */
.elva-button-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border: 2px solid var(--elva-primary-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: elva-pulse 2s infinite;
    opacity: 0.6;
}

@keyframes elva-pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.3;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.4);
        opacity: 0;
    }
}

/* Tooltip */
.elva-button-tooltip {
    position: absolute;
    bottom: 70px;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--elva-transition);
    pointer-events: none;
    z-index: 2;
}

.elva-button-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 20px;
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.8);
}

.elva-chat-button:hover .elva-button-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Chat Panel */
.elva-chat-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: var(--elva-border-radius);
    box-shadow: var(--elva-shadow-hover);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.8) translateY(20px);
    transform-origin: bottom right;
    transition: var(--elva-transition);
    opacity: 0;
    backdrop-filter: saturate(120%) blur(2px);
}

.elva-widget-bottom-left .elva-chat-panel {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.elva-widget-top-right .elva-chat-panel {
    bottom: auto;
    top: 80px;
    transform-origin: top right;
}

.elva-widget-top-left .elva-chat-panel {
    bottom: auto;
    top: 80px;
    right: auto;
    left: 0;
    transform-origin: top left;
}

.elva-chat-panel.elva-open {
    display: flex;
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Chat Header */
.elva-chat-header {
    background: linear-gradient(135deg, var(--elva-primary-color), rgba(var(--elva-primary-rgb), 0.8));
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.elva-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.elva-header-content {
    flex: 1;
}

.elva-header-content h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.elva-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.elva-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    animation: elva-online-pulse 2s infinite;
}

@keyframes elva-online-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.elva-minimize-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--elva-transition);
}

.elva-minimize-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Container */
.elva-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

.elva-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.elva-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.elva-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

/* Message */
.elva-message {
    display: flex;
    gap: 8px;
    animation: elva-message-in 0.3s ease-out;
}

@keyframes elva-message-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.elva-user-message {
    flex-direction: row-reverse;
}

.elva-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 4px;
}

.elva-bot-message .elva-message-avatar {
    background: var(--elva-primary-color);
    color: white;
}

.elva-user-message .elva-message-avatar {
    background: #6c757d;
    color: white;
}

.elva-message-content {
    flex: 1;
    max-width: 80%;
}

.elva-message-bubble {
    background: white;
    padding: 12px 16px;
    border-radius: var(--elva-border-radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    word-wrap: break-word;
    border: 1px solid rgba(0,0,0,0.04);
}

.elva-user-message .elva-message-bubble {
    background: var(--elva-primary-color);
    color: white;
}

.elva-message-text {
    display: block;
    line-height: 1.5;
}

.elva-message-actions {
    margin-top: 8px;
    display: flex;
    gap: 4px;
}

.elva-speak-btn {
    background: rgba(0, 0, 0, 0.1);
    border: none;
    color: inherit;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--elva-transition);
    opacity: 0.7;
}

.elva-speak-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.2);
}

.elva-speak-btn.elva-speaking {
    animation: elva-speaking-pulse 1.5s infinite;
}

@keyframes elva-speaking-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; transform: scale(1.1); }
}

.elva-message-time {
    font-size: 11px;
    color: #6c757d;
    margin-top: 4px;
    opacity: 0.8;
}

.elva-user-message .elva-message-time {
    text-align: right;
}

/* Typing Indicator */
.elva-typing-indicator {
    display: flex;
    gap: 8px;
    animation: elva-fade-in 0.3s ease-out;
}

@keyframes elva-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.elva-typing-content {
    flex: 1;
}

.elva-typing-bubble {
    background: white;
    padding: 12px 16px;
    border-radius: var(--elva-border-radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    width: fit-content;
}

.elva-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.elva-typing-dots span {
    width: 8px;
    height: 8px;
    background: #6c757d;
    border-radius: 50%;
    animation: elva-typing-bounce 1.4s infinite;
}

.elva-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.elva-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes elva-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Area */
.elva-chat-input {
    padding: 16px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.elva-input-container {
    display: flex;
    gap: 8px;
    align-items: center;
    background: #f8f9fa;
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    transition: var(--elva-transition);
}

.elva-input-container:focus-within {
    background: white;
    box-shadow: 0 0 0 2px rgba(var(--elva-primary-rgb), 0.2);
}

#elva-message-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 14px;
    outline: none;
    color: #333;
}

#elva-message-input::placeholder {
    color: #6c757d;
}

.elva-input-actions {
    display: flex;
    gap: 4px;
}

.elva-voice-btn,
.elva-send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--elva-transition);
    color: #6c757d;
    background: transparent;
}

.elva-voice-btn:hover,
.elva-send-btn:hover {
    background: rgba(var(--elva-primary-rgb), 0.1);
    color: var(--elva-primary-color);
}

.elva-send-btn {
    background: var(--elva-primary-color);
    color: white;
    box-shadow: 0 6px 12px rgba(var(--elva-primary-rgb), 0.25);
}

.elva-send-btn:hover {
    background: var(--elva-primary-color);
    transform: scale(1.05);
}

.elva-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.elva-voice-btn.elva-recording {
    background: #e74c3c;
    color: white;
    animation: elva-recording-pulse 1s infinite;
}

@keyframes elva-recording-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.elva-voice-btn.elva-recording .elva-mic-icon {
    display: none;
}

.elva-voice-btn.elva-recording .elva-recording-icon {
    display: block !important;
}

/* Voice Indicator */
.elva-voice-indicator {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 20px;
    color: #e74c3c;
    font-size: 12px;
    font-weight: 500;
}

.elva-voice-wave {
    display: flex;
    gap: 2px;
    align-items: center;
}

.elva-voice-wave span {
    width: 3px;
    height: 12px;
    background: #e74c3c;
    border-radius: 2px;
    animation: elva-voice-wave-animation 1.2s infinite;
}

.elva-voice-wave span:nth-child(2) { animation-delay: 0.1s; }
.elva-voice-wave span:nth-child(3) { animation-delay: 0.2s; }
.elva-voice-wave span:nth-child(4) { animation-delay: 0.3s; }
.elva-voice-wave span:nth-child(5) { animation-delay: 0.4s; }

@keyframes elva-voice-wave-animation {
    0%, 100% {
        height: 4px;
        opacity: 0.5;
    }
    50% {
        height: 12px;
        opacity: 1;
    }
}

/* Powered By */
.elva-powered-by {
    padding: 8px 16px;
    background: #f8f9fa;
    text-align: center;
    font-size: 11px;
    color: #6c757d;
    border-top: 1px solid #e9ecef;
}

.elva-powered-by strong {
    color: var(--elva-primary-color);
}

/* Welcome Message Animation */
.elva-welcome-message {
    animation: elva-welcome-bounce 0.6s ease-out;
}

@keyframes elva-welcome-bounce {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    60% {
        opacity: 1;
        transform: translateY(-5px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .elva-chat-panel {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 10px;
    }
    
    .elva-widget-bottom-left .elva-chat-panel {
        left: 10px;
        right: auto;
    }
    
    .elva-chat-button {
        width: 56px;
        height: 56px;
    }
    
    .elva-button-tooltip {
        display: none;
    }
}

@media (max-width: 480px) {
    .elva-chat-panel {
        width: calc(100vw - 10px);
        height: calc(100vh - 90px);
        bottom: 70px;
        right: 5px;
    }
    
    .elva-widget-bottom-left .elva-chat-panel {
        left: 5px;
        right: auto;
    }
    
    .elva-message-content {
        max-width: 85%;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .elva-chat-button,
    .elva-chat-panel,
    .elva-message,
    .elva-button-icon,
    .elva-button-tooltip {
        animation: none;
        transition: none;
    }
    
    .elva-button-pulse {
        display: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .elva-chat-panel {
        border: 2px solid #000;
    }
    
    .elva-message-bubble {
        border: 1px solid #000;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .elva-chat-panel {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .elva-chat-messages {
        background: #4a5568;
    }
    
    .elva-message-bubble {
        background: #2d3748;
        color: #e2e8f0;
        border: 1px solid #4a5568;
    }
    
    .elva-user-message .elva-message-bubble {
        background: var(--elva-primary-color);
        color: white;
    }
    
    .elva-input-container {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .elva-input-container:focus-within {
        background: #2d3748;
    }
    
    #elva-message-input {
        color: #e2e8f0;
    }
    
    #elva-message-input::placeholder {
        color: #a0aec0;
    }
    
    .elva-chat-input {
        background: #2d3748;
        border-top-color: #4a5568;
    }
    
    .elva-powered-by {
        background: #4a5568;
        color: #a0aec0;
        border-top-color: #4a5568;
    }
}
