/* Floating chat widget. Self-contained and namespaced with cw- so it cannot collide with
   the customer or admin theme, both of which use Bootstrap with different overrides. */

.cw-chat {
    position: fixed;
    right: 20px;
    bottom: 60px;
    z-index: 19000;
    font-family: inherit;
}

/* ------------------------------------------------------------------ launcher */

.cw-launcher {
    position: relative;
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    background: #4a63e7;
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(74, 99, 231, 0.4);
    transition: transform 0.15s ease;
}

.cw-launcher:hover {
    transform: scale(1.06);
}

.cw-launcher-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #d9534f;
    color: #fff;
    font-size: 11px;
    line-height: 20px;
}

/* --------------------------------------------------------------------- panel */

.cw-panel {
    position: absolute;
    right: 0;
    bottom: 70px;
    display: flex;
    flex-direction: column;
    width: 340px;
    height: 460px;
    background: #fff;
    border: 1px solid #e3e6ef;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(20, 25, 50, 0.22);
}

.cw-panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #4a63e7;
    color: #fff;
}

.cw-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cw-panel-head button,
.cw-panel-head a {
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    opacity: 0.85;
}

.cw-panel-head button:hover,
.cw-panel-head a:hover {
    opacity: 1;
}

.cw-back {
    font-size: 22px;
}

/* ---------------------------------------------------------------------- list */

.cw-list {
    flex: 1;
    overflow-y: auto;
}

.cw-empty {
    padding: 24px 12px;
    text-align: center;
    color: #9aa0b8;
    font-size: 13px;
}

.cw-row {
    position: relative;
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #f3f4f9;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.cw-row:hover {
    background: #f7f8fc;
}

.cw-row-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #2b3350;
}

.cw-row-preview {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: #7a819b;
    /* One line — a long message must not reflow the list. */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cw-row-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #4a63e7;
    color: #fff;
    font-size: 10px;
    line-height: 18px;
    text-align: center;
}

/* -------------------------------------------------------------------- thread */

.cw-thread {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.cw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #f7f8fc;
}

.cw-msg {
    display: flex;
    margin-bottom: 8px;
}

.cw-msg.is-mine {
    justify-content: flex-end;
}

.cw-bubble {
    max-width: 78%;
    padding: 7px 11px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e6e9f4;
    font-size: 13px;
    /* Bodies are user input; wrap rather than letting one paste stretch the panel. */
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.cw-msg.is-mine .cw-bubble {
    background: #4a63e7;
    border-color: #4a63e7;
    color: #fff;
}

.cw-bubble.is-muted {
    font-style: italic;
    opacity: 0.65;
}

.cw-system {
    margin: 8px 0;
    text-align: center;
    font-size: 11px;
    color: #8a90a8;
}

.cw-typing {
    min-height: 16px;
    padding: 0 12px;
    font-size: 11px;
    font-style: italic;
    color: #7a819b;
}

.cw-composer {
    display: flex;
    gap: 6px;
    padding: 10px;
    border-top: 1px solid #eef0f6;
}

.cw-composer textarea {
    flex: 1;
    resize: none;
    max-height: 90px;
    padding: 7px 9px;
    border: 1px solid #d8dce8;
    border-radius: 6px;
    font-size: 13px;
}

.cw-send {
    padding: 0 14px;
    border: 0;
    border-radius: 6px;
    background: #4a63e7;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
}

.cw-send:disabled {
    opacity: 0.6;
    cursor: default;
}

/* --------------------------------------------------------------------- toast */

.cw-toast-host {
    position: fixed;
    right: 20px;
    bottom: 90px;
    z-index: 19500;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cw-toast {
    max-width: 300px;
    padding: 10px 14px;
    border-radius: 8px;
    background: #2b3350;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.cw-toast div {
    margin-top: 2px;
    opacity: 0.85;
    overflow-wrap: anywhere;
}

@media (max-width: 520px) {
    .cw-chat {
        right: 12px;
        bottom: 12px;
    }

    .cw-panel {
        width: calc(100vw - 24px);
        height: 70vh;
    }
}
