/* ============================================================
   .custom-live-chat — isolated live chat widget
   ============================================================ */

.custom-live-chat {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    z-index: 99999 !important;
    display: block !important;
    visibility: visible !important;
    pointer-events: auto !important;
    font-family: 'Roboto', Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.4;
    color: #333;
}

.custom-live-chat *,
.custom-live-chat *::before,
.custom-live-chat *::after {
    box-sizing: border-box;
}

/* ── Launcher ──────────────────────────────────────────────── */
.custom-live-chat__launcher {
    position: relative;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #950000;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 28px rgba(149, 0, 0, 0.45);
    transition: transform 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease;
    outline: none;
    visibility: visible !important;
    opacity: 1 !important;
}

.custom-live-chat__launcher:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 34px rgba(149, 0, 0, 0.52);
}

.custom-live-chat__launcher-icon {
    width: 32px;
    height: 32px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.custom-live-chat.is-open .custom-live-chat__launcher {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

.custom-live-chat.has-unread:not(.is-open) .custom-live-chat__launcher::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #4cd964;
    border: 2px solid #fff;
    animation: clc-pulse 1.5s ease infinite;
}


/* ── Window ────────────────────────────────────────────────── */
.custom-live-chat__window {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 420px;
    max-width: calc(100vw - 40px);
    height: 640px;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    transform: scale(0);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.38s cubic-bezier(0.34, 1.4, 0.64, 1),
                opacity 0.28s ease;
}

.custom-live-chat.is-open .custom-live-chat__window {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* ── Header ────────────────────────────────────────────────── */
.custom-live-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    padding: 18px 18px 16px;
    background: linear-gradient(135deg, #ba0000 0%, #950000 55%, #6f0000 100%);
    color: #fff;
}

.custom-live-chat__header-info {
    min-width: 0;
}

.custom-live-chat__title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.custom-live-chat__status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.92;
}

.custom-live-chat__status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4cd964;
    box-shadow: 0 0 0 2px rgba(76, 217, 100, 0.35);
    animation: clc-pulse 2s ease infinite;
}

@keyframes clc-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.55; }
}

.custom-live-chat__minimize {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease;
}

.custom-live-chat__minimize:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ── Quick callback bar ──────────────────────────────────────── */
.custom-live-chat__quick-bar {
    flex-shrink: 0;
    padding: 10px 14px 0;
    background: #f8f8f8;
    border-bottom: 1px solid #eee;
}

.custom-live-chat__quick-btn {
    display: block;
    width: 100%;
    margin: 0;
    padding: 9px 14px;
    border: 1px dashed #950000;
    border-radius: 10px;
    background: #fff;
    color: #950000;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.custom-live-chat__quick-btn:hover {
    background: #fff5f5;
    border-color: #c02525;
}

/* ── Callback form (inline) ────────────────────────────────── */
.custom-live-chat__callback {
    display: none;
    flex-shrink: 0;
    padding: 12px 14px;
    background: #fff8f0;
    border-bottom: 1px solid #f0e0d0;
}

.custom-live-chat__callback.is-visible {
    display: block;
}

.custom-live-chat__callback-title {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: #555;
}

.custom-live-chat__callback-row {
    margin-bottom: 8px;
}

.custom-live-chat__callback-input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    background: #fff;
}

.custom-live-chat__callback-input:focus {
    border-color: #950000;
}

.custom-live-chat__callback-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.custom-live-chat__callback-submit {
    flex: 1;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: #950000;
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.custom-live-chat__callback-cancel {
    height: 36px;
    padding: 0 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    color: #666;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

.custom-live-chat__callback-error {
    margin: 6px 0 0;
    font-size: 12px;
    color: #950000;
    min-height: 0;
}

.custom-live-chat__callback-error:empty {
    display: none;
}

/* ── Messages area ─────────────────────────────────────────── */
.custom-live-chat__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 14px 8px;
    background: #f3f4f6;
    scroll-behavior: smooth;
}

.custom-live-chat__body::-webkit-scrollbar {
    width: 5px;
}

.custom-live-chat__body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.custom-live-chat__messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Message balloons ──────────────────────────────────────── */
.custom-live-chat__msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: clc-msg-in 0.35s ease;
}

