/* ChatX 客户端聊天窗口样式 - 响应式设计 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
}

body {
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #dfe5f3;
    overflow: hidden;
    overscroll-behavior: none;
}

/* 基础容器：移动端全屏 */
.chat-container {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    font-size: 14px;
}

.chat-app-shell {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
}

/* 阶段切换 */
.chat-stage {
    display: none;
    flex: 1;
    overflow: hidden;
    flex-direction: column;
    position: relative;
}

.chat-stage.active {
    display: flex;
    min-width: 0;
    min-height: 0;
}

/* ========== 阶段1：登录页（index.html 独立实现） ========== */

/* ========== 阶段3：聊天窗口 ========== */
#stage-chat {
    background: var(--body-bg-color, #f5f5f5);
}

.chat-sidebar {
    display: none;
    width: 272px;
    flex-shrink: 0;
    border-left: 2px solid rgba(120, 125, 139, 0.22);
    background: linear-gradient(180deg, #edf5ff 0%, #ffffff 100%);
}

.promo-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px 16px 18px;
    background:
        radial-gradient(circle at 50% 0, rgba(114, 198, 255, 0.3), transparent 38%),
        linear-gradient(180deg, rgba(66, 158, 255, 0.18) 0%, rgba(255, 255, 255, 0) 36%);
}

.promo-hero {
    position: relative;
    padding: 14px 16px 18px;
    border-radius: 24px;
    overflow: hidden;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(230, 244, 255, 0.92)),
        linear-gradient(180deg, #d8f0ff, #ffffff);
    box-shadow: 0 18px 36px rgba(36, 74, 135, 0.14);
}

.promo-hero::before,
.promo-hero::after {
    content: "";
    position: absolute;
    inset: auto auto 14px -18px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(120, 182, 255, 0.12);
}

.promo-hero::after {
    inset: -36px -30px auto auto;
    width: 140px;
    height: 140px;
}

.promo-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    position: relative;
    z-index: 1;
}

.promo-brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #27b2ff, #1b63ff);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    box-shadow: 0 12px 22px rgba(39, 128, 255, 0.32);
}

.promo-brand-text {
    display: flex;
    flex-direction: column;
    color: #1652ae;
}

.promo-brand-text strong {
    font-size: 24px;
    letter-spacing: 0.04em;
}

.promo-brand-text span {
    font-size: 12px;
    opacity: 0.82;
}

.promo-copy {
    position: relative;
    z-index: 1;
}

.promo-copy h3 {
    font-size: 30px;
    line-height: 1.06;
    color: #30466f;
    margin-bottom: 12px;
    text-shadow: 0 8px 18px rgba(52, 87, 145, 0.18);
}

.promo-copy p {
    font-size: 13px;
    line-height: 1.6;
    color: #61708d;
}

.promo-schedule {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.schedule-date {
    font-size: 14px;
    color: #5e6983;
    text-align: center;
    letter-spacing: 0.04em;
}

.schedule-item {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    padding: 14px 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 10px 24px rgba(61, 94, 151, 0.08);
}

.schedule-item strong {
    font-size: 24px;
    color: #1f2433;
    letter-spacing: 0.03em;
}

.team {
    font-size: 13px;
    color: #5a657e;
    white-space: nowrap;
}

.team:last-child {
    text-align: right;
}

.chat-header-bar {
    height: 50px;
    background: var(--header-bg-color, #1890ff);
    color: var(--header-color, #fff);
    display: flex;
    align-items: center;
    padding: 0 18px;
    flex-shrink: 0;
    position: relative;
    z-index: 60;
}

.header-logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    margin-right: 12px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.14);
    padding: 3px;
}

#chat-title {
    flex: 1;
    font-size: 16px;
    font-weight: 500;
}

