/* 丹秋学习力人事工作台 - 全局样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    color: #333;
    font-size: 14px;
}
a { text-decoration: none; color: inherit; }

/* ===== 布局 ===== */
.layout { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
    width: 220px;
    background: #1a1f2e;
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s;
}
.sidebar .logo {
    padding: 18px 16px;
    font-size: 16px;
    font-weight: bold;
    border-bottom: 1px solid #2a3040;
    text-align: center;
    letter-spacing: 1px;
}
.sidebar .menu-group { border-bottom: 1px solid #252b3b; }
.sidebar .menu-title {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #a0a8b8;
    user-select: none;
}
.sidebar .menu-title:hover { color: #fff; background: #222838; }
.sidebar .menu-title .arrow { transition: transform 0.2s; font-size: 10px; }
.sidebar .menu-group.open .menu-title .arrow { transform: rotate(90deg); }
.sidebar .submenu { display: none; }
.sidebar .menu-group.open .submenu { display: block; }
.sidebar .submenu a {
    display: block;
    padding: 10px 16px 10px 32px;
    font-size: 13px;
    color: #8a92a6;
    transition: all 0.15s;
}
.sidebar .submenu a:hover { color: #fff; background: #222838; }
.sidebar .submenu a.active {
    background: #1e3a5f;
    color: #fff;
    border-left: 3px solid #4a9eff;
    padding-left: 29px;
}

/* 主内容区 */
.main {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.topbar {
    background: #fff;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar .page-title { font-size: 17px; font-weight: 600; }
.topbar .user-info { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.topbar .user-info .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: #1e3a5f; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
}
.topbar .menu-toggle { display: none; cursor: pointer; font-size: 20px; }

.content { padding: 20px 24px; flex: 1; }

/* ===== 卡片 ===== */
.card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ===== 统计卡片 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}
.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border-left: 4px solid #1e3a5f;
}
.stat-card .stat-label { font-size: 13px; color: #888; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: bold; color: #1a1f2e; }
.stat-card.green { border-left-color: #52c41a; }
.stat-card.orange { border-left-color: #fa8c16; }
.stat-card.red { border-left-color: #f5222d; }
.stat-card.blue { border-left-color: #1890ff; }
.stat-card.purple { border-left-color: #722ed1; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data-table th {
    background: #fafafa;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #f0f0f0;
    white-space: nowrap;
}
table.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f5f5f5;
}
table.data-table tr:hover { background: #f9fafc; }

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 16px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #1e3a5f; color: #fff; }
.btn-success { background: #52c41a; color: #fff; }
.btn-warning { background: #fa8c16; color: #fff; }
.btn-danger { background: #f5222d; color: #fff; }
.btn-default { background: #f0f0f0; color: #333; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-outline { background: #fff; color: #1e3a5f; border: 1px solid #1e3a5f; }
.btn-outline:hover { background: #1e3a5f; color: #fff; }
.btn-link { background: none; color: #1890ff; padding: 4px 6px; }
.btn-link.danger { color: #f5222d; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: #555;
    font-weight: 500;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: #1e3a5f;
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

/* ===== 徽章 ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}
.badge-green { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.badge-red { background: #fff1f0; color: #f5222d; border: 1px solid #ffa39e; }
.badge-orange { background: #fff7e6; color: #fa8c16; border: 1px solid #ffd591; }
.badge-blue { background: #e6f7ff; color: #1890ff; border: 1px solid #91d5ff; }
.badge-gray { background: #f5f5f5; color: #888; border: 1px solid #d9d9d9; }
.badge-purple { background: #f9f0ff; color: #722ed1; border: 1px solid #d3adf7; }

/* ===== 弹窗 ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 16px;
    overflow-y: auto;
}
.modal-overlay.show { display: flex; }
.modal {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-width: 640px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.modal-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-close { cursor: pointer; font-size: 20px; color: #999; }
.modal-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ===== 分页 ===== */
.pagination {
    margin-top: 16px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.page-btn {
    padding: 6px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 13px;
    color: #555;
}
.page-btn.active { background: #1e3a5f; color: #fff; border-color: #1e3a5f; }

/* ===== 搜索栏 ===== */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.search-bar input, .search-bar select {
    padding: 7px 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 13px;
}

/* ===== 登录页 ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1f2e 0%, #1e3a5f 100%);
}
.login-box {
    background: #fff;
    border-radius: 10px;
    padding: 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.login-box h2 {
    text-align: center;
    margin-bottom: 24px;
    color: #1a1f2e;
    font-size: 20px;
}
.login-box .error-msg {
    background: #fff1f0;
    color: #f5222d;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 13px;
    text-align: center;
}

/* ===== 待办列表 ===== */
.todo-list { list-style: none; }
.todo-list li {
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}
.todo-list li:last-child { border-bottom: none; }

/* ===== 权限矩阵 ===== */
.perm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.perm-table th, .perm-table td {
    padding: 8px 10px;
    border: 1px solid #f0f0f0;
    text-align: center;
}
.perm-table th { background: #fafafa; font-weight: 600; }
.perm-table td:first-child { text-align: left; }

/* ===== 响应式 - 平板（769px ~ 1024px） ===== */
@media (max-width: 1024px) and (min-width: 769px) {
    .sidebar { width: 180px; }
    .sidebar .logo { font-size: 14px; padding: 14px 10px; }
    .sidebar .menu-title { padding: 10px 12px; font-size: 13px; }
    .sidebar .submenu a { padding: 8px 12px 8px 24px; font-size: 12px; }
    .main { margin-left: 180px; }
    .content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
    .stat-card .stat-value { font-size: 24px; }
    .form-row { grid-template-columns: repeat(2, 1fr); }
    .card { padding: 16px; }
}

/* ===== 响应式 - 手机（<=768px） ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 240px;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 99;
    }
    .sidebar-overlay.show { display: block; }
    .main { margin-left: 0; }
    .topbar { padding: 0 14px; height: 50px; }
    .topbar .menu-toggle { display: block; font-size: 18px; }
    .topbar .page-title { font-size: 15px; }
    .topbar .user-info span:not(.avatar) { display: none; }
    .content { padding: 10px; }
    .card { padding: 12px; margin-bottom: 10px; }
    .card-title { font-size: 14px; padding-bottom: 10px; margin-bottom: 12px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { padding: 10px; }
    .stat-card .stat-label { font-size: 11px; }
    .stat-card .stat-value { font-size: 20px; }
    table.data-table { font-size: 12px; }
    table.data-table th, table.data-table td { padding: 7px 5px; }
    .btn { padding: 6px 10px; font-size: 12px; white-space: nowrap; }
    .btn .btn-text { display: inline; }
    .btn-sm { padding: 4px 8px; font-size: 11px; }
    .card-title { flex-direction: column; align-items: flex-start; gap: 8px; }
    .card-title > div { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; }
    .card-title .btn { flex: 1; min-width: 60px; text-align: center; }
    table.data-table .btn-link { display: inline-block; padding: 2px 4px; font-size: 11px; white-space: nowrap; }
    .form-row { grid-template-columns: 1fr; gap: 10px; }
    .form-group { margin-bottom: 10px; }
    .modal { padding: 14px; margin: 0; max-width: 100%; }
    .modal-overlay { padding: 10px; }
    .search-bar { flex-direction: column; align-items: stretch; gap: 8px; }
    .search-bar input, .search-bar select { width: 100%; }
    .pagination { justify-content: center; }
    .page-btn { padding: 5px 10px; font-size: 12px; }
    .todo-list li { font-size: 12px; padding: 8px 0; }
    .perm-table { font-size: 11px; }
    .perm-table th, .perm-table td { padding: 5px 4px; }
    .login-box { padding: 24px; margin: 16px; }
    .badge { font-size: 10px; padding: 1px 6px; }
}

/* ===== 响应式 - 小屏手机（<=480px） ===== */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .stat-card { padding: 8px; }
    .stat-card .stat-value { font-size: 18px; }
    .stat-card .stat-label { font-size: 10px; margin-bottom: 4px; }
    .topbar .page-title { font-size: 14px; }
    .card-title { font-size: 13px; flex-direction: column; align-items: flex-start; gap: 6px; }
    .card-title > div { display: flex; gap: 5px; flex-wrap: wrap; width: 100%; }
    .card-title .btn { flex: 1; min-width: 55px; text-align: center; padding: 5px 6px; font-size: 11px; }
    table.data-table { font-size: 11px; }
    table.data-table th, table.data-table td { padding: 6px 4px; }
    table.data-table .btn-link { padding: 2px 3px; font-size: 10px; }
    .btn { padding: 5px 8px; font-size: 11px; white-space: nowrap; }
    .content { padding: 8px; }
}

/* 横屏手机优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .form-row { grid-template-columns: repeat(2, 1fr); }
}

/* 遮罩层 */
.sidebar-overlay { display: none; }

/* ===== 部门架构图响应式优化 ===== */
/* Pad端（768px-1024px） */
@media (max-width: 1024px) {
    .dept-d2-card { min-width: 180px !important; max-width: 240px !important; }
    .dept-d3-card { min-width: 90px !important; }
}

/* 手机端（768px以下） */
@media (max-width: 768px) {
    .dept-d2-card { min-width: 140px !important; max-width: 100% !important; flex: 1 1 45% !important; }
    .dept-d3-card { min-width: 80px !important; flex: 1 1 45% !important; }
}

/* 小屏手机（480px以下） */
@media (max-width: 480px) {
    .dept-d2-card { min-width: 100% !important; flex: 1 1 100% !important; }
    .dept-d3-card { min-width: 45% !important; flex: 1 1 45% !important; }
}
