/* ============================================
   企业级办公协同系统 - 专业UI设计
   参考：阿里云、腾讯云、企业微信、钉钉
   ============================================ */

/* ========== 全局变量 ========== */
:root {
    --primary: #1890ff;
    --primary-hover: #40a9ff;
    --success: #52c41a;
    --warning: #faad14;
    --error: #ff4d4f;
    --info: #13c2c2;
    
    --text-title: #262626;
    --text-primary: #595959;
    --text-secondary: #8c8c8c;
    
    --bg-body: #f5f7fa;
    --bg-white: #ffffff;
    --bg-hover: #fafafa;
    
    --border-base: #e8e8e8;
    --border-split: #f0f0f0;
    
    --shadow-1: 0 2px 8px rgba(0, 0, 0, 0.09);
    --shadow-2: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* ========== 全局样式 ========== */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5715;
    color: var(--text-title);
    background: var(--bg-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
}

/* ========== 动态背景（优化性能） ========== */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(24, 144, 255, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(82, 196, 26, 0.04) 0%, transparent 50%);
    z-index: 0;
    pointer-events: none;
    will-change: transform;
}

/* ========== 导航栏 ========== */
.navbar {
    background: linear-gradient(135deg, #001529 0%, #002140 100%) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 0;
    height: 64px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 1000;
}

.navbar .container-fluid {
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
}

.navbar-brand {
    font-size: 20px;
    font-weight: 600;
    color: #ffffff !important;
    margin-right: 48px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-brand i {
    font-size: 24px;
    color: var(--primary);
}

.navbar-nav {
    display: flex;
    align-items: center;
}

.navbar-nav.main-nav {
    flex: 1;
}

.navbar-nav.user-nav {
    flex: 0 0 auto;
    margin-left: auto;
}

.navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
    font-size: 14px;
    font-weight: 400;
    padding: 0 16px !important;
    height: 64px;
    line-height: 64px;
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.navbar-nav .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: var(--primary);
    transform: translateX(-50%);
    transition: width 0.2s;
}

.navbar-nav .nav-link:hover {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.08);
}

.navbar-nav .nav-link:hover::after {
    width: 60%;
}

.navbar-nav .nav-link.active {
    color: #ffffff !important;
    background: rgba(24, 144, 255, 0.2);
    font-weight: 500;
}

.navbar-nav .nav-link.active::after {
    width: 100%;
}

.navbar-nav .nav-link i {
    font-size: 16px;
}

/* 用户下拉菜单 */
.dropdown-menu {
    min-width: 160px;
    padding: 4px 0;
    background: var(--bg-white);
    border: 1px solid var(--border-base);
    border-radius: 6px;
    box-shadow: var(--shadow-2);
    margin-top: 8px;
}

.dropdown-item {
    padding: 10px 16px;
    color: var(--text-title);
    font-size: 14px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

/* ========== 主内容区 ========== */
.container-fluid {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.page-content {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ========== 欢迎横幅 ========== */
.welcome-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    padding: 32px 40px;
    margin-bottom: 24px;
    color: #ffffff;
    box-shadow: var(--shadow-2);
    position: relative;
    overflow: hidden;
}

.welcome-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, transparent 70%);
    animation: rotate 20s linear infinite;
    will-change: transform;
}

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

.welcome-banner h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #ffffff;
    position: relative;
    z-index: 1;
}

.welcome-banner p {
    font-size: 14px;
    opacity: 0.95;
    margin: 0;
    color: #ffffff;
    position: relative;
    z-index: 1;
}

/* ========== 统计卡片 ========== */
.stat-card {
    background: var(--bg-white);
    border-radius: 8px;
    padding: 24px;
    box-shadow: var(--shadow-1);
    transition: box-shadow 0.3s, border-color 0.3s;
    border: 1px solid var(--border-split);
    height: 100%;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--primary);
    transition: width 0.3s;
}

.stat-card:hover {
    box-shadow: var(--shadow-2);
    border-color: var(--primary);
}

.stat-card:hover::before {
    width: 100%;
}

.stat-card .card-title {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
}

.stat-card .card-title i {
    font-size: 16px;
}

.stat-card .card-text {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-title);
    line-height: 1.2;
    margin: 0;
}

/* 不同颜色的统计卡片 */
.stat-card.primary .card-title i,
.stat-card.primary .card-text {
    color: var(--primary);
}

.stat-card.success .card-title i,
.stat-card.success .card-text {
    color: var(--success);
}

.stat-card.warning .card-title i,
.stat-card.warning .card-text {
    color: var(--warning);
}

.stat-card.info .card-title i,
.stat-card.info .card-text {
    color: var(--info);
}

/* ========== 卡片 ========== */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border-split);
    border-radius: 8px;
    box-shadow: var(--shadow-1);
    margin-bottom: 24px;
    overflow: hidden;
    transition: box-shadow 0.3s;
}

.card:hover {
    box-shadow: var(--shadow-2);
}

