/* ============================================
   荣盛科技官网 · 在线咨询窗口
   访客端面板，配合 chat-widget.js 使用
   ============================================ */

.float-btn-chat {
    border: 0;
    font-family: inherit;
    line-height: 1.4;
    text-align: left;
    color: var(--accent, #0ea5e9);
}
.float-btn-chat:hover {
    background: var(--accent, #0ea5e9);
    color: #fff;
}

.chat-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 368px;
    height: min(580px, calc(100vh - 48px));
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 38, 77, 0.28);
    overflow: hidden;
    z-index: 9999;
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.24s ease, transform 0.24s ease;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-dark, #0a1628);
}
.chat-widget.open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

/* ---- 头部 ---- */
.chat-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--primary-light, #2b7de9), var(--accent, #0ea5e9));
    color: #fff;
}
.chat-head-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.chat-avatar {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.22);
    font-weight: 800;
    font-size: 15px;
}
.chat-head-text { min-width: 0; }
.chat-head-text strong {
    display: block;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-head-text span {
    display: block;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.85);
}
.chat-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease;
}
.chat-close:hover { background: rgba(255, 255, 255, 0.2); }

/* ---- 消息区 ---- */
.chat-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 14px;
    background: #f4f7fc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb { background: rgba(0, 61, 122, 0.16); border-radius: 3px; }

.chat-card {
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 2px 10px rgba(0, 61, 122, 0.06);
}
.chat-card h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark, #0a1628);
    margin-bottom: 8px;
}
.chat-card p {
    font-size: 12.5px;
    color: var(--text-light, #6b7280);
    line-height: 1.7;
}
.chat-card ul {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.chat-card li {
    font-size: 12.5px;
    color: var(--text-body, #3a3f4b);
    padding-left: 16px;
    position: relative;
}
.chat-card li::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 8px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent, #0ea5e9);
}

.chat-msg {
    max-width: 80%;
    padding: 9px 13px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}
.chat-msg.visitor {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary-light, #2b7de9), var(--accent, #0ea5e9));
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg.admin {
    align-self: flex-start;
    background: #fff;
    color: var(--text-dark, #0a1628);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
    border-bottom-left-radius: 4px;
}
.chat-msg-time {
    align-self: center;
    font-size: 11px;
    color: #9aa3af;
    padding: 2px 0;
}
.chat-msg-failed {
    align-self: flex-end;
    font-size: 11px;
    color: #e05555;
    margin-top: -6px;
}

/* ---- 联系方式 ---- */
.chat-contact {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    background: #fff;
    border-top: 1px solid #e8edf5;
}
.chat-contact input {
    min-width: 0;
    flex: 1;
    height: 32px;
    padding: 0 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--text-dark, #0a1628);
    outline: none;
    transition: border-color 0.2s ease;
}
.chat-contact input:focus { border-color: var(--primary-light, #2b7de9); }
.chat-contact button {
    flex-shrink: 0;
    height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: #eaf2fd;
    color: var(--primary-light, #2b7de9);
    font-size: 12.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}
.chat-contact button:hover { background: #dbe9fb; }
.chat-contact-saved {
    flex-shrink: 0;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 12px;
    background: #fff;
    border-top: 1px solid #e8edf5;
    font-size: 12.5px;
    color: var(--text-light, #6b7280);
}
.chat-contact-saved.show { display: flex; }
.chat-contact-saved b { color: var(--text-dark, #0a1628); font-weight: 600; }
.chat-contact-saved button {
    border: 0;
    background: transparent;
    color: var(--primary-light, #2b7de9);
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
    padding: 2px 4px;
}

/* ---- 输入区 ---- */
.chat-input {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px 12px;
    background: #fff;
    border-top: 1px solid #e8edf5;
}
.chat-input textarea {
    flex: 1;
    min-width: 0;
    height: 40px;
    max-height: 110px;
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafd;
    font-size: 13.5px;
    font-family: inherit;
    line-height: 1.5;
    color: var(--text-dark, #0a1628);
    resize: none;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}
.chat-input textarea:focus { border-color: var(--primary-light, #2b7de9); background: #fff; }
.chat-input textarea::placeholder { color: #9aa3af; }
.chat-send {
    flex-shrink: 0;
    height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary-light, #2b7de9), var(--accent, #0ea5e9));
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.chat-send:hover { opacity: 0.92; transform: translateY(-1px); }
.chat-send:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.chat-hint {
    flex-shrink: 0;
    padding: 0 12px 9px;
    background: #fff;
    font-size: 11px;
    color: #9aa3af;
    text-align: center;
}

/* ---- 悬浮按钮红点 ---- */
.float-btn-chat .chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: #e0555f;
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(224, 85, 95, 0.45);
}
.float-btn-chat .chat-badge[hidden] { display: none; }

/* ---- 移动端：全屏 ---- */
@media (max-width: 640px) {
    .chat-widget {
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        border-radius: 0;
        transform: translateY(20px);
    }
    .chat-msg { max-width: 86%; font-size: 14px; }
}

/* 演示模式（demo.js）下与其它浮层一起隐藏 */
body.demo-mode .chat-widget {
    opacity: 0 !important;
    pointer-events: none !important;
}
