/* ==================== 全局样式 ==================== */
:root {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
    --gray-50: #ffffff;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 260px;
    --header-height: 64px;
    --transition-speed: 0.2s;
    --border-radius: 12px;
    --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --box-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: var(--custom-font, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif);
    background: #ffffff;
    color: var(--gray-900);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

/* ==================== 应用容器 ==================== */
.app-container {
    display: flex;
    min-height: 100vh;
    background: #ffffff;
}

/* ==================== 侧边栏 ==================== */
.sidebar {
    width: var(--sidebar-width);
    background: #1f2937;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--box-shadow-lg);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: #3b82f6;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo h1 {
    font-size: 18px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: #3b82f6;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    display: block;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.change-password-btn {
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all var(--transition-speed);
    margin-left: 8px;
}

.change-password-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.logout-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.sidebar-nav {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 10px;
    transition: all var(--transition-speed);
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(4px);
}

.nav-item.active {
    background: #3b82f6;
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.nav-item svg {
    flex-shrink: 0;
}

.nav-item span {
    white-space: nowrap;
}

/* ==================== 主内容区 ==================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px;
    background: #ffffff;
    min-height: 100vh;
}

/* ==================== 顶部栏 ==================== */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding: 20px 24px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.header-left h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    gap: 12px;
}

/* ==================== 内容区块 ==================== */
.content-section {
    display: none;
}

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

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

.stat-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--box-shadow);
    transition: all var(--transition-speed);
    border: 1px solid var(--gray-100);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--box-shadow-lg);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.stat-card-primary .stat-icon {
    background: #3b82f6;
}

.stat-card-success .stat-icon {
    background: #10b981;
}

.stat-card-info .stat-icon {
    background: #3b82f6;
}

.stat-card-warning .stat-icon {
    background: #f59e0b;
}

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
}

/* ==================== 仪表盘网格 ==================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

/* ==================== 卡片 ==================== */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--gray-100);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
}

.card-body {
    padding: 24px;
}

/* ==================== 列表 ==================== */
.list-container {
    max-height: 300px;
    overflow-y: auto;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}

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

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 2px;
}

.list-item-subtitle {
    font-size: 12px;
    color: var(--gray-500);
}

.list-item-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}

/* ==================== 工具栏 ==================== */
.section-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

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

.stats-summary {
    display: flex;
    gap: 24px;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-item .stat-label {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-item .stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-present {
    color: var(--success-color);
}

.stat-absent {
    color: var(--danger-color);
}

/* ==================== 表格 ==================== */
.table-container {
    overflow-x: auto;
}

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

.data-table thead {
    background: #f9fafb;
}

.data-table th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--gray-200);
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

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

.data-table code {
    background: var(--gray-100);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--gray-700);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-decoration: none;
    white-space: nowrap;
    box-shadow: var(--box-shadow);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--box-shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: #f9fafb;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--gray-100);
    color: var(--gray-600);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.btn-icon:hover {
    background: var(--gray-200);
    color: var(--gray-900);
    transform: translateY(-1px);
}

.btn-icon-danger {
    color: var(--danger-color);
}

.btn-icon-danger:hover {
    background: #fee2e2;
    color: var(--danger-color);
}

/* ==================== 表单 ==================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-700);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    color: var(--gray-900);
    background: white;
    transition: all var(--transition-speed);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-control small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--gray-500);
}

/* ==================== 模态框 ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.modal.active {
    display: flex;
}

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

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--box-shadow-lg);
    animation: slideUp 0.3s ease-out;
}

.modal-content-large {
    max-width: 700px;
}

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

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--gray-100);
    background: #f9fafb;
}

/* ==================== 状态标签 ==================== */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-inactive {
    background: #fee2e2;
    color: #991b1b;
}

.status-not_checked_in {
    background: var(--gray-100);
    color: var(--gray-600);
}

.status-present {
    background: #d1fae5;
    color: #065f46;
}

.status-absent {
    background: #fee2e2;
    color: #991b1b;
}

.status-late {
    background: #fef3c7;
    color: #92400e;
}

.status-leave {
    background: #dbeafe;
    color: #1e40af;
}

/* ==================== 任务状态 ==================== */
.task-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.task-status-pending {
    background: var(--gray-100);
    color: var(--gray-600);
}

.task-status-active {
    background: #d1fae5;
    color: #065f46;
}

.task-status-completed {
    background: #dbeafe;
    color: #1e40af;
}

/* ==================== 加载中 ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ==================== Toast 提示 ==================== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    padding: 16px 20px;
    background: white;
    border-radius: 10px;
    box-shadow: var(--box-shadow-lg);
    font-weight: 500;
    color: var(--gray-900);
    min-width: 300px;
    animation: slideInRight 0.3s ease-out;
    transform: translateX(120%);
}

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

@keyframes slideInRight {
    from {
        transform: translateX(120%);
    }
    to {
        transform: translateX(0);
    }
}

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

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

/* ==================== 空状态 ==================== */
.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--gray-400);
    font-size: 14px;
}

/* ==================== 详情部分 ==================== */
.detail-section {
    margin-bottom: 24px;
}

.detail-section h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 16px;
}

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

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-item label {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 500;
    margin-bottom: 4px;
}

.detail-item span {
    font-size: 14px;
    color: var(--gray-900);
    font-weight: 600;
}

/* ==================== 出勤编辑表单 ==================== */
.attendance-edit-form {
    background: #f9fafb;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
}

/* 照片显示区域 */
.photo-display {
    margin-top: 10px;
    padding: 10px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.photo-display img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    object-fit: contain;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
    }
    
    .sidebar-header h1,
    .user-info,
    .logout-btn span {
        display: none;
    }
    
    .nav-item span {
        display: none;
    }
    
    .main-content {
        margin-left: 80px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .section-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar-group {
        flex-direction: column;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .top-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .header-right {
        width: 100%;
    }
    
    .header-right .btn {
        width: 100%;
        justify-content: center;
    }
}

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

::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 4px;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ==================== 开关按钮 ==================== */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #3b82f6;
}

input:checked + .slider:before {
    transform: translateX(24px);
}

input:disabled + .slider {
    opacity: 0.5;
    cursor: not-allowed;
}