/* LingoTreiner AI Chat Widget Styles */

/* Floating Chat Button */
.btn-lingotreiner {
    position: fixed;
    bottom: 120px;
    /* Above WhatsApp button */
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #9900CC, #FE00F9);
    box-shadow: 0 4px 15px rgba(153, 0, 204, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: all 0.3s ease;
    border: 3px solid rgba(255, 255, 255, 0.3);
    animation: float 3s ease-in-out infinite, pulse-glow 2s infinite;
}

.btn-lingotreiner:hover {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(254, 0, 249, 0.8), 0 0 60px rgba(153, 0, 204, 0.4);
    animation-play-state: paused;
    /* Pause animation on hover */
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(254, 0, 249, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(254, 0, 249, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(254, 0, 249, 0);
    }
}

.btn-lingotreiner img {
    width: 70%;
    height: 70%;
    border-radius: 50%;
}

.btn-lingotreiner .chat-icon {
    font-size: 28px;
    color: white;
}

/* Notification badge */
.btn-lingotreiner .notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #99ff00;
    color: #333;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat Window Container */
.lingotreiner-chat-container {
    position: fixed;
    bottom: 190px;
    /* Above buttons */
    right: 20px;
    width: 380px;
    height: 550px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(249, 240, 255, 0.95));
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(153, 0, 204, 0.3);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 2px solid rgba(153, 0, 204, 0.2);
    animation: slideUp 0.3s ease-out;
}

.lingotreiner-chat-container.active {
    display: flex;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #9900CC, #FE00F9);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 20px 20px 0 0;
    color: white;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-container {
    position: relative;
    width: 50px;
    height: 50px;
}

.avatar-container img,
.avatar-container svg {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.5);
}

.avatar-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #99ff00;
    border-radius: 50%;
    border: 2px solid white;
}

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

.chat-header-info p {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

.btn-close-chat {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-close-chat:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.5), rgba(249, 240, 255, 0.5));
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(153, 0, 204, 0.1);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(153, 0, 204, 0.3);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(153, 0, 204, 0.5);
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: fadeInMessage 0.3s ease-out;
}

@keyframes fadeInMessage {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.ai {
    align-self: flex-start;
}

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #99ff00, #9c3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.message.ai .message-avatar {
    border: 2px solid #9900CC;
}

.message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.message.user .message-content {
    background: linear-gradient(135deg, #9900CC, #FE00F9);
    color: white;
    border-radius: 18px 18px 4px 18px;
}

.message.ai .message-content {
    background: white;
    color: #333;
    border-radius: 18px 18px 18px 4px;
    border: 1px solid rgba(153, 0, 204, 0.1);
}

.message-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.btn-speak-msg {
    background: none;
    border: none;
    color: #9900CC;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    transition: transform 0.2s;
}

.btn-speak-msg:hover {
    transform: scale(1.2);
}

.message-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #9900CC;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

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

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

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-10px);
    }
}


/* Chat Input Area */
.chat-input-area {
    position: relative;
    /* Anchor for progress bar */
    padding: 10px 15px;
    /* Reduced padding */
    background: white;
    border-top: 1px solid rgba(153, 0, 204, 0.1);
    display: flex;
    gap: 8px;
    /* Reduced gap */
    align-items: center;
    flex-wrap: nowrap;
    /* Prevent wrapping */
}

.chat-input {
    flex: 1;
    border: 2px solid rgba(153, 0, 204, 0.2);
    border-radius: 30px !important;
    padding: 8px !important;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: 'Poppins', sans-serif;
    max-width: 250px !important;
    border-color: #de9cff !important;
}

.chat-input:focus {
    border-color: #9900CC !important;
}

/* Audio Recording Styles */
.btn-chat-action {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f0f0f0 !important;
    border: none;
    color: #666 !important;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-chat-action:disabled {
    cursor: not-allowed;
    opacity: 0.7;
    background: #e0e0e0 !important;
    color: #999 !important;
    font-weight: bold;
    font-size: 14px;
    /* Slightly smaller for numbers */
}

.btn-chat-action.cooldown {
    border: 2px solid #ccc;
    /* Visual indicator of cooldown */
}

/* Recording Progress Bar */
.recording-progress-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    overflow: hidden;
    display: none;
    /* Shown during recording */
    z-index: 5;
}

.recording-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #9900CC, #FE00F9);
    transition: width 0.1s linear;
}

.btn-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #9900CC, #FE00F9) !important;
    border: none;
    color: white !important;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(153, 0, 204, 0.3);
    flex-shrink: 0;
}

.btn-chat-action:hover {
    background: #e0e0e0 !important;
    color: #9900CC !important;
    transform: scale(1.05);
}

.btn-chat-action.recording {
    background: #ffecfc;
    color: #ff0000;
    animation: pulseRed 1.5s infinite;
}

@keyframes pulseRed {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(255, 0, 0, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0);
    }
}

#audio-visualizer {
    flex: 1;
    height: 40px;
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: #f8f8f8;
    border-radius: 20px;
    padding: 0 10px;
}

.visualizer-bar {
    width: 4px;
    background: #9900CC;
    border-radius: 2px;
    animation: soundWave 0s infinite;
    /* Controlled by JS */
    min-height: 4px;
}

.btn-play-audio-msg {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    cursor: pointer;
    font-size: 12px;
    vertical-align: middle;
    transition: all 0.2s;
}

.btn-play-audio-msg:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 30px 20px;
    color: #666;
}

.welcome-message h4 {
    color: #9900CC;
    margin-bottom: 10px;
}

.welcome-message p {
    font-size: 14px;
    margin: 5px 0;
}

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
}

.quick-action-btn {
    background: white;
    border: 2px solid #9900CC;
    color: #9900CC;
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-action-btn:hover {
    background: #9900CC;
    color: white;
}

/* Responsive Design */
@media only screen and (max-width: 480px) {
    .lingotreiner-chat-container {
        width: calc(100vw - 1px);
        height: calc(100vh - 100px);
        right: 0px;
        bottom: 0px;
    }

    .btn-lingotreiner {
        right: 10px;
        bottom: 100px;
    }
}

/* Avatar Animation States */
.avatar-container.speaking .avatar-mouth {
    animation: mouthMove 0.3s infinite;
}

@keyframes mouthMove {

    0%,
    100% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(1.5);
    }
}

.avatar-container.thinking {
    animation: thinkingPulse 1s infinite;
}

@keyframes thinkingPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}