:root {
    --primary-color: #10a37f;
    --primary-dark: #0d8a6d;
    --bg-color: #f7f7f8;
    --chat-bg: #ffffff;
    --sidebar-bg: #f0f2f5;
    --user-msg: #10a37f;
    --assistant-msg: #ffffff;
    --text-color: #333333;
    --border-color: #e5e5e6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    color: var(--text-color);
}

.chat-launcher {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: all 0.3s ease;
}

.chat-launcher:hover {
    background-color: var(--primary-dark);
    transform: scale(1.05);
}

.chat-popup-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background-color: var(--chat-bg);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1001;
}

.chat-popup-container.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.chat-header {
    background-color: var(--primary-color);
    color: white;
    padding: 0 15px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 10;
}

.menu-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    flex-shrink: 0;
}

.thread-info {
    flex: 1;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 5px;
    height: 100%;
    display: flex;
    align-items: center;
    margin-top: 5px;
}

.close-chat-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    flex-shrink: 0;
}

.sidebar {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background-color: var(--sidebar-bg);
    transition: left 0.3s ease;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--primary-color);
    color: white;
}

.sidebar-header h3 {
    font-size: 1.1rem;
    font-weight: 500;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: white;
}

.threads-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.thread-item {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    flex-direction: column;
    background-color: white;
    border: 1px solid var(--border-color);
}

.thread-item:hover {
    background-color: rgba(0,0,0,0.05);
}

.thread-item.active {
    background-color: var(--primary-color);
    color: white;
}

.thread-title {
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-date {
    font-size: 0.8rem;
    opacity: 0.7;
}

.new-thread {
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding: 12px 15px;
    border: none;
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 120px;
}

.message {
    max-width: 95%;
    padding: 12px 16px;
    border-radius: 8px;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(10px);
    animation: messageAppear 0.3s forwards;
    word-wrap: break-word;
}

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

.user-message {
    align-self: flex-end;
    background-color: var(--user-msg);
    color: white;
}

.assistant-message {
    align-self: flex-start;
    background-color: var(--assistant-msg);
    border: 1px solid var(--border-color);
}

.chat-input {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    width: 100%;
}

.voice-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    min-width: 50px;
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.voice-btn.recording {
    background-color: #d32f2f;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.voice-status {
    font-size: 0.8rem;
    color: #666;
    padding: 5px 0;
    text-align: center;
    height: 20px;
    margin-top: 5px;
}

.chat-input textarea {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    resize: none;
    min-height: 50px;
    max-height: 150px;
    min-width: 50%;
    font-family: inherit;
    font-size: 1.3rem;
    background-color: var(--bg-color);
    outline: none;
    width: calc(100% - 108px);
}

#send-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    min-width: 50px;
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
}

#send-button-mobile {
    display: none;
    width: 100%;
    margin: 10px 0 0;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
}

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 8px 0;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #666;
    border-radius: 50%;
    animation: bounce 1s infinite ease-in-out;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.typewriter-cursor::after {
    content: '|';
    animation: blink 0.7s infinite;
}

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

.error {
    color: #d32f2f;
    background-color: #fde8e8 !important;
    border-color: #f5c6cb !important;
}

@media (max-width: 768px) {
    .chat-popup-container {
        width: calc(100% - 40px);
        right: 20px;
        bottom: 20px;
        height: 70vh;
    }
    
    .chat-launcher {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .chat-input textarea {
        width: calc(100% - 48px);
    }
    
    #send-button {
        display: none;
    }
    
    #send-button-mobile {
        display: block;
    }
    
    .message {
        max-width: 90%;
    }
    
    .input-wrapper {
        gap: 6px;
    }
}