/* ============================================================
   即时消息插件样式（仅聊天）
   文件位置: assets/css/chat.css
   ============================================================ */

/* ============================================================
   悬浮按钮（图标 + "立即咨询"文字）
   ============================================================ */
.chat-float-wrap {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    animation: chat-bounce 2s ease-in-out infinite;
    pointer-events: auto;     /* ✅ 加一句保险 */
}

@keyframes chat-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.chat-float-btn {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1A3A6A, #2D5A8A);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(26, 58, 106, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(26, 58, 106, 0.55);
}

.chat-float-label {
    background: linear-gradient(135deg, #D4A843, #F5D68A);
    color: #1A2332;
    font-size: 13px;
    font-weight: 700;
    padding: 5px 14px;
    border-radius: 20px;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(212, 168, 67, 0.4);
    letter-spacing: 0.5px;
    user-select: none;
    position: relative;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
}

.chat-float-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 168, 67, 0.6);
    background: linear-gradient(135deg, #E5B94A, #FFE49A);
}

.chat-float-label::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #E5C260;
}

.chat-float-btn .chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: #DC2626;
    color: #fff;
    border-radius: 11px;
    font-size: 12px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: badge-pulse 1.5s ease-in-out infinite;
}

.chat-float-btn .chat-badge.show {
    display: flex;
}

@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ============================================================
   聊天窗口
   ============================================================ */
.chat-window {
    position: fixed;
    right: 24px;
    bottom: 130px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 160px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.96);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.chat-window-header {
    background: linear-gradient(135deg, #1A3A6A, #2D5A8A);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-window-header .title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
}

.chat-window-header .title .status-dot {
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
    animation: status-pulse 2s ease-in-out infinite;
}

@keyframes status-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.15); }
}

.chat-window-header .close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s;
}

.chat-window-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.chat-window-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #F5F8FC;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-window-body::-webkit-scrollbar {
    width: 6px;
}

.chat-window-body::-webkit-scrollbar-thumb {
    background: rgba(26, 58, 106, 0.2);
    border-radius: 3px;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 78%;
    animation: msg-in 0.3s ease;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg.visitor {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-msg.admin {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-msg .bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-msg.visitor .bubble {
    background: linear-gradient(135deg, #1A3A6A, #2D5A8A);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg.admin .bubble {
    background: #fff;
    color: #1A2332;
    border: 1px solid #E8EDF4;
    border-bottom-left-radius: 4px;
}

.chat-msg .time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 4px;
}

.chat-welcome {
    text-align: center;
    padding: 20px 16px;
    color: #5A6B7C;
    font-size: 13px;
    line-height: 1.8;
}

.chat-welcome .icon {
    font-size: 40px;
    display: block;
    margin-bottom: 8px;
}

.chat-window-footer {
    border-top: 1px solid #E8EDF4;
    padding: 12px 14px;
    background: #fff;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-window-footer textarea {
    flex: 1;
    resize: none;
    border: 2px solid #E8EDF4;
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    max-height: 100px;
    min-height: 40px;
    transition: all 0.3s;
    outline: none;
}

.chat-window-footer textarea:focus {
    border-color: #1A3A6A;
    box-shadow: 0 0 0 3px rgba(26, 58, 106, 0.1);
}

.chat-window-footer .send-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1A3A6A, #2D5A8A);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-window-footer .send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(26, 58, 106, 0.4);
}

.chat-window-footer .send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================
   后台 - 消息中心
   ============================================================ */
.chat-admin-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 0;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    height: calc(100vh - 160px);
    min-height: 500px;
}

.chat-conv-list {
    border-right: 1px solid #E8EDF4;
    overflow-y: auto;
    background: #FAFBFC;
}

.chat-conv-list .conv-header {
    padding: 16px 20px;
    border-bottom: 1px solid #E8EDF4;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-conv-list .conv-header h3 {
    font-size: 15px;
    margin: 0;
    color: #1A3A6A;
}

.chat-conv-list .conv-header .total-badge {
    background: #1A3A6A;
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.chat-conv-item {
    padding: 14px 18px;
    border-bottom: 1px solid #F0F4F8;
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
}

.chat-conv-item:hover {
    background: #F0F5FA;
}

.chat-conv-item.active {
    background: #E8F0F8;
    border-left: 3px solid #1A3A6A;
    padding-left: 15px;
}

.chat-conv-item .conv-name {
    font-weight: 600;
    font-size: 14px;
    color: #1A2332;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-conv-item .conv-name .unread-badge {
    background: #DC2626;
    color: #fff;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-conv-item .conv-preview {
    font-size: 13px;
    color: #5A6B7C;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.chat-conv-item .conv-time {
    font-size: 11px;
    color: #999;
}

.chat-admin-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
}

.chat-admin-main .main-header {
    padding: 16px 24px;
    border-bottom: 1px solid #E8EDF4;
    background: #fff;
    flex-shrink: 0;
}

.chat-admin-main .main-header h4 {
    font-size: 15px;
    margin: 0 0 4px;
    color: #1A2332;
}

.chat-admin-main .main-header .sub {
    font-size: 12px;
    color: #999;
}

.chat-admin-main .main-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    background: #F5F8FC;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-admin-main .main-footer {
    padding: 14px 20px;
    border-top: 1px solid #E8EDF4;
    background: #fff;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-admin-main .main-footer textarea {
    flex: 1;
    resize: none;
    border: 2px solid #E8EDF4;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    min-height: 44px;
    max-height: 120px;
    outline: none;
    transition: all 0.3s;
}

.chat-admin-main .main-footer textarea:focus {
    border-color: #1A3A6A;
    box-shadow: 0 0 0 3px rgba(26, 58, 106, 0.1);
}

.chat-admin-main .main-footer .send-btn {
    padding: 10px 24px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1A3A6A, #2D5A8A);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    flex-shrink: 0;
}

.chat-admin-main .main-footer .send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(26, 58, 106, 0.4);
}

.chat-admin-main .main-footer .send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-admin-main .empty-conv {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    gap: 12px;
}

.chat-admin-main .empty-conv .icon {
    font-size: 64px;
    opacity: 0.3;
}

.sidebar-nav a .nav-unread-badge {
    margin-left: auto;
    background: #DC2626;
    color: #fff;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 768px) {
    .chat-float-wrap {
        right: 16px;
        bottom: 16px;
        gap: 6px;
    }
    .chat-float-btn {
        width: 52px;
        height: 52px;
        font-size: 22px;
    }
    .chat-float-label {
        font-size: 11px;
        padding: 4px 10px;
    }
    .chat-window {
        right: 8px;
        bottom: 100px;
        width: calc(100vw - 16px);
        height: calc(100vh - 120px);
        border-radius: 12px;
    }
    .chat-admin-container {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
    }
    .chat-conv-list {
        max-height: 240px;
        border-right: none;
        border-bottom: 1px solid #E8EDF4;
    }
    .chat-admin-main {
        min-height: 500px;
    }
}