/* --- 1. 全局样式重置与变量 --- */
:root {
    --primary-bg: #1e293b;      /* 深蓝侧边栏 */
    --primary-hover: #334155;   /* 侧边栏悬停 */
    --accent-color: #d4af37;    /* 金色 */
    --text-light: #f8fafc;
    --text-dark: #334155;
    --text-gray: #64748b;
    --bg-gray: #f1f5f9;
    --white: #ffffff;
    --border-color: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    display: flex;
    height: 100vh;
    background-color: var(--bg-gray);
    color: var(--text-dark);
    overflow: hidden;
}

/* --- 2. 侧边栏样式 (Sidebar) --- */
.sidebar {
    width: 256px;
    background-color: var(--primary-bg);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    transition: width 0.3s;
    flex-shrink: 0;
}

.logo-area {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--text-light);
}

.menu-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

/* 滚动条样式 */
.menu-container::-webkit-scrollbar { width: 4px; }
.menu-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.menu-item {
    cursor: pointer;
}

.menu-header {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
    font-size: 14px;
    color: #cbd5e1;
}

.menu-header:hover {
    background-color: var(--primary-hover);
    color: var(--white);
}

.menu-header.active {
    background-color: rgba(0,0,0,0.2);
    color: var(--white);
}

.menu-icon { 
    margin-right: 10px; 
    width: 20px; 
    text-align: center; 
    font-size: 18px;
    display: inline-block;
    flex-shrink: 0;
}
.arrow-icon { font-size: 12px; transition: transform 0.3s; }
.menu-header.active .arrow-icon { transform: rotate(90deg); }

.submenu {
    display: none;
    background-color: #0f172a; /* 更深的背景 */
}

.submenu.show {
    display: block;
}

