/* ==========================================================================
   INVIBROWSER — Website support chat widget
   Self-contained: every design token has a literal fallback so the widget looks
   right on pages that do not load styles.css (blog, tools).
   ========================================================================== */

.ibwc {
    --ibwc-cyan: var(--c-cyan, #00FFFF);
    --ibwc-azure: var(--c-azure, #00A3FF);
    --ibwc-base: var(--bg-base, #0E0A2E);
    --ibwc-surface: var(--bg-surface, #251E5C);
    --ibwc-elevated: var(--bg-elevated, #2D2470);
    --ibwc-border: var(--c-border, #382D82);
    --ibwc-text: var(--t-primary, #FFFFFF);
    --ibwc-muted: var(--t-muted, #A09DBA);
    --ibwc-font: var(--f-body, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);

    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    font-family: var(--ibwc-font);
    font-size: 15px;
    line-height: 1.55;
}

.ibwc *, .ibwc *::before, .ibwc *::after { box-sizing: border-box; }

/* ---------- Launcher ---------- */
.ibwc__launcher {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    margin-left: auto;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    color: #04122B;
    background: linear-gradient(135deg, #00FFFF 0%, #00A3FF 50%, #0055FF 100%);
    box-shadow: 0 8px 28px rgba(0, 255, 255, 0.35);
    transition: transform 0.18s cubic-bezier(.22,.61,.36,1);
}

.ibwc__launcher:hover { transform: translateY(-2px) scale(1.04); }
.ibwc__launcher:focus-visible { outline: 2px solid var(--ibwc-cyan); outline-offset: 3px; }
.ibwc__launcher svg { width: 26px; height: 26px; }

.ibwc__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #FF4D6D;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

.ibwc__badge[hidden] { display: none; }

/* ---------- Panel ---------- */
.ibwc__panel {
    display: flex;
    flex-direction: column;
    width: 370px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--ibwc-border);
    border-radius: 18px;
    background: var(--ibwc-base);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

.ibwc__panel[hidden] { display: none; }

.ibwc__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--ibwc-border);
    background: var(--ibwc-surface);
}

.ibwc__title {
    flex: 1;
    min-width: 0;
    color: var(--ibwc-text);
    font-weight: 600;
}

.ibwc__subtitle {
    display: block;
    color: var(--ibwc-muted);
    font-size: 12px;
    font-weight: 400;
}

.ibwc__close {
    flex: none;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--ibwc-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.ibwc__close:hover { background: var(--ibwc-elevated); color: var(--ibwc-text); }

/* ---------- Messages ---------- */
.ibwc__log {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.ibwc__intro {
    padding: 12px 14px;
    border: 1px dashed var(--ibwc-border);
    border-radius: 12px;
    color: var(--ibwc-muted);
    font-size: 13px;
}

.ibwc__msg {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ibwc__msg--visitor {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.18), rgba(0, 85, 255, 0.24));
    border: 1px solid rgba(0, 255, 255, 0.28);
    color: var(--ibwc-text);
}

.ibwc__msg--agent {
    align-self: flex-start;
    background: var(--ibwc-surface);
    border: 1px solid var(--ibwc-border);
    color: var(--ibwc-text);
}

.ibwc__msg-time {
    display: block;
    margin-top: 3px;
    color: var(--ibwc-muted);
    font-size: 11px;
}

.ibwc__msg img {
    margin-top: 6px;
    border-radius: 10px;
}

/* ---------- Contact form ---------- */
.ibwc__form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid rgba(0, 255, 255, 0.24);
    border-radius: 12px;
    background: rgba(0, 255, 255, 0.05);
}

.ibwc__form[hidden] { display: none; }
.ibwc__form-label { color: var(--ibwc-muted); font-size: 13px; }
.ibwc__form-row { display: flex; gap: 8px; }

.ibwc__input, .ibwc__textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--ibwc-border);
    border-radius: 10px;
    background: var(--ibwc-base);
    color: var(--ibwc-text);
    font: inherit;
}

.ibwc__input:focus, .ibwc__textarea:focus {
    outline: none;
    border-color: var(--ibwc-cyan);
}

.ibwc__btn {
    padding: 8px 14px;
    border: 1px solid var(--ibwc-border);
    border-radius: 10px;
    background: var(--ibwc-elevated);
    color: var(--ibwc-text);
    font: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.ibwc__btn:hover:not(:disabled) { border-color: var(--ibwc-cyan); }
.ibwc__btn:disabled { opacity: 0.55; cursor: default; }

.ibwc__btn--primary {
    border: none;
    color: #04122B;
    font-weight: 600;
    background: linear-gradient(135deg, #00FFFF 0%, #00A3FF 100%);
}

/* ---------- Composer ---------- */
.ibwc__composer {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 12px;
    border-top: 1px solid var(--ibwc-border);
    background: var(--ibwc-surface);
}

.ibwc__textarea {
    flex: 1;
    min-height: 42px;
    max-height: 120px;
    resize: none;
}

.ibwc__send {
    flex: none;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    color: #04122B;
    background: linear-gradient(135deg, #00FFFF 0%, #00A3FF 100%);
}

.ibwc__send:disabled { opacity: 0.5; cursor: default; }
.ibwc__send svg { width: 19px; height: 19px; }

.ibwc__error {
    padding: 0 14px 10px;
    color: #FF8FA3;
    font-size: 13px;
}

.ibwc__error[hidden] { display: none; }

@media (max-width: 480px) {
    .ibwc { right: 12px; bottom: 12px; }
    .ibwc__panel { width: calc(100vw - 24px); height: calc(100vh - 110px); }
}

@media (prefers-reduced-motion: reduce) {
    .ibwc__launcher { transition: none; }
}
