/* 侧边栏样式 */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 200px;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    margin: 2px 0;
    white-space: nowrap;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: white;
    background-color: rgba(255, 255, 255, 0.2);
}

.sidebar .nav-section {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 1rem 0.75rem 0.5rem;
}

.sidebar .nav-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin: 0.75rem 0;
}

/* 主内容区域包装器 */
.main-content-wrapper {
    margin-left: 200px;
    min-height: 100vh;
}

/* 主内容区域样式 */
.main-content {
    background-color: #f8f9fa;
    min-height: 100vh;
}

.main-content::-webkit-scrollbar {
    width: 8px;
}

.main-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.main-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.main-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 登录页面样式 */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

/* 统计卡片样式 */
.stats-card {
    border: none;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* 表格样式 */
.table-hover tbody tr:hover {
    background-color: #f8f9fa;
}

.status-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
}

/* 分页样式 */
.pagination .page-link {
    color: #667eea;
}

.pagination .page-item.active .page-link {
    background-color: #667eea;
    border-color: #667eea;
    color: white;
}

/* 模态框样式 */
.modal-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

/* 最近活动样式 */
.timeline {
    max-height: 400px;
    overflow-y: auto;
}

.recent-activity-item {
    border-left: 3px solid #667eea;
    padding-left: 1rem;
    margin-bottom: 1rem;
}

.recent-activity-item:last-child {
    margin-bottom: 0;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .sidebar {
        left: -200px;
        transition: left 0.3s ease;
    }

    .sidebar.show {
        left: 0;
    }

    .main-content-wrapper {
        margin-left: 0;
    }
}

/* 页面内容过渡效果 */
.page-content {
    animation: fadeIn 0.3s ease;
}

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

/* 加载动画 */
.loading-spinner {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 表单增强样式 */
.form-control:focus,
.form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.btn-primary {
    background-color: #667eea;
    border-color: #667eea;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: #5a6fd6;
    border-color: #5a6fd6;
}

/* 图片预览 */
.image-preview-container img {
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Badge 文字颜色修复 */
.badge-warning {
    color: #212529 !important;
}

.badge-info {
    color: #212529 !important;
}

.badge-light {
    color: #212529 !important;
}

/* ==================== 客服聊天 ==================== */

/* 客服登录卡片 */
.cs-login-container {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.cs-login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.cs-login-card .cs-logo {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 12px;
}

/* 主聊天容器 */
.cs-chat-wrapper {
    display: flex;
    height: calc(100vh - 56px);
    background: #f5f6fa;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* 左侧 - 会话列表 */
.cs-sidebar {
    width: 320px;
    background: #fff;
    border-right: 1px solid #e6e8ec;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.cs-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #e6e8ec;
    background: #fafbfc;
}

.cs-sidebar-header .cs-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cs-sidebar-header .cs-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
}

.cs-sidebar-header .cs-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cs-sidebar-header .cs-user-meta {
    flex: 1;
    min-width: 0;
}

.cs-sidebar-header .cs-user-name {
    font-weight: 600;
    font-size: 14px;
    color: #1f2329;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cs-sidebar-header .cs-user-status {
    font-size: 12px;
    color: #8f959e;
    line-height: 1.2;
    margin-top: 2px;
}

.cs-sidebar-header .cs-user-status .status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00b96b;
    margin-right: 4px;
    vertical-align: middle;
}

.cs-sidebar-header .cs-user-status .status-dot.offline {
    background: #c9cdd4;
}

.cs-sidebar-header .cs-user-status .status-dot.connecting {
    background: #ff8800;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.cs-chat-list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 0;
}

.cs-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f1f3;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.cs-chat-item:hover {
    background: #f7f8fa;
}

.cs-chat-item.active {
    background: #e8f0fe;
}

.cs-chat-item .cs-item-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #e6e8ec;
    color: #8f959e;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.cs-chat-item .cs-item-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cs-chat-item .cs-item-avatar .cs-unread-dot {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #f56565;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid #fff;
    box-sizing: border-box;
    transform: translate(30%, -30%);
}

.cs-chat-item .cs-item-content {
    flex: 1;
    min-width: 0;
}

.cs-chat-item .cs-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.cs-chat-item .cs-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #1f2329;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.cs-chat-item .cs-item-time {
    font-size: 11px;
    color: #8f959e;
    flex-shrink: 0;
    margin-left: 8px;
}