@keyframes clc-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.custom-live-chat__msg--incoming {
    align-self: flex-start;
}

.custom-live-chat__msg--outgoing {
    align-self: flex-end;
    align-items: flex-end;
}

.custom-live-chat__bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}

.custom-live-chat__msg--incoming .custom-live-chat__bubble {
    background: #fff;
    color: #333;
    border: 1px solid #e8e8e8;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.custom-live-chat__msg--outgoing .custom-live-chat__bubble {
    background: #950000;
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(149, 0, 0, 0.25);
}

.custom-live-chat__msg--bot .custom-live-chat__bubble {
    background: #fff;
    border-left: 3px solid #950000;
}

.custom-live-chat__meta {
    margin-top: 3px;
    font-size: 11px;
    color: #999;
    padding: 0 4px;
}

.custom-live-chat__msg--outgoing .custom-live-chat__meta {
    text-align: right;
}

/* ── Typing indicator ──────────────────────────────────────── */
.custom-live-chat__typing {
    display: none;
    align-self: flex-start;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    font-size: 12px;
    color: #888;
}

.custom-live-chat__typing.is-visible {
    display: flex;
    align-items: center;
    gap: 6px;
    animation: clc-msg-in 0.3s ease;
}

.custom-live-chat__typing-dots {
    display: inline-flex;
    gap: 3px;
}

.custom-live-chat__typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #bbb;
    animation: clc-dot 1.2s ease infinite;
}

.custom-live-chat__typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.custom-live-chat__typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes clc-dot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%            { transform: translateY(-4px); opacity: 1; }
}

/* ── Attach / images ───────────────────────────────────────── */
.custom-live-chat__file-input {
    display: none !important;
}

.custom-live-chat__attach {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin: 0;
    padding: 0;
    border: 1px solid #e0e0e0;
    border-radius: 50%;
    background: #fafafa;
    color: #666;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.custom-live-chat__attach:hover {
    border-color: #950000;
    color: #950000;
    background: #fff;
}

.custom-live-chat__attach-icon {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.custom-live-chat__image-link {
    display: block;
    margin-bottom: 6px;
}

.custom-live-chat__image {
    display: block;
    max-width: 220px;
    max-height: 160px;
    border-radius: 10px;
    object-fit: cover;
    cursor: zoom-in;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.custom-live-chat__msg--bot .custom-live-chat__bubble {
    background: #fff8e8;
    border: 1px solid #f0e0b8;
}

/* ── Footer / input ────────────────────────────────────────── */
.custom-live-chat__footer {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding: 12px 14px;
    background: #fff;
    border-top: 1px solid #eee;
}

.custom-live-chat__input {
    flex: 1;
    min-width: 0;
    height: 42px;
    margin: 0;
    padding: 0 14px;
    border: 1px solid #e0e0e0;
    border-radius: 22px;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    background: #fafafa;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.custom-live-chat__input:focus {
    border-color: #950000;
    background: #fff;
}

.custom-live-chat__input::placeholder {
    color: #aaa;
}

.custom-live-chat__send {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #950000;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}

.custom-live-chat__send:hover {
    background: #c02525;
}

.custom-live-chat__send:active {
    transform: scale(0.94);
}

.custom-live-chat__send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.custom-live-chat__send-icon {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Toast inside chat ─────────────────────────────────────── */
.custom-live-chat__toast {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 72px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(30, 30, 30, 0.88);
    color: #fff;
    font-size: 12px;
    text-align: center;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 2;
}

.custom-live-chat__toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .custom-live-chat {
        bottom: 14px;
        right: 14px;
    }

    .custom-live-chat__window {
        width: calc(100vw - 28px);
        height: calc(100vh - 28px);
        max-height: 560px;
    }
}