.submenu-item {
    padding: 10px 20px 10px 52px;
    font-size: 13px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.submenu-item:hover { color: var(--white); }

.submenu-item.active {
    color: var(--accent-color);
    background-color: rgba(255,255,255,0.05);
    border-left: 3px solid var(--accent-color);
}

.menu-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    background-color: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9px;
    line-height: 1;
    margin-left: 8px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 15px;
    font-size: 12px;
    text-align: center;
    color: #64748b;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* --- 3. 主体内容样式 (Main) --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 顶部导航 (Header) */
.top-header {
    height: 64px;
    background-color: var(--white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

.breadcrumb {
    font-size: 14px;
    color: var(--text-gray);
    display: flex;
    align-items: center;
}
.breadcrumb span { margin: 0 8px; color: #cbd5e1; }
.breadcrumb b { color: var(--text-dark); font-weight: 600; }

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.mobile-icon {
    cursor: pointer;
    color: var(--text-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.mobile-icon:hover {
    color: var(--text-dark);
}

.mobile-icon svg {
    width: 20px;
    height: 20px;
}

.notification { position: relative; cursor: pointer; color: var(--text-gray); }
.badge { position: absolute; top: -2px; right: -2px; width: 8px; height: 8px; background: red; border-radius: 50%; }

.avatar-box {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding-left: 20px;
    border-left: 1px solid var(--border-color);
    position: relative;
}
.avatar { width: 32px; height: 32px; background: var(--primary-bg); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.user-detail h4 { font-size: 14px; color: var(--text-dark); }
.user-detail p { font-size: 12px; color: var(--text-gray); }
.user-menu-arrow {
    width: 16px;
    height: 16px;
    color: var(--text-gray);
    transition: all 0.2s;
    flex-shrink: 0;
}
.avatar-box:hover .user-menu-arrow {
    color: var(--text-dark);
}

/* 用户菜单下拉框 */
.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 160px;
    display: none;
    z-index: 1000;
    overflow: hidden;
}

.user-menu-dropdown.show {
    display: block;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
    color: var(--text-dark);
}

.user-menu-item:hover {
    background-color: var(--bg-gray);
}

.user-menu-item i {
    font-size: 18px;
    color: var(--text-gray);
}

.user-menu-item:hover i {
    color: var(--primary-bg);
}

/* 内容操作区 (Workspace) */
.workspace {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.page-title { font-size: 24px; font-weight: bold; color: #1e293b; }

/* 筛选区 */
.filter-card {
    background: var(--white);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

/* 搜索输入组 - 若存在图标则统一隐藏（不再显示搜索图标） */
.input-group {
    position: relative;
    display: inline-block;
    width: 100%;
}

.form-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
    outline: none;
    background-color: var(--white);
}

.input-group i,
.input-group svg {
    display: none;
}
.form-input:focus { border-color: var(--primary-bg); }

.form-select {
    padding: 8px 30px 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background: var(--white);
    cursor: pointer;
    outline: none;
}

.btn {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.2s;
}
.btn-primary { background: var(--primary-bg); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: #fff; border: 1px solid var(--border-color); color: var(--text-dark); }
.btn-secondary:hover { background: var(--bg-gray); }

/* 表格样式 */
.table-card {
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
    position: relative;
}

.table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
}

/* 表格容器：默认不滚动，超出时自动滚动 */
.table-card:not(.need-scroll) .table-wrapper {
    overflow-x: visible;
}

table { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 14px; 
    table-layout: auto;
    min-width: fit-content; /* 根据内容自适应最小宽度 */
}

/* 表头：不换行 */
th { 
    background: #f8fafc; 
    color: #475569; 
    font-weight: 600; 
    text-align: left; 
    padding: 12px 16px; 
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap; /* 表头不换行 */
    overflow: visible;
}

/* 表格内容：不换行 */
td { 
    padding: 12px 16px; 
    border-bottom: 1px solid var(--border-color); 
    color: #334155;
    white-space: nowrap; /* 内容不换行 */
    overflow: visible;
}

/* 头像列不显示省略号 */
td:has(.avatar-img),
td:has(img.avatar-img) {
    overflow: visible;
    text-overflow: clip;
}

/* 兼容性处理：直接针对包含头像的td */
td .avatar-img {
    margin: 0;
}
tr:hover { background: #f8fafc; }

/* 操作列冻结（仅在需要滚动时启用） */
.table-card.need-scroll .table-wrapper {
    overflow-x: auto; /* 启用横向滚动 */
}

.table-card.need-scroll th:last-child,
.table-card.need-scroll td:last-child {
    position: sticky;
    right: 0;
    background: var(--white);
    z-index: 10;
    box-shadow: -2px 0 4px rgba(0,0,0,0.05);
}

.table-card.need-scroll tr:hover td:last-child {
    background: #f8fafc;
}

/* 操作按钮不换行 */
.action-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
    white-space: nowrap;
}

.status-tag {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.status-green { background: #dcfce7; color: #166534; }
.status-blue { background: #dbeafe; color: #1e40af; }
.status-orange { background: #ffedd5; color: #9a3412; }
.status-red { background: #fee2e2; color: #991b1b; }
.status-gray { background: #f1f5f9; color: #64748b; }

.action-link { color: #1890ff; cursor: pointer; margin-right: 10px; text-decoration: none; }
.action-link:hover { text-decoration: underline; }
.delete-link { color: #dc2626; }

/* 分页组件样式 */
.pagination {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--text-gray);
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 14px;
    color: var(--text-gray);
    white-space: nowrap;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.pagination-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-dark);
    transition: all 0.2s;
    min-width: 36px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--bg-gray);
    border-color: var(--primary-bg);
    color: var(--primary-bg);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
}

.pagination-btn.active {
    background: var(--primary-bg);
    color: #fff;
    border-color: var(--primary-bg);
}

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

.pagination-ellipsis {
    padding: 0 8px;
    color: var(--text-gray);
    font-size: 14px;
}

/* 兼容旧样式 */
.page-btns {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.page-btns button {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    min-width: 36px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.page-btns button:hover:not(:disabled) {
    background: var(--bg-gray);
    border-color: var(--primary-bg);
    color: var(--primary-bg);
}

.page-btns button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
}

.page-btns button.active {
    background: var(--primary-bg);
    color: #fff;
    border-color: var(--primary-bg);
}

/* 占位图 */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: #cbd5e1;
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 14px; margin-top: 8px; }

/* 开关按钮样式 */
.switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 17px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 17px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 13px;
    width: 13px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: #10b981;
}
input:checked + .slider:before {
    transform: translateX(14px);
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}
.modal.show {
    display: flex;
}
.modal-content {
    background-color: var(--white);
    padding: 24px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.modal-header {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 16px;
    color: var(--text-dark);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-close-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-gray);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background-color: var(--bg-gray);
    color: var(--text-dark);
}
.modal-body {
    margin-bottom: 20px;
    color: var(--text-gray);
    line-height: 1.6;
    /* 全局规范：弹框内容区域最大高度70vh，超出则内部滚动 */
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 4px; /* 为滚动条留出空间 */
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* 自定义弹框样式 */
.custom-alert, .custom-confirm {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.custom-alert.show, .custom-confirm.show {
    display: flex;
}

.custom-alert-box, .custom-confirm-box {
    background-color: var(--white);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    max-width: 400px;
    width: 90%;
    overflow: hidden;
    animation: slideDown 0.3s ease;
}

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

@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.custom-alert-header, .custom-confirm-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.custom-alert-close, .custom-confirm-close {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-gray);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    transition: all 0.2s;
}

.custom-alert-close:hover, .custom-confirm-close:hover {
    background-color: var(--bg-gray);
    color: var(--text-dark);
}

.custom-alert-icon, .custom-confirm-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.custom-alert-icon {
    background-color: #dbeafe;
    color: #2563eb;
}

.custom-confirm-icon {
    background-color: #fef3c7;
    color: #d97706;
}

.custom-alert-title, .custom-confirm-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    flex: 1;
}

.custom-alert-body, .custom-confirm-body {
    padding: 24px;
    color: var(--text-gray);
    line-height: 1.6;
    font-size: 14px;
}

.custom-alert-footer, .custom-confirm-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background-color: #f8fafc;
}

.custom-alert-btn, .custom-confirm-btn {
    padding: 8px 20px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-weight: 500;
}

.custom-alert-btn-primary {
    background: var(--primary-bg);
    color: #fff;
}

.custom-alert-btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.custom-confirm-btn-cancel {
    background: #fff;
    border: 1px solid var(--border-color);
    color: var(--text-dark);
}

.custom-confirm-btn-cancel:hover {
    background: var(--bg-gray);
}

.custom-confirm-btn-confirm {
    background: var(--primary-bg);
    color: #fff;
}

.custom-confirm-btn-confirm:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.custom-confirm-btn-danger {
    background: #dc2626;
    color: #fff;
}

.custom-confirm-btn-danger:hover {
    background: #b91c1c;
    transform: translateY(-1px);
}

/* Tab切换样式 */
.tab-header {
    display: inline-flex;
    padding: 0;
    background: none;
    position: relative;
    align-items: flex-end;
}

.tab-actions {
    display: flex;
    gap: 12px;
    margin-left: auto;
    align-items: center;
}

.tab-item {
    padding: 16px 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-gray);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    position: relative;
}

.tab-item:hover {
    color: var(--text-dark);
    background-color: var(--bg-gray);
}

.tab-item.active {
    color: var(--primary-bg);
    border-bottom-color: var(--primary-bg);
    font-weight: 600;
    z-index: 1;
    position: relative;
}

.tab-content {
    display: none;
    padding: 0;
}

.tab-content.active {
    display: block;
}

/* 头像样式 */
.avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--bg-gray);
    border: none;
    display: block;
}

.avatar-upload {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.avatar-upload input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--bg-gray);
    border: 2px solid var(--border-color);
    display: block;
    margin: 0 auto;
}

.avatar-upload-label {
    display: block;
    text-align: center;
    margin-top: 8px;
    color: var(--text-gray);
    font-size: 12px;
    cursor: pointer;
    transition: color 0.2s;
}

.avatar-upload-label:hover {
    color: var(--primary-bg);
}

.avatar-upload label {
    display: block;
    cursor: pointer;
}

.avatar-upload:hover .avatar-preview {
    border-color: var(--primary-bg);
    opacity: 0.8;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}
.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
}
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}
.form-control:focus {
    border-color: var(--primary-bg);
}

/* 密码输入框显隐功能 */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper .form-control {
    padding-right: 40px;
}

.password-toggle-btn {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-gray);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: color 0.2s;
    outline: none;
}

.password-toggle-btn:hover {
    color: var(--primary-bg);
}

.password-toggle-btn:focus {
    color: var(--primary-bg);
}

/* 权限树样式 */
.permission-tree {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--white);
}
.permission-item {
    margin-bottom: 12px;
}
.permission-parent {
    display: flex;
    align-items: center;
    padding: 8px;
    font-weight: 500;
    color: var(--text-dark);
}
.permission-children {
    margin-left: 24px;
    margin-top: 8px;
}
.permission-child {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    color: var(--text-gray);
    font-size: 13px;
}
.permission-checkbox {
    margin-right: 8px;
    cursor: pointer;
}

/* 进度条样式 */
.progress-bar {
    width: 100%;
    height: 16px;
    background-color: #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80 0%, #22c55e 100%);
    border-radius: 8px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: 500;
    position: relative;
    z-index: 2;
}

.progress-bar-fill.low {
    background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 100%);
}

.progress-bar-fill.high {
    background: linear-gradient(90deg, #60a5fa 0%, #3b82f6 100%);
}

.progress-bar-text {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-dark);
    z-index: 1;
}

