/* Eko Chat Widget v0.1 */
#eko-chat-root {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Floating button */
.eko-chat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #4a8c3f 0%, #6ba85e 100%);
    color: #fff;
    border: 0;
    border-radius: 32px;
    box-shadow: 0 6px 20px rgba(74, 140, 63, 0.35);
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: transform .15s, box-shadow .15s;
}
.eko-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(74, 140, 63, 0.45);
}
.eko-chat-btn-hidden { display: none; }
.eko-chat-btn-icon { font-size: 20px; line-height: 1; }
.eko-chat-btn-label { white-space: nowrap; }

/* Panel */
.eko-chat-panel {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 80px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    flex-direction: column;
}
.eko-chat-panel.eko-chat-open { display: flex; }

/* Header */
.eko-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: linear-gradient(135deg, #4a8c3f 0%, #6ba85e 100%);
    color: #fff;
}
.eko-chat-title strong { display: block; font-size: 15px; }
.eko-chat-title small { font-size: 12px; opacity: 0.85; }
.eko-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.eko-chat-close,
.eko-chat-tts {
    background: rgba(255,255,255,0.15);
    border: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.eko-chat-close:hover,
.eko-chat-tts:hover { background: rgba(255,255,255,0.25); }
.eko-chat-tts-on { background: rgba(255, 235, 100, 0.4) !important; }

/* Messages */
.eko-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f7f8f5;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.eko-chat-msg { display: flex; }
.eko-chat-msg-user { justify-content: flex-end; }
.eko-chat-msg-bot { justify-content: flex-start; }
.eko-chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
}
.eko-chat-msg-user .eko-chat-bubble {
    background: #4a8c3f;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.eko-chat-msg-bot .eko-chat-bubble {
    background: #fff;
    color: #2c3a26;
    border: 1px solid #e8ebe3;
    border-bottom-left-radius: 4px;
}
.eko-chat-bubble a { color: inherit; text-decoration: underline; }

/* Typing indicator */
.eko-chat-typing .eko-chat-bubble {
    display: inline-flex;
    gap: 4px;
    padding: 14px 16px;
}
.eko-chat-dot {
    width: 7px;
    height: 7px;
    background: #999;
    border-radius: 50%;
    animation: eko-chat-bounce 1.4s infinite ease-in-out;
}
.eko-chat-dot:nth-child(2) { animation-delay: 0.16s; }
.eko-chat-dot:nth-child(3) { animation-delay: 0.32s; }
@keyframes eko-chat-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Form */
.eko-chat-form {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    background: #fff;
    border-top: 1px solid #e8ebe3;
}
.eko-chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #d1d8c9;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    outline: none;
}
.eko-chat-input:focus { border-color: #4a8c3f; }
.eko-chat-send,
.eko-chat-mic {
    width: 44px;
    height: 44px;
    background: #4a8c3f;
    color: #fff;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.eko-chat-mic {
    background: #6c7a64;
    font-size: 18px;
}
.eko-chat-send:hover { background: #3d7434; }
.eko-chat-mic:hover { background: #5a6754; }
.eko-chat-send:disabled,
.eko-chat-mic:disabled { background: #bcc6b3; cursor: wait; }
.eko-chat-mic-active {
    background: #d9534f !important;
    animation: eko-chat-pulse 1.2s infinite;
}
@keyframes eko-chat-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(217, 83, 79, 0.6); }
    50%      { box-shadow: 0 0 0 8px rgba(217, 83, 79, 0); }
}

/* Compact paragraph spacing in bot bubbles */
.eko-chat-msg-bot .eko-chat-bubble strong { font-weight: 600; }
.eko-chat-msg-bot .eko-chat-bubble br + br { display: none; }

/* Footer */
.eko-chat-footer {
    padding: 10px 14px;
    background: #f7f8f5;
    border-top: 1px solid #e8ebe3;
    font-size: 11px;
    color: #768170;
    text-align: center;
}
.eko-chat-clear {
    background: none;
    border: 0;
    color: #4a8c3f;
    text-decoration: underline;
    cursor: pointer;
    font-size: 11px;
    padding: 0;
}

/* Mobile */
@media (max-width: 480px) {
    .eko-chat-panel {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 10px;
        height: calc(100vh - 20px);
        max-height: calc(100vh - 20px);
        border-radius: 12px;
    }
    .eko-chat-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
}