.card-header {
    background: #fafafa;
    border-bottom: 1px solid var(--border-split);
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-title);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header i {
    margin-right: 10px;
    color: var(--primary);
    font-size: 16px;
}

.card-body {
    padding: 24px;
}

/* ========== 表格 ========== */
.table {
    margin-bottom: 0;
    color: var(--text-title);
}

.table thead th {
    background: #fafafa;
    border-bottom: 2px solid var(--border-split);
    font-weight: 600;
    color: var(--text-title);
    font-size: 14px;
    padding: 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 16px;
    border-bottom: 1px solid var(--border-split);
    color: var(--text-title);
    font-size: 14px;
}

/* 表格行样式 - 移除transition避免闪烁 */

.table tbody tr:hover {
    background: var(--bg-hover);
}

/* 系统管理表格优化 */
.admin-table th,
.admin-table td {
    vertical-align: middle;
}

.admin-table th:last-child,
.admin-table td:last-child {
    white-space: nowrap;
}

.admin-table .action-btn {
    min-width: 88px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.status-btn {
    min-width: 72px;
    font-weight: 500;
}

.dept-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

/* 个人信息模态 */
#profileInfo dt {
    font-weight: 600;
    color: var(--text-secondary);
}

#profileInfo dd {
    margin-bottom: 12px;
    color: var(--text-title);
}

.permission-section .card-header {
    background: #f0f5ff;
    border-bottom: 1px solid var(--border-split);
}

.permission-section .card-header h6 {
    font-weight: 600;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.permission-section .card-body {
    padding: 20px;
}

.permission-section .form-check {
    background: #fff;
    border: 1px solid var(--border-split);
    border-radius: 6px;
    padding: 10px 14px;
}

.permission-section .btn {
    min-width: 150px;
}

/* 修复文件管理表格布局 */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* 移除可能导致闪烁的效果 */
    position: relative;
}

.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: var(--bg-body);
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: var(--border-base);
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.table {
    min-width: 800px;
    table-layout: fixed;
}

.table th,
.table td {
    word-wrap: break-word;
    overflow-wrap: break-word;
    vertical-align: middle;
}

.table th {
    white-space: nowrap;
}

.table td {
    white-space: normal;
    line-height: 1.6;
}

.table td:not(:last-child) {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 200px;
}

.table th:nth-child(1),
.table td:nth-child(1) {
    width: 25%;
    max-width: 300px;
    white-space: normal;
}

.table th:nth-child(2),
.table td:nth-child(2) {
    width: 10%;
}

.table th:nth-child(3),
.table td:nth-child(3) {
    width: 12%;
}

.table th:nth-child(4),
.table td:nth-child(4) {
    width: 15%;
}

.table th:nth-child(5),
.table td:nth-child(5) {
    width: 18%;
}

.table th:nth-child(6),
.table td:nth-child(6) {
    width: 25%;
    white-space: normal;
    min-width: 350px;
    max-width: none;
}

.table td .btn {
    margin: 2px 4px;
    padding: 8px 14px;
    font-size: 13px;
    min-width: 70px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1.4;
    vertical-align: middle;
}

.table td .btn i {
    margin-right: 0;
    font-size: 12px;
    flex-shrink: 0;
}

/* 确保按钮文字可见和居中 */
.table td .btn:not(:only-child) {
    padding: 8px 12px;
    min-width: 70px;
}

.table td .btn:only-child {
    padding: 8px 16px;
    min-width: 80px;
}

/* 按钮容器防止重叠 */
.table td > div {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    justify-content: flex-start;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ========== 按钮 ========== */
.btn {
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5715;
    border: 1px solid var(--border-base);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
}

.btn:hover {
    border-color: var(--primary-hover);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #ffffff;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #ffffff;
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: #ffffff;
}

.btn-danger {
    background: var(--error);
    border-color: var(--error);
    color: #ffffff;
}

.btn-info {
    background: var(--info);
    border-color: var(--info);
    color: #ffffff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* ========== 通知列表 ========== */
.notice-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-split);
    transition: background-color 0.2s;
}

.notice-item:hover {
    background: var(--bg-hover);
}

.notice-item:last-child {
    border-bottom: none;
}

.notice-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-title);
    margin-bottom: 8px;
    line-height: 1.6;
}

.notice-title a {
    color: var(--text-title);
    text-decoration: none;
}

.notice-title a:hover {
    color: var(--primary);
}

.notice-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.notice-meta i {
    font-size: 12px;
}

/* ========== 任务列表 ========== */
.task-item {
    padding: 16px;
    border-left: 3px solid var(--primary);
    margin-bottom: 12px;
    background: var(--bg-white);
    border-radius: 6px;
    border: 1px solid var(--border-split);
    transition: box-shadow 0.2s;
    box-shadow: var(--shadow-1);
}

.task-item:hover {
    box-shadow: var(--shadow-2);
}

.task-status-pending {
    border-left-color: var(--warning);
}

