/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* 登录/注册页面 */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.auth-box h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 30px;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: #f0f0f0;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s;
}

.tab-btn.active {
    background: #667eea;
    color: white;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* 按钮 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    margin: 0 2px;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.auth-form .btn-primary {
    width: 100%;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-warning {
    background: #ffc107;
    color: #333;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

/* 仪表板 */
.dashboard {
    min-height: 100vh;
    background: #f5f7fa;
}

.dashboard-header,
.user-header,
.cs-header {
    background: white;
    padding: 20px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 统计卡片 */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
    color: #666;
    font-size: 14px;
    margin-bottom: 10px;
}

.stat-card p {
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

/* 用户信息 */
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.status-badge {
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.working {
    background: #d4edda;
    color: #155724;
}

.status-badge.resting {
    background: #f8d7da;
    color: #721c24;
}

/* 聊天区域 */
.chat-container {
    background: white;
    margin: 20px 30px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

/* 客服端聊天容器 */
.cs-main .chat-container {
    margin: 0;
    flex: 1;
    min-height: 0;
}

.chat-header {
    background: #667eea;
    color: white;
    padding: 15px 20px;
    flex-shrink: 0;
}

.chat-messages {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
    flex: 1;
    min-height: 400px;
}

/* 客服端聊天消息区域 */
.cs-main .chat-messages {
    height: auto;
    flex: 1;
    min-height: 0;
}

.message {
    margin-bottom: 15px;
}

.message.sent {
    text-align: right;
}

.message.received {
    text-align: left;
}

.message-content {
    display: inline-block;
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 10px;
    word-wrap: break-word;
}

.message.sent .message-content {
    background: #667eea;
    color: white;
}

.message.received .message-content {
    background: #f0f0f0;
    color: #333;
}

.chat-input {
    display: flex;
    padding: 15px 20px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.chat-input input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    margin-right: 10px;
}

.chat-input input:focus {
    outline: none;
    border-color: #667eea;
}

/* 客服端布局 */
.cs-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 20px;
    padding: 20px;
    height: calc(100vh - 80px);
}

.cs-sidebar {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cs-sidebar h3 {
    flex-shrink: 0;
    margin-bottom: 15px;
}

.cs-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
    overflow: hidden;
}

.user-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.user-list-item {
    padding: 10px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.user-list-item:hover,
.user-list-item.active {
    background: #667eea;
    color: white;
}

.control-panel {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.control-buttons {
    display: flex;
    gap: 10px;
}

/* 代理端 */
.invite-section {
    background: white;
    padding: 30px;
    margin: 20px 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.invite-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.invite-card button {
    background: white;
    color: #667eea;
}

/* 数据表格 */
.data-table-container {
    background: white;
    padding: 20px;
    margin: 20px 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

.data-table-container h3 {
    margin-bottom: 15px;
    color: #333;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.data-table td {
    color: #666;
}

.data-table tr:hover {
    background: #f8f9fa;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* 管理后台 */
.admin-dashboard {
    min-height: 100vh;
}

.admin-nav {
    background: white;
    padding: 15px 30px;
    display: flex;
    gap: 10px;
    border-bottom: 1px solid #eee;
}

.nav-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 5px;
    font-weight: 500;
    transition: all 0.3s;
}

.nav-btn:hover {
    background: #f0f0f0;
}

.nav-btn.active {
    background: #667eea;
    color: white;
}

.admin-content {
    padding: 20px 30px;
}

.admin-actions {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.admin-actions select {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    min-width: 200px;
    cursor: pointer;
    transition: all 0.3s;
}

.admin-actions select:focus {
    outline: none;
    border-color: #667eea;
}

.admin-actions select:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

/* 管理后台表格容器 */
.admin-content .data-table-container {
    margin: 0;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

/* 响应式 */
@media (max-width: 768px) {
    .cs-layout {
        grid-template-columns: 1fr;
    }
    
    .stats-cards {
        grid-template-columns: 1fr;
    }
    
    .chat-container {
        margin: 10px;
    }
    
    .data-table-container {
        margin: 10px;
        padding: 15px;
    }

    .modal-content {
        width: 95%;
        max-width: none;
        padding: 20px;
    }

    .permissions-grid {
        grid-template-columns: 1fr;
    }
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

/* 嵌套弹窗层级更高 */
.modal .modal {
    z-index: 1001;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 550px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-30px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h3 {
    margin-bottom: 25px;
    color: #333;
    font-size: 20px;
    font-weight: 600;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* 权限卡片网格 */
.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.permission-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.permission-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.permission-card.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
}

.permission-card input[type="checkbox"] {
    display: none;
}

.permission-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.permission-icon {
    width: 32px;
    height: 32px;
    background: #667eea;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: white;
    flex-shrink: 0;
}

.permission-card.active .permission-icon {
    background: white;
    color: #667eea;
}

.permission-title {
    font-weight: 600;
    font-size: 15px;
    color: #333;
}

.permission-card.active .permission-title {
    color: white;
}

.permission-desc {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
    margin-left: 42px;
}

.permission-card.active .permission-desc {
    color: rgba(255, 255, 255, 0.9);
}

.permission-check {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.permission-card.active .permission-check {
    background: white;
    border-color: white;
}

.permission-card.active .permission-check::after {
    content: '✓';
    color: #667eea;
    font-weight: bold;
    font-size: 14px;
}

/* 权限说明信息框 */
.permission-info {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    padding: 12px 15px;
    border-radius: 5px;
    margin: 15px 0;
}

.permission-info p {
    margin: 0;
    font-size: 13px;
    color: #666;
    line-height: 1.6;
}

.permission-info strong {
    color: #667eea;
}

/* 全选按钮 */
.select-all-btn {
    display: inline-block;
    padding: 8px 16px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    margin-bottom: 15px;
    transition: all 0.3s;
}

.select-all-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* 树状结构样式 - 完全统一.data-table的字体、颜色、样式 */
.tree-container {
    background: white;
    padding: 20px;
    margin: 20px 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.tree-container h3 {
    margin-bottom: 15px;
    color: #333;
    font-weight: 600;
}

.tree-root {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* 树状节点 - 完全对齐.data-table的表格行样式 */
.tree-node {
    margin: 0;
    padding: 0;
}

.tree-node-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;  /* 与.data-table td完全一致 */
    cursor: pointer;  /* 整行可点击 */
    user-select: none;
    transition: background 0.2s;
    border-bottom: 1px solid #eee;  /* 与.data-table th, td完全一致 */
    background: white;
    font-size: 14px;  /* 统一字体大小 */
}

.tree-node-header:hover {
    background: #f8f9fa;  /* 与.data-table tr:hover完全一致 */
}

/* 客户节点没有子节点，不需要点击效果 */
.tree-user-header {
    cursor: default;  /* 普通鼠标指针 */
}

/* 一级菜单（角色组头部）- 参考h3样式并加粗 */
.tree-group-header {
    background: #f8f9fa;  /* 与.data-table th完全一致 */
    font-weight: 700;  /* 加粗 */
    color: #333;
    font-size: 16px;  /* 参考h3，稍大一些 */
    padding: 15px;  /* 增加内边距，更醒目 */
    margin-top: 10px;  /* 不同tab之间的间隔 */
}

.tree-group-header:first-child {
    margin-top: 0;  /* 第一个不需要上边距 */
}

.tree-group-header:hover {
    background: #e9ecef;  /* 稍深一点的hover效果 */
}

/* 二三级菜单（成员节点、代理节点）- 参考h2样式并加粗 */
.tree-member-header,
.tree-agent-header {
    background: white;
    font-weight: 700;  /* 加粗 */
    font-size: 15px;  /* 参考h2，略大于普通文字 */
    padding: 14px 15px;  /* 稍大的内边距 */
}

/* 客户节点 - 普通表格行样式 */
.tree-user-header {
    background: white;
    font-weight: normal;  /* 普通字重 */
    font-size: 14px;
}

/* 展开/折叠按钮 */
.tree-toggle {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: white;
    color: #667eea;
    border: 1px solid #667eea;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.tree-toggle:hover {
    background: #667eea;
    color: white;
}

.tree-toggle.collapsed::after {
    content: '+';
}

.tree-toggle.expanded::after {
    content: '−';
}

/* 占位符（无子节点时） */
.tree-spacer {
    width: 20px;
    flex-shrink: 0;
}

/* 树节点标签（主要信息）- 一级菜单加粗 */
.tree-label {
    flex: 1;
    font-weight: inherit;  /* 继承父元素的字重 */
    color: #333;
    font-size: inherit;  /* 继承父元素的字号 */
    min-width: 150px;
}

/* 表格单元格（数据列） - 完全对齐.data-table td */
.tree-cell {
    color: #666;  /* 与.data-table td完全一致 */
    font-size: 14px;
    font-weight: inherit;  /* 继承父元素的字重 */
    white-space: nowrap;
    padding: 0 10px;
}

/* 文本信息（角色组的统计数据） */
.tree-info-text {
    color: #666;
    font-size: 14px;
    font-weight: normal;  /* 统计数据用普通字重 */
    white-space: nowrap;
    padding: 0 10px;
}

/* 操作按钮区域 */
.tree-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
    align-items: center;
    margin-left: auto;
}

.tree-actions .btn-sm {
    white-space: nowrap;
}

/* 子节点容器 */
.tree-children {
    margin-left: 30px;
    display: none;
    border-left: 2px solid #eee;  /* 层级指示线 */
}

.tree-children.expanded {
    display: block;
}

/* 空状态和加载状态 */
.tree-empty,
.tree-loading {
    padding: 20px;
    text-align: center;
    color: #999;  /* 与其他空状态一致 */
    font-size: 14px;
    font-weight: normal;
    background: #f8f9fa;  /* 与.data-table th完全一致 */
    border-radius: 5px;
    margin: 10px 0;
}

.tree-loading {
    color: #667eea;  /* 加载状态使用主题色 */
}

/* 响应式 */
@media (max-width: 768px) {
    .tree-container {
        margin: 10px;
        padding: 15px;
    }
    
    .tree-node-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
    }
    
    .tree-label {
        min-width: 100%;
        order: -1;
    }
    
    .tree-children {
        margin-left: 15px;
    }
    
    .tree-actions {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .tree-actions .btn-sm {
        flex: 1;
        min-width: calc(50% - 3px);
    }
}

/* 响应式 */
@media (max-width: 768px) {
    .tree-container {
        margin: 10px;
        padding: 15px;
    }
    
    .tree-node-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
    }
    
    .tree-label {
        min-width: 100%;
        order: -1;
    }
    
    .tree-children {
        margin-left: 15px;
    }
    
    .tree-actions {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .tree-actions .btn-sm {
        flex: 1;
        min-width: calc(50% - 3px);
    }
    
    .tree-info {
        flex-wrap: wrap;
        width: 100%;
    }
}



