/* Customer chat widget — storefront + customer panel (Next.js-style two-panel) */
.cchat {
    display: flex;
    gap: 0;
    height: 70vh;
    min-height: 460px;
    font-size: 14px;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
}
.cchat--compact { height: 64vh; min-height: 420px; }

/* ── Left: seller card + conversation list ─────────────────────── */
.cchat-list {
    width: 340px;
    flex: 0 0 340px;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #fff8ef 0%, #ffffff 65%);
}

.cchat-seller-card {
    margin: 16px;
    padding: 16px;
    background: #fff;
    border: 1px solid #fed7aa;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
.cchat-seller-eyebrow {
    margin: 0 0 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: #ea580c;
}
.cchat-seller-name { margin: 0 0 4px; font-size: 14px; font-weight: 700; color: #111827; }
.cchat-seller-sub { margin: 0 0 14px; font-size: 12px; line-height: 1.5; color: #6b7280; }
.cchat-seller-btn {
    width: 100%;
    border: 0;
    border-radius: 999px;
    background: #f97316;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background .15s;
}
.cchat-seller-btn:hover { background: #ea580c; }
.cchat-seller-btn:disabled { background: #d1d5db; cursor: default; }

.cchat-list-head { padding: 14px 18px 8px; }
.cchat-list-title { display: block; font-weight: 700; font-size: 14px; color: #111827; }
.cchat-list-sub { display: block; font-size: 12px; color: #9ca3af; margin-top: 2px; }
.cchat-conversations { list-style: none; margin: 0; padding: 0 10px 12px; flex: 1; }
.cchat-conv {
    padding: 12px 14px;
    margin-bottom: 6px;
    border: 1px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background .12s, border-color .12s;
}
.cchat-conv:hover { background: #fff7ed; }
.cchat-conv.is-active { background: #fff; border-color: #fdba74; box-shadow: 0 1px 2px rgba(16, 24, 40, .05); }
.cchat-conv.is-unread .cchat-conv-name { font-weight: 700; }
.cchat-conv-name { font-weight: 600; color: #111827; }
.cchat-conv-preview { color: #6b7280; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cchat-empty { padding: 16px; color: #9ca3af; font-size: 13px; }

/* ── Right: thread ─────────────────────────────────────────────── */
.cchat-thread {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    min-width: 0;
}
.cchat-thread-head { padding: 16px 20px; border-bottom: 1px solid #f1f3f7; font-weight: 700; font-size: 15px; color: #111827; }
.cchat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: linear-gradient(180deg, #fffaf5 0%, #ffffff 40%);
}

/* Empty state */
.cchat-thread-empty { margin: auto; max-width: 360px; text-align: center; color: #6b7280; }
.cchat-thread-empty-icon {
    width: 56px; height: 56px; margin: 0 auto 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; border-radius: 50%; background: #fff1e6;
}
.cchat-thread-empty-title { margin: 0 0 6px; font-size: 18px; font-weight: 700; color: #111827; }
.cchat-thread-empty-text { margin: 0; font-size: 13px; line-height: 1.6; }

/* Bubbles */
.cchat-msg { max-width: 78%; padding: 9px 13px; border-radius: 16px; position: relative; }
.cchat-msg.is-mine { align-self: flex-end; background: #f97316; color: #fff; border-bottom-right-radius: 5px; }
.cchat-msg.is-theirs { align-self: flex-start; background: #fff; border: 1px solid #e5e7eb; border-bottom-left-radius: 5px; }
.cchat-msg-body { white-space: pre-wrap; word-break: break-word; }
.cchat-msg-time { font-size: 10.5px; opacity: .65; margin-top: 4px; text-align: right; }
.cchat-msg-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cchat-att img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; display: block; }

/* Product reference card pinned at top of thread */
.cchat-product { border-bottom: 1px solid #f1f3f7; background: #fff; padding: 12px 20px; }
.cchat-product-card { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.cchat-product-img { width: 48px; height: 48px; flex: none; border-radius: 10px; object-fit: cover; background: #eef0f5; border: 1px solid #e5e7eb; }
.cchat-product-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cchat-product-name { font-weight: 600; font-size: 13px; color: #1f2937; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cchat-product-price { font-size: 13px; font-weight: 700; color: #f97316; margin-top: 2px; }
.cchat-product-view { flex: none; font-size: 22px; line-height: 1; color: #9aa3b2; }
.cchat-product-card:hover .cchat-product-name { color: #f97316; }

/* Input */
.cchat-input { border-top: 1px solid #f1f3f7; padding: 14px 20px; background: #fff; }
.cchat-attachments { display: flex; flex-wrap: wrap; gap: 6px; }
.cchat-attachments:not(:empty) { margin-bottom: 8px; }
.cchat-prev { position: relative; display: inline-block; }
.cchat-prev img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; }
.cchat-prev button { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border: 0; border-radius: 50%; background: #111827; color: #fff; cursor: pointer; line-height: 1; }
.cchat-input textarea {
    width: 100%;
    resize: none;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    max-height: 140px;
    background: #f9fafb;
}
.cchat-input textarea:focus { outline: none; border-color: #fdba74; background: #fff; }
.cchat-input-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.cchat-attach { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 7px 14px; border: 1px solid #e5e7eb; border-radius: 999px; font-size: 13px; color: #4b5563; user-select: none; }
.cchat-attach:hover { background: #f9fafb; }
.cchat-attach-icon { font-size: 15px; line-height: 1; }
.cchat-send {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    background: #f97316;
    color: #fff;
    border-radius: 999px;
    padding: 10px 22px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.cchat-send:hover { background: #ea580c; }
.cchat-send:disabled { opacity: .55; cursor: default; }

/* Inbox (customer panel) page — no seller card */
.cchat--inbox .cchat-seller-card { display: none; }

/* Floating "Message seller" button on product pages */
.cchat-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1040;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border: 0;
    border-radius: 999px;
    background: #f97316;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(249, 115, 22, .35);
    cursor: pointer;
    text-decoration: none;
}
.cchat-fab:hover { background: #ea580c; color: #fff; }
#messageSellerModal .modal-body { padding: 0; }
#messageSellerModal .modal-content { border: 0; border-radius: 16px; overflow: hidden; }
#messageSellerModal .cchat { height: 72vh; border: 0; border-radius: 0; }

@media (max-width: 768px) {
    .cchat { flex-direction: column; height: auto; }
    .cchat-list { width: 100%; flex: none; max-height: 42vh; border-right: 0; border-bottom: 1px solid #e5e7eb; }
    .cchat-thread { min-height: 56vh; }

    #messageSellerModal {
        padding: 0 !important;
    }
    #messageSellerModal .modal-dialog {
        width: 100%;
        max-width: none;
        height: 100vh;
        height: 100dvh;
        min-height: 100vh;
        min-height: 100dvh;
        margin: 0;
    }
    #messageSellerModal .modal-content {
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    #messageSellerModal .modal-header {
        flex: 0 0 auto;
    }
    #messageSellerModal .modal-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }
    #messageSellerModal .cchat {
        height: 100%;
        min-height: 0;
    }
    #messageSellerModal .cchat-list {
        flex: 0 0 38%;
        max-height: 38%;
        min-height: 0;
    }
    #messageSellerModal .cchat-thread {
        flex: 1 1 62%;
        min-height: 0;
    }
    #messageSellerModal .cchat-messages {
        min-height: 0;
    }
    #messageSellerModal .cchat-input {
        flex: 0 0 auto;
    }
}
