/* ============================================================
   HR System — 简洁专业风格 / 深色侧边栏 + 浅色内容区
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600;700&display=swap');

:root {
    --sidebar-bg: #1a1d23;
    --sidebar-hover: #262a33;
    --sidebar-active: #2c313a;
    --sidebar-text: #9ca3af;
    --sidebar-text-active: #e5e7eb;
    --accent: #4f8ef7;
    --accent-light: #e8f0fe;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --card-bg: var(--surface);
    --border: #e5e7eb;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
    --font: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 10;
}

.sidebar-brand {
    padding: 24px 20px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    color: #e5e7eb;
    letter-spacing: 0.02em;
}

.brand-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #7c5cfc);
}

.sidebar-nav {
    flex: 1;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.15s ease;
}

.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-text-active); }

.nav-sm { font-size: 13px; padding: 7px 12px; }

.nav-divider {
    height: 1px;
    background: #2c313a;
    margin: 8px 12px;
}

.nav-label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 12px 4px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid #2c313a;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-user {
    font-size: 13px; color: var(--sidebar-text);
}

.logout-btn {
    font-size: 12px; color: #ef4444; text-decoration: none;
    padding: 4px 10px; border-radius: 4px; transition: background 0.15s;
}
.logout-btn:hover { background: rgba(239,68,68,0.15); }

/* Main Content */
.main-content {
    flex: 1;
    padding: 32px 40px;
    max-width: 1200px;
}

.main-content.full-width {
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Flash */
.flash-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.flash-msg {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    transition: opacity 0.3s;
    max-width: 360px;
}

/* Page Header */
.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 24px; font-weight: 700; color: var(--text);
}

.page-header p {
    font-size: 14px; color: var(--text-secondary); margin-top: 4px;
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

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

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

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 28px; font-weight: 700; color: var(--text);
}

.stat-label {
    font-size: 13px; color: var(--text-secondary); margin-top: 4px;
}

.stat-card.warn .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--danger); }

/* Table */
.table-wrap {
    overflow-x: auto;
}

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

th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 12px 14px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: top;
}

tr:hover { background: #f9fafb; }

/* Table column widths */
.col-name { min-width: 140px; }
.col-id { min-width: 170px; }
.col-phone { min-width: 120px; }
.col-duration { min-width: 90px; }
.col-status { min-width: 90px; }
.col-date { min-width: 100px; }
.col-actions { min-width: 110px; width: 110px; }

/* Sortable column headers */
th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

th.sortable:hover {
    color: var(--accent);
}

th.sortable.sorted {
    color: var(--accent);
}

.sort-arrow {
    font-size: 10px;
    margin-left: 4px;
    opacity: 0.5;
}

th.sortable.sorted .sort-arrow {
    opacity: 1;
}

/* Dashboard toolbar */
.dashboard-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.result-count {
    font-size: 13px;
    color: var(--text-muted);
}

/* Search box with icon */
.search-box {
    position: relative;
    flex: 1;
    max-width: 320px;
    min-width: 180px;
}

.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 8px 14px 8px 36px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: var(--font);
    background: #f9fafb;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

.search-box input:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(79,142,247,0.1);
}

.select-sm {
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    cursor: pointer;
    outline: none;
}

.select-sm:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,142,247,0.1);
}

/* Table card — reduced padding */
.table-card { padding: 0; }

.table-card .table-wrap { padding: 0; }

.table-card th { padding: 14px 18px; }
.table-card td { padding: 14px 18px; }

/* Employee name cell */
.emp-name-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.emp-name-cell strong {
    font-size: 14px;
    color: var(--text);
}

.emp-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ID code style */
.id-code {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    color: var(--text-secondary);
    background: none;
    padding: 0;
    border-radius: 0;
    letter-spacing: 0.02em;
}

/* Text muted */
.text-muted {
    font-size: 13px;
    color: var(--text-muted);
}

/* Resign date under status */
.resign-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Row action buttons (icon style) */
.row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.action-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    color: var(--text-secondary);
    transition: all 0.15s;
    text-decoration: none;
}

.action-link:hover {
    background: #f0f4ff;
    color: var(--accent);
}

.action-link.danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.delete-form {
    display: inline-flex;
    margin: 0;
}

.delete-form button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

/* Form */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-grid.col-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.col-1 { grid-template-columns: 1fr; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full { grid-column: 1 / -1; }
.form-group.half { grid-column: span 1; }

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

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

input[type="text"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="email"],
input[type="password"],
select,
textarea {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,142,247,0.15);
}

