/* REMIC Desk — live-chat widget (self-contained; loaded in the iframe) */
:root { --cw-blue: #4382ed; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
.cw-body { font-family: system-ui, "Segoe UI", Arial, sans-serif; background: #fff; }

.cw-wrap { display: flex; flex-direction: column; height: 100vh; }

.cw-header {
    flex: 0 0 auto; background: var(--cw-blue); color: #fff;
    padding: 14px 16px; font-weight: 600; font-size: 16px;
    display: flex; align-items: center; justify-content: space-between;
}
.cw-close {
    background: transparent; border: none; color: #fff; cursor: pointer;
    font-size: 22px; line-height: 1; padding: 0 2px; opacity: .85;
}
.cw-close:hover { opacity: 1; }

/* Pre-chat form */
.cw-pre { padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.cw-intro { margin: 0 0 6px; color: #374151; font-size: 14px; }
.cw-pre input, .cw-pre-msg {
    padding: 10px 12px; border: 1px solid #cfd6e0; border-radius: 8px; font-size: 14px;
}
.cw-pre-msg { font-family: inherit; resize: vertical; }
.cw-pre button, .cw-footer button {
    background: var(--cw-blue); color: #fff; border: none; border-radius: 8px;
    padding: 10px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.cw-pre button:hover, .cw-footer button:hover { background: #3a73d6; }
.cw-err { color: #c1121f; font-size: 13px; min-height: 16px; }

/* Chat pane */
.cw-chat { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.cw-log { flex: 1 1 auto; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #f2f3f7; }

.cw-msg { max-width: 80%; align-self: flex-start; }
.cw-msg.mine { align-self: flex-end; }
.cw-sender { font-size: 11px; color: #6b7280; margin-bottom: 2px; }
.cw-bubble {
    background: #fff; border: 1px solid #e3e6ec; border-radius: 12px;
    padding: 8px 12px; font-size: 14px; color: #374151; white-space: pre-wrap; word-break: break-word;
}
.cw-msg.mine .cw-bubble { background: var(--cw-blue); color: #fff; border-color: var(--cw-blue); }
.cw-bubble a { color: var(--cw-blue); text-decoration: underline; word-break: break-word; }
.cw-msg.mine .cw-bubble a { color: #fff; }

/* Typing indicator (…dots) */
.cw-typing-bubble { display: inline-flex; align-items: center; gap: 4px; padding: 10px 12px; }
.cw-dot {
    width: 7px; height: 7px; border-radius: 50%; background: #9aa5b1; display: inline-block;
    animation: cw-bounce 1.2s infinite ease-in-out both;
}
.cw-dot:nth-child(2) { animation-delay: 0.15s; }
.cw-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes cw-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40%           { transform: scale(1);   opacity: 1; }
}

.cw-sys {
    align-self: center; max-width: 90%; text-align: center;
    font-size: 12px; color: #6b7280; font-style: italic;
    padding: 6px 10px; margin: 2px 0; white-space: pre-line; line-height: 1.7;
}

/* Closing screen: rating + transcript prompt */
.cw-end { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 10px; padding: 22px 18px; text-align: center; background: #f2f3f7; }
.cw-end-title { font-size: 18px; font-weight: 700; color: #1f2937; margin-bottom: 4px; }
.cw-end-q { font-size: 14px; color: #374151; margin-top: 8px; }
.cw-stars { display: flex; gap: 4px; }
.cw-star {
    background: none; border: none; cursor: pointer; padding: 2px;
    font-size: 30px; line-height: 1; color: #cfd6e0; transition: color .1s;
}
.cw-star:hover, .cw-star.hot { color: #f5b301; }
.cw-star.sel { color: #f5b301; }
.cw-stars.done .cw-star { cursor: default; }
.cw-end-btns { display: flex; gap: 10px; }
.cw-end-btn {
    background: var(--cw-blue); color: #fff; border: none; border-radius: 8px;
    padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.cw-end-btn:hover { background: #3a73d6; }
.cw-end-btn-alt { background: #e5e7eb; color: #374151; }
.cw-end-btn-alt:hover { background: #d7dbe0; }
.cw-end-btn:disabled, .cw-end-btn-alt:disabled { opacity: .55; cursor: default; }
.cw-end-note { font-size: 13px; color: #2f9e44; min-height: 16px; }
.cw-end-done { font-size: 14px; color: #6b7280; margin-top: 8px; }

.cw-footer { flex: 0 0 auto; display: flex; gap: 8px; padding: 10px; border-top: 1px solid #e3e6ec; background: #fff; }
.cw-footer input {
    flex: 1 1 auto; padding: 10px 12px; border: 1px solid #cfd6e0; border-radius: 8px; font-size: 14px;
}

/* Waiting-for-a-human banner (offer/accept routing) */
.cw-wait { background: #fff7e6; border-bottom: 1px solid #ffe2a8; padding: 10px 12px; font-size: 13px; color: #5b4b1f; }
.cw-wait-row { display: flex; align-items: center; gap: 8px; }
.cw-wait-spin { width: 12px; height: 12px; border: 2px solid #e6c46a; border-top-color: transparent; border-radius: 50%; display: inline-block; animation: cw-spin .8s linear infinite; flex: 0 0 auto; }
@keyframes cw-spin { to { transform: rotate(360deg); } }
.cw-wait-sub { font-size: 12px; color: #8a7a4f; margin-top: 3px; }
.cw-wait-btns { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.cw-wait-btn { border: 1px solid #cfd6df; background: #fff; border-radius: 6px; padding: 4px 9px; font-size: 12px; cursor: pointer; }
.cw-wait-btn-alt { background: #4382ed; border-color: #4382ed; color: #fff; }

/* Cancel-request "×" in the waiting banner header */
.cw-wait-row .cw-wait-text { flex: 1 1 auto; }
.cw-wait-x { flex: 0 0 auto; border: 0; background: transparent; color: #8a7a4f; font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.cw-wait-x:hover { color: #5b4b1f; }
