/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1890ff;
    --success-color: #52c41a;
    --warning-color: #faad14;
    --error-color: #f5222d;
    --text-primary: #262626;
    --text-secondary: #595959;
    --text-disabled: #bfbfbf;
    --border-color: #e8e8e8;
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --bg-hover: #f5f5f5;
    --sidebar-width: 240px;
    --topbar-height: 64px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    line-height: 1.5;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
}

.sidebar-nav {
    padding: 16px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.3s;
    border-left: 3px solid transparent;
}

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

.nav-item.active {
    background: #e6f7ff;
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.nav-item .icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
}

/* 主内容区 */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

/* 顶部栏 */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-left {
    display: flex;
    align-items: center;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    position: relative;
    cursor: pointer;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--border-color);
    transition: border-color 0.3s;
}

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

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-primary);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 150px;
    display: none;
    z-index: 1000;
    overflow: hidden;
    animation: fadeIn 0.2s ease-out;
    padding-top: 4px;
}

/* 使用伪元素在下拉菜单上方创建一个"桥接"区域，避免鼠标移动时失去hover */
.user-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
    background: transparent;
}

.user-info:hover .user-dropdown,
.user-dropdown:hover,
.user-dropdown.show {
    display: block;
}

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

.user-dropdown-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.3s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    gap: 8px;
    pointer-events: auto;
    font-family: inherit;
}

.user-dropdown-item:focus {
    outline: none;
    background: var(--bg-hover);
}

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

.user-dropdown-item:active {
    background: var(--bg-secondary);
}

.user-dropdown-item .icon {
    width: 16px;
    height: 16px;
}

.username {
    color: var(--text-secondary);
}

.user-info .icon {
    width: 20px;
    height: 20px;
}

/* 页面内容 */
.page-content {
    flex: 1;
    padding: 24px;
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 24px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s, box-shadow 0.3s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
}

.stat-icon svg {
    width: 28px;
    height: 28px;
}

.stat-icon.blue {
    background: #e6f7ff;
    color: var(--primary-color);
}

.stat-icon.green {
    background: #f6ffed;
    color: var(--success-color);
}

.stat-icon.orange {
    background: #fff7e6;
    color: var(--warning-color);
}

.stat-icon.purple {
    background: #f9f0ff;
    color: #722ed1;
}

.stat-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
}

/* 快捷操作 */
.quick-actions {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

/* 按钮样式 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
    text-decoration: none;
    height: 36px;
    line-height: 1;
    box-sizing: border-box;
}

.btn .icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #40a9ff;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background: #ff4d4f;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #73d13d;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 4px 8px;
    text-decoration: none;
}

.btn-link:hover {
    text-decoration: underline;
}

/* 表格 */
.table-container {
    background: var(--bg-primary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
    position: relative;
    z-index: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-secondary);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

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

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

/* 标签 */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    margin-right: 4px;
}

.badge-blue {
    background: #e6f7ff;
    color: var(--primary-color);
}

.badge-green {
    background: #f6ffed;
    color: var(--success-color);
}

.badge-orange {
    background: #fff7e6;
    color: var(--warning-color);
}

.badge-red {
    background: #fff1f0;
    color: var(--error-color);
}

/* 状态 */
.status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.status-success {
    background: #f6ffed;
    color: var(--success-color);
}

.status-processing {
    background: #e6f7ff;
    color: var(--primary-color);
}

.status-pending {
    background: #fff7e6;
    color: var(--warning-color);
}

.status-failed {
    background: #fff1f0;
    color: var(--error-color);
}

.status-paused {
    background: #f5f5f5;
    color: var(--text-secondary);
}

/* 最近任务 */
.recent-tasks {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 14px;
}

.link:hover {
    text-decoration: underline;
}

/* 表单样式 */
.form-container {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    max-width: 800px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-label .required {
    color: var(--error-color);
    margin-left: 4px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.form-input,
.form-select {
    height: 36px;
    line-height: 1;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-help {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

/* 复选框和单选框 */
.checkbox-group,
.radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.checkbox-item,
.radio-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-item input,
.radio-item input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* 卡片 */
.card {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
}

/* 搜索和筛选 */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
    z-index: 1;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    height: 36px;
    box-sizing: border-box;
}

.filter-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.pagination button:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

/* 模态框 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--bg-primary);
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: var(--bg-hover);
}

.modal-body {
    padding: 24px;
    flex: 1;
    min-height: 80px;
    display: flex;
    align-items: flex-start;
}

.modal-body p {
    margin: 0;
    line-height: 1.6;
    color: var(--text-primary);
    font-size: 14px;
    width: 100%;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* 提示框 */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    background: var(--bg-primary);
    border-radius: 4px;
    padding: 14px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    z-index: 2000;
    min-width: 300px;
    min-height: 48px;
    box-sizing: border-box;
}

.toast .icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast span {
    flex: 1;
    line-height: 1.5;
    font-size: 14px;
    color: var(--text-primary);
}

.toast.show {
    display: flex;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--error-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

.toast.info {
    border-left: 4px solid var(--primary-color);
}

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

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 14px;
    margin-bottom: 16px;
}

/* 标签选择器 */
.tag-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    gap: 6px;
}

.tag-item.selected {
    background: #e6f7ff;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.tag-item .remove {
    cursor: pointer;
    padding: 0 4px;
}

/* 时间选择器 */
.datetime-input {
    display: flex;
    gap: 8px;
}

.datetime-input input {
    flex: 1;
}

/* 表单步骤 */
.form-step {
    display: block;
}

/* 步骤条 */
.steps {
    display: flex;
    margin-bottom: 32px;
    position: relative;
}

.step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.step::after {
    content: '';
    position: absolute;
    top: 16px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: var(--border-color);
    z-index: 0;
}

.step:last-child::after {
    display: none;
}

.step.active::after {
    background: var(--primary-color);
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.step.active .step-number {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.step.completed .step-number {
    background: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

.step-title {
    font-size: 14px;
    color: var(--text-secondary);
}

.step.active .step-title {
    color: var(--primary-color);
    font-weight: 600;
}

/* Tab组件 */
.tabs {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.tab-list {
    display: flex;
    gap: 0;
    list-style: none;
    padding: 0;
    margin: 0;
}

.tab-item {
    padding: 12px 24px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.3s;
    position: relative;
    background: none;
    border: none;
    outline: none;
}

.tab-item:hover {
    color: var(--primary-color);
}

.tab-item.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.tab-content {
    display: none;
}

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

.tab-content .card-header {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* 响应式 */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .sidebar.show {
        transform: translateX(0);
    }

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

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