textarea { resize: vertical; min-height: 60px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #3b7de6; }

.btn-outline {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: #f9fafb; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

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

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* Badge */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-active { background: var(--success-bg); color: #059669; }
.badge-resigned { background: var(--danger-bg); color: #dc2626; }
.badge-tag { background: #f0f4ff; color: #2563eb; font-size: 11px; margin-left: 6px; }

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.toolbar .search-input {
    flex: 1;
    min-width: 200px;
    max-width: 320px;
}

/* Login Page */
.login-wrapper {
    width: 420px;
    max-width: 90vw;
}

.login-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-card h1 {
    font-size: 22px; font-weight: 700; margin-bottom: 4px;
}

.login-card .login-sub {
    font-size: 14px; color: var(--text-secondary); margin-bottom: 28px;
}

.login-card .form-group { margin-bottom: 18px; }

.login-card .form-group label {
    font-size: 13px; font-weight: 600; color: var(--text-secondary);
    margin-bottom: 6px; display: block;
}

.login-card input {
    width: 100%; padding: 12px 14px;
    border: 1px solid var(--border); border-radius: 6px;
    font-size: 15px;
}

.login-card .btn-primary { width: 100%; padding: 12px; font-size: 15px; margin-top: 8px; }

.login-link {
    text-align: center;
    margin-top: 20px;
    font-size: 13px; color: var(--text-secondary);
}

.login-link a { color: var(--accent); text-decoration: none; font-weight: 500; }
.login-link a:hover { text-decoration: underline; }

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.info-grid .info-item {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

.info-grid .info-item:nth-child(even) { border-right: none; }
.info-grid .info-item:nth-last-child(-n+2) { border-bottom: none; }

.info-item .info-label {
    font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 2px;
}

.info-item .info-value {
    font-size: 15px; color: var(--text); font-weight: 500;
}

/* Section Card */
.section-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 20px;
}

.section-card-header {
    padding: 16px 24px;
    background: #f9fafb;
    border-bottom: 1px solid var(--border);
    font-size: 15px; font-weight: 600;
    display: flex; align-items: center; gap: 8px;
}

.section-card-body { padding: 24px; }

/* Action Bar */
.action-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.tab-item {
    padding: 10px 20px;
    font-size: 14px; font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--accent); border-color: var(--accent); }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 15px; }

/* Responsive */
@media (max-width: 768px) {
    .app-layout { flex-direction: column; }

    .sidebar {
        width: 100%; min-width: 100%; height: auto; position: relative;
        padding-bottom: 12px;
    }

    .sidebar-brand { padding: 16px 20px 12px; }

    .sidebar-nav {
        flex-direction: row; flex-wrap: wrap; padding: 0 12px; gap: 4px;
    }

    .nav-item { font-size: 12px; padding: 8px 10px; }
    .nav-item svg { display: none; }
    .nav-divider, .nav-label, .nav-sm { display: none; }

    .sidebar-footer { padding: 12px 20px; font-size: 12px; }

    .main-content { padding: 16px; max-width: 100%; }

    .page-header h1 { font-size: 20px; }
    .page-header p { font-size: 13px; }

    /* Stats */
    .stats-row { grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 22px; }
    .stat-label { font-size: 12px; }

    /* Toolbar */
    .dashboard-toolbar { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px 16px; }
    .toolbar-left { flex-wrap: wrap; gap: 8px; }
    .toolbar-right { justify-content: space-between; }
    .search-box { max-width: 100%; }
    .search-box input { font-size: 16px; } /* prevent iOS zoom */

    /* Table */
    .table-card th, .table-card td { padding: 10px 12px; font-size: 13px; }
    .col-id { min-width: 150px; }
    .emp-meta { font-size: 11px; }
    .id-code { font-size: 12px; }
    .row-actions { gap: 2px; }
    .action-link { width: 28px; height: 28px; }
    .action-link svg { width: 13px; height: 13px; }

    /* Forms */
    .form-grid { grid-template-columns: 1fr; }
    .card { padding: 16px; }
    .card-header h2 { font-size: 15px; }
    .section-card-body { padding: 16px; }
    .section-card-header { padding: 12px 16px; font-size: 14px; }

    /* Info Grid */
    .info-grid { grid-template-columns: 1fr; }
    .info-grid .info-item { border-right: none; }
    .info-item { padding: 12px 16px; }
    .info-item .info-value { font-size: 14px; }

    /* Login */
    .login-card { padding: 28px 20px; }
    .login-card h1 { font-size: 20px; }

    /* Buttons */
    .btn { padding: 8px 16px; font-size: 13px; }
    .btn-sm { padding: 6px 12px; font-size: 12px; }

    /* Flash */
    .flash-container { top: 10px; right: 10px; left: 10px; }
    .flash-msg { max-width: 100%; font-size: 13px; padding: 10px 16px; }

    /* Empty state */
    .empty-state { padding: 32px 16px; }
    .empty-state .empty-icon { font-size: 32px; }

    /* Tabs */
    .tabs { overflow-x: auto; }
    .tab-item { padding: 8px 14px; font-size: 13px; white-space: nowrap; }
}

/* Status dot */
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.active { background: var(--success); }
.status-dot.resigned { background: var(--danger); }
