/* CodexChat Widget — variabilele sunt injectate inline din setări */

#codexchat-root * { box-sizing: border-box; margin: 0; padding: 0; font-family: var(--cc-font, inherit); }

#codexchat-root {
    --cc-primary:    #2563eb;
    --cc-secondary:  #ffffff;
    --cc-text:       #1e293b;
    --cc-bg:         #ffffff;
    --cc-radius:     16px;
    --cc-font:       inherit;
    position: fixed;
    z-index: 999999;
    bottom: 24px;
    right: 24px;
}

#codexchat-root.cc-pos-left { right: auto; left: 24px; }

/* ── Launcher ─────────────────────────────────────────────────────── */
#cc-launcher {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--cc-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,.2);
    transition: transform .2s, box-shadow .2s;
    position: relative;
    border: none;
    outline: none;
}

#cc-launcher:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,0,0,.25); }

#cc-launcher svg { width: 26px; height: 26px; fill: #fff; }

#cc-launcher-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none;
}

/* ── Chat window ──────────────────────────────────────────────────── */
#cc-window {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 340px;
    max-height: 520px;
    background: var(--cc-bg);
    border-radius: var(--cc-radius);
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: transform .2s ease, opacity .2s ease;
}

#codexchat-root.cc-pos-left #cc-window {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

#cc-window.cc-hidden {
    transform: scale(.95);
    opacity: 0;
    pointer-events: none;
}

/* ── Header ───────────────────────────────────────────────────────── */
#cc-header {
    background: var(--cc-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#cc-agent-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.3);
    overflow: hidden;
    flex-shrink: 0;
}

#cc-agent-avatar img { width: 100%; height: 100%; object-fit: cover; }
#cc-agent-avatar svg { width: 100%; height: 100%; padding: 6px; fill: #fff; }

#cc-agent-name { font-weight: 600; font-size: 14px; }
#cc-agent-status { font-size: 11px; opacity: .8; }

#cc-close-btn {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,.7);
    font-size: 20px;
    line-height: 1;
    padding: 2px 4px;
    transition: color .15s;
}

#cc-close-btn:hover { color: #fff; }

/* ── Pre-chat form ────────────────────────────────────────────────── */
#cc-prechat {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

#cc-prechat h3 { font-size: 15px; color: var(--cc-text); margin-bottom: 12px; }

.cc-input-group { margin-bottom: 12px; }
.cc-input-group label { display: block; font-size: 12px; color: #6b7280; margin-bottom: 4px; }
.cc-input-group input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: var(--cc-text);
    outline: none;
    transition: border-color .15s;
}

.cc-input-group input:focus { border-color: var(--cc-primary); }

#cc-prechat-submit {
    width: 100%;
    padding: 10px;
    background: var(--cc-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
}

#cc-prechat-submit:hover { opacity: .9; }

/* ── Messages ─────────────────────────────────────────────────────── */
#cc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

.cc-msg-row { display: flex; flex-direction: column; max-width: 80%; }
.cc-msg-row.visitor { align-self: flex-end; }
.cc-msg-row.agent, .cc-msg-row.bot { align-self: flex-start; }

.cc-bubble {
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--cc-text);
    word-break: break-word;
}

.visitor .cc-bubble { background: var(--cc-primary); color: #fff; border-bottom-right-radius: 4px; }
.agent .cc-bubble   { background: #f3f4f6; border-bottom-left-radius: 4px; }
.bot .cc-bubble     { background: #fef9c3; color: #713f12; border-bottom-left-radius: 4px; font-style: italic; }

.cc-msg-time { font-size: 10px; color: #9ca3af; margin-top: 2px; }
.visitor .cc-msg-time { text-align: right; }

/* Typing indicator */
.cc-typing .cc-bubble {
    display: flex;
    gap: 3px;
    align-items: center;
    padding: 10px 14px;
}

.cc-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: cc-bounce .8s infinite;
}

.cc-dot:nth-child(2) { animation-delay: .15s; }
.cc-dot:nth-child(3) { animation-delay: .3s; }

@keyframes cc-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-4px); }
}

/* ── Input ────────────────────────────────────────────────────────── */
#cc-input-area {
    padding: 10px 12px;
    border-top: 1px solid #f3f4f6;
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

#cc-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    resize: none;
    outline: none;
    max-height: 80px;
    overflow-y: auto;
    color: var(--cc-text);
    font-family: var(--cc-font, inherit);
    transition: border-color .15s;
}

#cc-input:focus { border-color: var(--cc-primary); }
#cc-input::placeholder { color: #9ca3af; }

#cc-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--cc-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-end;
    transition: opacity .15s;
}

#cc-send-btn:hover { opacity: .85; }
#cc-send-btn svg { width: 16px; height: 16px; fill: #fff; }

/* ── Branding ─────────────────────────────────────────────────────── */
#cc-branding {
    text-align: center;
    font-size: 10px;
    color: #d1d5db;
    padding: 4px 0 8px;
}

#cc-branding a { color: inherit; text-decoration: none; }
#cc-branding a:hover { color: #9ca3af; }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 400px) {
    #cc-window {
        width: calc(100vw - 24px);
        bottom: 70px;
        right: 0;
    }
}