.exit-btn {
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.exit-btn:hover {
    opacity: 0.82;
}

/* 公告栏 */
.notice-bar {
    background: var(--announce-bg-color, #fffbe6);
    color: var(--announce-color, #ff8800);
    padding: 1px 12px;
    font-size: 12px;
    border-bottom: 1px solid rgba(255, 188, 89, 0.35);
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 公告栏波形动画指示器 */
.notice-bar-icon {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
    flex-shrink: 0;
}

.notice-bar-icon span {
    display: block;
    width: 3px;
    background: var(--announce-color, #ff8800);
    border-radius: 2px;
    animation: barPulse 1.2s ease infinite;
}

.notice-bar-icon span:nth-child(1) { height: 4px; animation-delay: 0s; }
.notice-bar-icon span:nth-child(2) { height: 10px; animation-delay: 0.2s; }
.notice-bar-icon span:nth-child(3) { height: 6px; animation-delay: 0.4s; }
.notice-bar-icon span:nth-child(4) { height: 8px; animation-delay: 0.1s; }

@keyframes barPulse {
    0%, 100% { transform: scaleY(0.5); opacity: 0.7; }
    50% { transform: scaleY(1); opacity: 1; }
}

.notice-bar-content {
    display: inline-block;
    padding-left: 100%;
    animation: scroll-left 20s linear infinite;
    white-space: nowrap;
}

@keyframes scroll-left {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* 消息列表 */
.message-list {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 18px 12px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.message-list::-webkit-scrollbar {
    width: 6px;
}

.message-list::-webkit-scrollbar-thumb {
    background: #d9d9d9;
    border-radius: 3px;
}

/* 消息项 */
.message-item {
    display: flex;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
    align-items: flex-end;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-item.customer {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    margin: 0 8px;
    flex-shrink: 0;
    object-fit: cover;
}

/* 消息主体（包含 meta + bubble） */
.message-body {
    max-width: 76%;
    display: flex;
    flex-direction: column;
}

.message-item.servicer .message-body {
    align-items: flex-start;
}

.message-item.customer .message-body {
    align-items: flex-end;
}

/* 发送者姓名+时间 */
.message-meta {
    font-size: 11px;
    color: #aaa;
    margin-bottom: 4px;
    padding: 0 2px;
}

.message-bubble {
    padding: 12px 14px;
    border-radius: 14px;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.5;
    max-width: 100%;
}

.message-item.servicer .message-bubble {
    background: var(--msg-servicer-bg-color, #ececec);
    color: var(--msg-servicer-color, #333);
    border-radius: 2px 14px 14px 14px;
}

.message-item.customer .message-bubble {
    background: var(--msg-user-bg-color, #1890ff);
    color: var(--msg-user-color, #fff);
    border-radius: 14px 2px 14px 14px;
}

.message-bubble img {
    max-width: 180px;
    border-radius: 6px;
    display: block;
    cursor: pointer;
}

/* 系统消息（会话结束等） */
.system-message {
    background: #f0f0f0;
    border-radius: 6px;
    padding: 12px 16px;
    margin: 4px 0 16px;
    color: #666;
    font-size: 13px;
    line-height: 1.6;
    text-align: center;
}

/* 时间分隔 */
.message-time {
    text-align: center;
    color: #999;
    font-size: 12px;
    margin: 16px 0;
}

/* ========== 会话结束 bar ========== */
.session-end-bar {
    padding: 10px 16px;
    font-size: 13px;
    color: #999;
    text-align: center;
    border-top: 1px solid #f0f0f0;
    background: #fff;
    flex-shrink: 0;
    position: relative;
    z-index: 60;
}

.continue-link {
    color: var(--theme-color, #1890ff);
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
    margin-left: 4px;
}

.continue-link:hover {
    text-decoration: underline;
}

/* ========== 输入区域（单行设计） ========== */
.input-area {
    background: #fff;
    border-top: 1px solid #e8e8e8;
    padding: 8px 12px 10px;
    flex-shrink: 0;
    position: relative;
    z-index: 60;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

/* 表情选择面板 */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px 8px 0 0;
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    z-index: 101;
    max-height: 160px;
    overflow-y: auto;
}

.emoji-item {
    font-size: 22px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.15s;
    user-select: none;
}

.emoji-item:hover {
    background: #f5f5f5;
}

/* 加号弹出菜单 */
.plus-menu {
    position: absolute;
    bottom: calc(100% + 4px);
    right: 12px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.12);
    z-index: 101;
    overflow: hidden;
    min-width: 80px;
}

.plus-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 12px;
    color: #555;
    width: 100%;
}

.plus-menu-item:hover {
    background: #f8f8f8;
}

.plus-menu-icon {
    font-size: 26px;
    margin-bottom: 4px;
    line-height: 1;
}

/* 表情按钮（小圆形） */
.emoji-btn-sm {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.emoji-btn-sm:hover {
    background: #f5f5f5;
}

/* 输入框 */
#message-input {
    flex: 1;
    min-width: 0;
    min-height: 36px;
    max-height: 100px;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    background: #f3f4f8;
    transition: background 0.2s;
    outline: none;
    line-height: 1.4;
}

#message-input:focus {
    background: #eceef5;
}

/* ➕ 圆形按钮 */
.plus-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--theme-color, #1890ff);
    color: #fff;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.2s;
}

.plus-btn:hover {
    opacity: 0.9;
}

.plus-btn:active {
    transform: scale(0.95);
}

/* ========== 验证弹窗 ========== */
.verify-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: var(--body-bg-color, #f5f5f5);
    z-index: 50;
    align-items: center;
    justify-content: center;
}

.verify-modal {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    width: 85%;
    max-width: 340px;
    text-align: left;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.verify-modal h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #333;
    font-weight: 600;
}

.verify-modal p {
    color: #666;
    margin-bottom: 20px;
    font-size: 13px;
    line-height: 1.6;
}

.slide-verify {
    position: relative;
    width: 100%;
    height: 44px;
    background: #f0f0f0;
    border-radius: 22px;
    overflow: hidden;
}

.slide-track {
    width: 100%;
    height: 100%;
    position: relative;
}

.slide-btn {
    position: absolute;
    left: 0;
    top: 0;
    width: 50px;
    height: 44px;
    background: #fff;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 22px;
    cursor: grab;
    user-select: none;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 1px 6px rgba(0,0,0,0.15);
    transition: background 0.3s, color 0.3s;
    z-index: 2;
}

.slide-btn:active {
    cursor: grabbing;
}

.slide-btn.success {
    background: #52c41a;
    color: #fff;
    cursor: default;
}

.slide-text {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #bbb;
    font-size: 13px;
}

/* ========== 满意度评价弹层 ========== */
.rating-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.rating-modal {
    background: #fff;
    border-radius: 8px;
    padding: 28px 32px;
    text-align: center;
    width: 280px;
}

.rating-modal h3 { margin: 0 0 8px; font-size: 16px; }
.rating-modal p  { color: #666; font-size: 13px; margin-bottom: 16px; }
.rating-stars    { font-size: 32px; color: #ddd; cursor: pointer; line-height: 1.2; }
.rating-star.active { color: #faad14; }
.rating-labels   { display: flex; justify-content: space-between; font-size: 11px; color: #999; margin-top: 4px; }
.rating-btns     { margin-top: 20px; display: flex; gap: 10px; justify-content: center; }

.primary-btn {
    height: 40px;
    padding: 0 20px;
    background: var(--theme-color, #1890ff);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.primary-btn:hover { opacity: 0.9; }
.primary-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.secondary-btn {
    height: 40px;
    padding: 0 20px;
    border: 1px solid #d9d9d9;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.secondary-btn:hover { border-color: #aaa; }

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 移动端优化 */
@media (max-width: 767px) {
    body {
        background: #ffffff;
    }

    .chat-app-shell {
        display: flex;
        height: 100%;
        min-height: 0;
    }

    .chat-sidebar {
        display: none !important;
    }

    .message-body {
        max-width: 78%;
    }

    .message-bubble img {
        max-width: 160px;
    }

    .input-area {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .verify-modal {
        width: 88%;
        padding: 20px;
    }
}

@media (min-width: 768px) {
    .chat-container {
        min-height: 100vh;
        background:
            linear-gradient(90deg, rgba(147, 156, 177, 0.28) 0, rgba(147, 156, 177, 0.28) calc(50% - 576px), #ffffff calc(50% - 576px), #ffffff calc(50% + 576px), rgba(147, 156, 177, 0.28) calc(50% + 576px), rgba(147, 156, 177, 0.28) 100%);
    }

    .chat-app-shell {
        width: 1152px;
        max-width: calc(100vw - 48px);
        min-height: 100vh;
        margin: 0 auto;
        background: transparent;
    }

    #stage-chat {
        width: 880px;
        border-right: 0;
    }

    .chat-sidebar {
        display: block;
    }
}