.task-status-processing {
    border-left-color: var(--info);
}

.task-status-reviewing {
    border-left-color: #722ed1;
}

.task-status-completed {
    border-left-color: var(--success);
}

/* ========== 审批列表 ========== */
.approval-item {
    padding: 16px;
    border: 1px solid var(--border-split);
    border-left: 3px solid var(--warning);
    border-radius: 6px;
    margin-bottom: 12px;
    background: var(--bg-white);
    transition: box-shadow 0.2s;
    box-shadow: var(--shadow-1);
}

.approval-item:hover {
    box-shadow: var(--shadow-2);
}

.approval-status-pending {
    border-left-color: var(--warning);
}

.approval-status-approved {
    border-left-color: var(--success);
}

.approval-status-rejected {
    border-left-color: var(--error);
}

/* ========== 表单 ========== */
.form-control,
.form-select {
    border: 1px solid var(--border-base);
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 14px;
    color: var(--text-title);
    background: var(--bg-white);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
    outline: none;
}

.form-label {
    font-weight: 500;
    color: var(--text-title);
    margin-bottom: 8px;
    font-size: 14px;
}

/* ========== 面包屑 ========== */
.breadcrumb {
    background: var(--bg-white);
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    border: 1px solid var(--border-split);
    box-shadow: var(--shadow-1);
}

.breadcrumb-item a {
    color: var(--primary);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--text-secondary);
}

/* ========== 标签页 ========== */
.nav-tabs {
    border-bottom: 2px solid var(--border-split);
    margin-bottom: 16px;
}

.nav-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 12px 16px;
    margin-right: 8px;
    transition: color 0.2s, border-bottom-color 0.2s;
    font-weight: 400;
}

.nav-tabs .nav-link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
}

.nav-tabs .nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
    background: transparent;
}

.nav-pills .nav-link {
    border-radius: 4px;
    padding: 8px 16px;
    color: var(--text-secondary);
    font-size: 14px;
    transition: background-color 0.2s, color 0.2s;
}

.nav-pills .nav-link:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.nav-pills .nav-link.active {
    background: var(--primary);
    color: #ffffff;
}

/* ========== 徽章 ========== */
.badge {
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
    line-height: 1.5;
}

.badge.bg-danger {
    background: var(--error) !important;
}

.badge.bg-success {
    background: var(--success) !important;
}

.badge.bg-warning {
    background: var(--warning) !important;
}

.badge.bg-info {
    background: var(--info) !important;
}

.badge.bg-primary {
    background: var(--primary) !important;
}

/* ========== 模态框 ========== */
.modal-content {
    border: none;
    border-radius: 8px;
    box-shadow: var(--shadow-2);
}

.modal-header {
    border-bottom: 1px solid var(--border-split);
    padding: 16px 24px;
    background: var(--bg-white);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-title);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid var(--border-split);
    padding: 12px 24px;
    background: var(--bg-white);
}

/* ========== 空状态 ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    color: #d9d9d9;
    display: block;
    }
    
.empty-state p {
    font-size: 14px;
    margin: 0;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ========== 加载动画 ========== */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner-border {
    width: 32px;
    height: 32px;
    border-width: 3px;
    border-color: var(--primary);
    border-right-color: transparent;
    animation: spin 0.8s linear infinite;
}

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

/* ========== 响应式 ========== */
@media (max-width: 1200px) {
    .container-fluid {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .container-fluid {
        padding: 16px;
}

    .card-body {
        padding: 16px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-card .card-text {
        font-size: 28px;
    }
    
    .welcome-banner {
        padding: 24px;
    }
    
    .welcome-banner h2 {
        font-size: 20px;
    }
}

/* ========== 滚动条美化 ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
    background: var(--border-base);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ========== 小助手 ========== */
.ai-assistant-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(24, 144, 255, 0.4);
    cursor: pointer;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
}

.ai-assistant-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(24, 144, 255, 0.5);
}

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

.ai-message {
    margin-bottom: 20px;
    display: flex;
    animation: fadeIn 0.3s ease;
}

.ai-message.ai-user {
    justify-content: flex-end;
}

.ai-message.ai-user .message-content {
    background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
    max-width: 70%;
}

.ai-message.ai-system .message-content {
    background: #fff;
    color: var(--text-title);
    border-radius: 18px 18px 18px 4px;
    max-width: 70%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message-content {
    padding: 12px 16px;
    line-height: 1.6;
    word-wrap: break-word;
}

.message-content i {
    margin-right: 8px;
    color: var(--primary);
}

.ai-input-container {
    position: sticky;
    bottom: 0;
    background: #fff;
    z-index: 10;
}

/* 确保AI助手弹窗在最上层 */
#aiAssistantModal {
    z-index: 1055 !important;
}

#aiAssistantModal .modal-dialog {
    z-index: 1056 !important;
}

#aiAssistantModal .modal-content {
    z-index: 1057 !important;
}

#aiChatContainer {
    min-height: 400px;
    max-height: 500px;
}

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