/* =============================================================
   Invekto WebChat Widget - Standalone CSS (BEM naming)
   Does not depend on Tailwind
   ============================================================= */

:root {
    --iwc-primary: #E54C4C;
    --iwc-primary-dark: #c93a3a;
    --iwc-visitor-bg: #f3f4f6;
    --iwc-operator-bg: #dbeafe;
    --iwc-ai-bg: #ede9fe;
    --iwc-text: #111827;
    --iwc-text-light: #6b7280;
    --iwc-border: #e5e7eb;
    --iwc-white: #ffffff;
    --iwc-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    --iwc-radius: 16px;
}

/* ── Bubble ── */
.iwc-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--iwc-primary);
    color: var(--iwc-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(229, 76, 76, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 99998;
}
.iwc-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(229, 76, 76, 0.5);
}
.iwc-bubble svg {
    width: 28px;
    height: 28px;
    fill: var(--iwc-white);
}
.iwc-bubble__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid var(--iwc-white);
    display: none;
}
.iwc-bubble__badge--online {
    display: block;
}

/* ── Window ── */
.iwc-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: var(--iwc-white);
    border-radius: var(--iwc-radius);
    box-shadow: var(--iwc-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.iwc-window--open {
    display: flex;
}

/* ── Header ── */
.iwc-header {
    background: var(--iwc-primary);
    color: var(--iwc-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.iwc-header__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}
.iwc-header__info {
    flex: 1;
}
.iwc-header__title {
    font-weight: 600;
    font-size: 15px;
    margin: 0;
}
.iwc-header__status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}
.iwc-header__status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #86efac;
}
.iwc-header__status-dot--offline {
    background: rgba(255, 255, 255, 0.4);
}
.iwc-header__close {
    background: none;
    border: none;
    color: var(--iwc-white);
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.15s;
}
.iwc-header__close:hover {
    opacity: 1;
}
.iwc-header__close svg {
    width: 20px;
    height: 20px;
}

/* ── Pre-chat form ── */
.iwc-prechat {
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    justify-content: center;
}
.iwc-prechat__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--iwc-text);
    margin: 0 0 4px 0;
}
.iwc-prechat__desc {
    font-size: 13px;
    color: var(--iwc-text-light);
    margin: 0 0 8px 0;
}
.iwc-prechat input {
    padding: 10px 14px;
    border: 1px solid var(--iwc-border);
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.iwc-prechat input:focus {
    border-color: var(--iwc-primary);
}
.iwc-prechat__btn {
    padding: 12px;
    background: var(--iwc-primary);
    color: var(--iwc-white);
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 4px;
}
.iwc-prechat__btn:hover {
    background: var(--iwc-primary-dark);
}

/* ── Messages ── */
.iwc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.iwc-messages::-webkit-scrollbar {
    width: 4px;
}
.iwc-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

/* ── Message bubble ── */
.iwc-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--iwc-text);
    word-wrap: break-word;
}
.iwc-msg--visitor {
    background: var(--iwc-visitor-bg);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.iwc-msg--operator {
    background: var(--iwc-operator-bg);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.iwc-msg--ai {
    background: var(--iwc-ai-bg);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.iwc-msg__label {
    font-size: 11px;
    color: var(--iwc-text-light);
    margin-bottom: 3px;
}
.iwc-msg__time {
    font-size: 11px;
    color: var(--iwc-text-light);
    margin-top: 3px;
    text-align: right;
}

/* ── Typing indicator ── */
.iwc-typing {
    align-self: flex-start;
    display: none;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--iwc-visitor-bg);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.iwc-typing--active {
    display: flex;
}
.iwc-typing__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    animation: iwc-bounce 1.4s infinite both;
}
.iwc-typing__dot:nth-child(2) { animation-delay: 0.16s; }
.iwc-typing__dot:nth-child(3) { animation-delay: 0.32s; }

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

/* ── Input bar ── */
.iwc-input {
    padding: 12px 16px;
    border-top: 1px solid var(--iwc-border);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    background: var(--iwc-white);
}
.iwc-input__field {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--iwc-border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}
.iwc-input__field:focus {
    border-color: var(--iwc-primary);
}
.iwc-input__send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--iwc-primary);
    color: var(--iwc-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}
.iwc-input__send:hover {
    background: var(--iwc-primary-dark);
}
.iwc-input__send:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}
.iwc-input__send svg {
    width: 18px;
    height: 18px;
}

/* ── Mobile responsive ── */
@media (max-width: 640px) {
    .iwc-window {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    .iwc-bubble {
        bottom: 16px;
        right: 16px;
    }
}