.cs-chat-item .cs-item-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.cs-chat-item .cs-item-preview {
    font-size: 12px;
    color: #8f959e;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.cs-chat-item.active .cs-item-preview,
.cs-chat-item.active .cs-item-name {
    color: #1f2329;
}

.cs-chat-item.has-unread .cs-item-preview {
    color: #1f2329;
    font-weight: 500;
}

.cs-chat-list-empty {
    padding: 40px 20px;
    text-align: center;
    color: #8f959e;
    font-size: 13px;
}

/* 右侧 - 聊天区域 */
.cs-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #f5f6fa;
}

.cs-main-header {
    height: 60px;
    padding: 0 20px;
    background: #fff;
    border-bottom: 1px solid #e6e8ec;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.cs-main-header .cs-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
    color: #1f2329;
}

.cs-main-header .cs-chat-title .cs-online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00b96b;
}

.cs-main-header .cs-chat-title .cs-online-dot.offline {
    background: #c9cdd4;
}

.cs-main-header .cs-chat-actions {
    display: flex;
    gap: 8px;
}

.cs-main-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8f959e;
    font-size: 14px;
    flex-direction: column;
    gap: 12px;
}

.cs-main-empty i {
    font-size: 64px;
    color: #d6d8dd;
}

/* 消息列表 */
.cs-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cs-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    max-width: 70%;
    animation: cs-fade-in 0.2s ease-out;
}

@keyframes cs-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.cs-message.cs-own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cs-message .cs-msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e6e8ec;
    color: #8f959e;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
}

.cs-message .cs-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cs-message .cs-msg-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.cs-message.cs-own .cs-msg-body {
    align-items: flex-end;
}

.cs-message .cs-msg-meta {
    font-size: 11px;
    color: #8f959e;
    padding: 0 4px;
}

.cs-message .cs-msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    background: #fff;
    color: #1f2329;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.cs-message.cs-own .cs-msg-bubble {
    background: #667eea;
    color: #fff;
}

.cs-message .cs-msg-image {
    max-width: 240px;
    max-height: 240px;
    border-radius: 8px;
    cursor: pointer;
}

.cs-message .cs-msg-status {
    font-size: 11px;
    color: #8f959e;
    padding: 0 4px;
}

.cs-message .cs-msg-status.cs-failed {
    color: #f56565;
}

.cs-message .cs-msg-sending {
    opacity: 0.6;
}

.cs-message-system {
    align-self: center;
    background: rgba(0, 0, 0, 0.05);
    color: #8f959e;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 10px;
}

/* 输入区域 */
.cs-input-area {
    padding: 12px 20px;
    background: #fff;
    border-top: 1px solid #e6e8ec;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.cs-input-area textarea {
    flex: 1;
    resize: none;
    border-radius: 8px;
    border: 1px solid #e6e8ec;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.5;
    max-height: 120px;
    min-height: 40px;
}

.cs-input-area textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.15);
}

.cs-input-area .cs-send-btn {
    height: 40px;
    padding: 0 20px;
    border-radius: 8px;
    background: #667eea;
    color: #fff;
    border: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s;
}

.cs-input-area .cs-send-btn:hover:not(:disabled) {
    background: #5a6fd6;
}

.cs-input-area .cs-send-btn:disabled {
    background: #c9cdd4;
    cursor: not-allowed;
}

/* 加载与提示 */
.cs-loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e6e8ec;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    vertical-align: middle;
}

.cs-typing-indicator {
    font-size: 12px;
    color: #8f959e;
    padding: 4px 16px;
    height: 20px;
    flex-shrink: 0;
}

/* 侧边栏徽章 */
.nav-link .cs-nav-badge,
.nav-link .order-nav-badge {
    background: #f56565;
    color: #fff;
    border-radius: 10px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    margin-left: auto;
    min-width: 18px;
    text-align: center;
    line-height: 18px;
    height: 18px;
    display: inline-block;
}

/* 消息列表滚动条 */
.cs-chat-list::-webkit-scrollbar,
.cs-messages::-webkit-scrollbar {
    width: 6px;
}

.cs-chat-list::-webkit-scrollbar-thumb,
.cs-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.cs-chat-list::-webkit-scrollbar-thumb:hover,
.cs-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .cs-chat-wrapper {
        height: calc(100vh - 56px);
    }
    .cs-sidebar {
        width: 100%;
    }
    .cs-main {
        display: none;
    }
    .cs-chat-wrapper.cs-show-main .cs-sidebar {
        display: none;
    }
    .cs-chat-wrapper.cs-show-main .cs-main {
        display: flex;
    }
}
