/* =========================================================================
   JeeChat AI - Chat Widget Styles
   ========================================================================= */

:root {
    --jeechat-primary: #6C63FF;
    --jeechat-primary-dark: #5a52d5;
    --jeechat-bg: #ffffff;
    --jeechat-msg-bg: #f0f2f5;
    --jeechat-text: #1a1a2e;
    --jeechat-text-light: #6b7280;
    --jeechat-border: #e5e7eb;
    --jeechat-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    --jeechat-radius: 16px;
}

/* Toggle Button */
.jeechat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--jeechat-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(108, 99, 255, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 99999;
}

.jeechat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(108, 99, 255, 0.5);
}

.jeechat-toggle:active {
    transform: scale(0.95);
}

.jeechat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* Chat Window */
.jeechat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--jeechat-bg);
    border-radius: var(--jeechat-radius);
    box-shadow: var(--jeechat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99998;
    animation: jeechat-slideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--jeechat-border);
}

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

/* Header */
.jeechat-header {
    background: var(--jeechat-primary);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.jeechat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.jeechat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.jeechat-header-name {
    font-weight: 700;
    font-size: 15px;
    display: block;
}

.jeechat-header-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 4px;
}

.jeechat-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

.jeechat-minimize {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.jeechat-minimize:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Messages Area */
.jeechat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.jeechat-messages::-webkit-scrollbar {
    width: 5px;
}

.jeechat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.jeechat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

/* Message Bubbles */
.jeechat-msg {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: jeechat-fadeIn 0.3s ease;
}

@keyframes jeechat-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.jeechat-msg-user {
    align-self: flex-end;
}

.jeechat-msg-bot {
    align-self: flex-start;
}

.jeechat-msg-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}

.jeechat-msg-user .jeechat-msg-bubble {
    background: var(--jeechat-primary);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.jeechat-msg-bot .jeechat-msg-bubble {
    background: var(--jeechat-msg-bg);
    color: var(--jeechat-text);
    border-bottom-left-radius: 6px;
}

.jeechat-msg-time {
    font-size: 11px;
    color: var(--jeechat-text-light);
    margin-top: 4px;
    padding: 0 4px;
}

.jeechat-msg-user .jeechat-msg-time {
    text-align: right;
}

/* Typing Indicator */
.jeechat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
    background: var(--jeechat-msg-bg);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    width: fit-content;
}

.jeechat-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: jeechat-bounce 1.4s infinite ease-in-out;
}

.jeechat-typing-dot:nth-child(1) { animation-delay: 0s; }
.jeechat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.jeechat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes jeechat-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input Area */
.jeechat-input-area {
    padding: 12px 16px 10px;
    border-top: 1px solid var(--jeechat-border);
    flex-shrink: 0;
    background: var(--jeechat-bg);
}

.jeechat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--jeechat-msg-bg);
    border-radius: 24px;
    padding: 6px 6px 6px 16px;
    transition: box-shadow 0.2s;
}

.jeechat-input-wrap:focus-within {
    box-shadow: 0 0 0 2px var(--jeechat-primary), 0 0 0 4px rgba(108, 99, 255, 0.15);
}

.jeechat-input-field {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 14px;
    line-height: 1.45;
    max-height: 100px;
    color: var(--jeechat-text);
    font-family: inherit;
    padding: 8px 0;
    outline: none;
}

.jeechat-input-field::placeholder {
    color: var(--jeechat-text-light);
}

.jeechat-send-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: var(--jeechat-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.jeechat-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

.jeechat-send-btn:not(:disabled):hover {
    background: var(--jeechat-primary-dark);
    transform: scale(1.05);
}

.jeechat-powered {
    text-align: center;
    font-size: 11px;
    color: var(--jeechat-text-light);
    padding-top: 8px;
    opacity: 0.7;
}

/* Markdown-like formatting in bot messages */
.jeechat-msg-bot .jeechat-msg-bubble strong,
.jeechat-msg-bot .jeechat-msg-bubble b {
    font-weight: 700;
}

.jeechat-msg-bot .jeechat-msg-bubble a {
    color: var(--jeechat-primary);
    text-decoration: underline;
}

.jeechat-msg-bot .jeechat-msg-bubble code {
    background: rgba(0,0,0,0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.jeechat-msg-bot .jeechat-msg-bubble ul,
.jeechat-msg-bot .jeechat-msg-bubble ol {
    padding-left: 18px;
    margin: 6px 0;
}

.jeechat-msg-bot .jeechat-msg-bubble p {
    margin: 0 0 8px 0;
}

.jeechat-msg-bot .jeechat-msg-bubble p:last-child {
    margin-bottom: 0;
}

/* Error message */
.jeechat-msg-error .jeechat-msg-bubble {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .jeechat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .jeechat-toggle {
        bottom: 16px;
        right: 16px;
    }
}
