/* CSS Variables - Modern Palette (Slate & Indigo) */
:root {
    /* Primary Colors */
    --primary-color: #4f46e5; /* Indigo 600 */
    --primary-hover: #4338ca; /* Indigo 700 */
    --primary-light: #e0e7ff; /* Indigo 100 */

    /* Functional Colors */
    --danger-color: #ef4444; /* Red 500 */
    --danger-light: #fee2e2; /* Red 100 */
    --warning-color: #f59e0b; /* Amber 500 */
    --warning-light: #fef3c7; /* Amber 100 */
    --success-color: #10b981; /* Emerald 500 */
    --success-light: #d1fae5; /* Emerald 100 */
    --info-color: #0ea5e9; /* Sky 500 */

    /* Surface Colors */
    --bg-body: #f8fafc; /* Slate 50 */
    --bg-surface: #ffffff;

    /* Text Colors */
    --text-main: #0f172a; /* Slate 900 */
    --text-secondary: #64748b; /* Slate 500 */
    --text-tertiary: #94a3b8; /* Slate 400 */

    /* Border & Shadows */
    --border-color: #e2e8f0; /* Slate 200 */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);

    /* Legacy aliases for compatibility */
    --secondary-color: #64748b;
    --light-color: #f8fafc;
    --dark-color: #0f172a;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    letter-spacing: -0.01em;
}

/* Sidebar Styles */
.sidebar {
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    width: 250px;
    background-color: #2c3e50;
    color: #fff;
    z-index: 1000;
    transition: all 0.3s;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    background-color: #1a252f;
    border-bottom: 1px solid #4b5d67;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.sidebar-menu {
    padding: 20px 0;
}

.menu-item {
    padding: 12px 20px;
    display: block;
    color: #adb5bd;
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
    border-left: 4px solid transparent;
}

.menu-item:hover, .menu-item.active {
    background-color: #34495e;
    color: #fff;
    border-left-color: var(--primary-color);
}

.menu-item i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

/* Main Content */
.main-content {
    margin-left: 0;
    padding: 20px;
    min-height: 100vh;
}

/* Cards - Modern Design */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.025em;
    color: var(--text-main);
    border-radius: 16px 16px 0 0 !important;
}

.card-body {
    padding: 24px;
}

/* Dashboard Statistics Cards - Style A: Modern Icon Box */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(0,0,0,0.02);
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-right: 20px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

/* Icon background colors */
.stat-icon.bg-primary {
    background: #e7f1ff !important;
    color: #0d6efd !important;
}

.stat-icon.bg-danger {
    background: #ffecec !important;
    color: #dc3545 !important;
}

.stat-icon.bg-warning {
    background: #fff5e6 !important;
    color: #fd7e14 !important;
}

.stat-icon.bg-success {
    background: #e8f5e9 !important;
    color: #198754 !important;
}

.stat-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1.1;
    margin-bottom: 2px;
    order: 2;
}

.stat-label {
    color: #95a5a6;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.3px;
    order: 1;
    margin-bottom: 4px;
}

/* Tables - Modern Design */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    font-size: 1.1rem;
    text-transform: none;
    color: var(--text-main);
    font-weight: 700;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface);
    letter-spacing: -0.025em;
    text-align: left;  /* 改为左对齐，特定列通过 .text-center 类居中 */
}

.table td {
    padding: 18px 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    transition: background 0.2s;
    text-align: left;  /* 明确设置左对齐 */
}

.table tbody tr:hover td {
    background-color: rgba(79, 70, 229, 0.03);
    color: var(--text-main);
}

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

/* Badges - Modern Pill Design */
.badge {
    padding: 4px 12px;
    font-weight: 600;
    font-size: 0.75rem;
    border-radius: 999px;
    letter-spacing: 0.01em;
}

/* Priority Badges - Soft Colors */
.badge-priority-p0 {
    background-color: var(--danger-light);
    color: var(--danger-color);
}
.badge-priority-p1 {
    background-color: var(--warning-light);
    color: var(--warning-color);
}
.badge-priority-p2 {
    background-color: var(--primary-light);
    color: var(--primary-color);
}
.badge-priority-p3 {
    background-color: #dbeafe; /* Sky 100 */
    color: #0ea5e9; /* Sky 500 */
}
.badge-priority-p4 {
    background-color: #f1f5f9; /* Slate 100 */
    color: var(--text-secondary);
}

/* Status Badges - Soft Colors */
.badge-status-pending {
    background-color: #f1f5f9;
    color: var(--text-secondary);
}
.badge-status-in-progress {
    background-color: var(--primary-light);
    color: var(--primary-color);
}
.badge-status-completed {
    background-color: var(--success-light);
    color: var(--success-color);
}
.badge-status-cancelled {
    background-color: var(--danger-light);
    color: var(--danger-color);
}
.badge-status-delayed {
    background-color: var(--warning-light);
    color: var(--warning-color);
}
.badge-status-overdue-completed {
    background-color: #fed7aa; /* Orange 200 */
    color: #ea580c; /* Orange 600 */
}

/* 中文状态徽章 */
.badge-status-未开始 {
    background-color: #f1f5f9;
    color: var(--text-secondary);
}
.badge-status-进行中 {
    background-color: var(--primary-light);
    color: var(--primary-color);
}
.badge-status-已完成 {
    background-color: var(--success-light);
    color: var(--success-color);
}
.badge-status-已超期 {
    background-color: var(--danger-light);
    color: var(--danger-color);
}
.badge-status-超期完成 {
    background-color: #fed7aa;
    color: #ea580c;
}

/* 中文优先级徽章 (待办) */
.badge-priority-重要紧急 {
    background-color: var(--danger-light);
    color: var(--danger-color);
}
.badge-priority-重要不紧急 {
    background-color: var(--warning-light);
    color: var(--warning-color);
}
.badge-priority-不重要紧急 {
    background-color: var(--primary-light);
    color: var(--primary-color);
}
.badge-priority-不重要不紧急 {
    background-color: #f1f5f9;
    color: var(--text-secondary);
}

/* Buttons */
.btn-icon {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: 0.2rem;
}

/* Forms */
.form-control:focus, .form-select:focus {
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
    border-color: #86b7fe;
}

/* Modals */
.modal-header {
    border-bottom: 1px solid #f0f0f0;
    background-color: #f8f9fa;
}

.modal-footer {
    border-top: 1px solid #f0f0f0;
    background-color: #f8f9fa;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1060;
}

/* Utilities */
.cursor-pointer {
    cursor: pointer;
}

.text-ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Navbar Dropdown Fix */
.navbar .dropdown-menu {
    position: absolute;
    z-index: 9999 !important;
    min-width: 160px;
}

.navbar .dropdown {
    position: relative;
}

.navbar {
    position: relative;
    z-index: 1030;
}

/* Login Page */
.login-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f5f7fb;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

/* Modal Backdrop */
.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.6);
}

/* Filter Panel Animation */
.filter-panel {
    animation: slideDown 0.3s ease-out;
}

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

/* Spinner */
.spinner-border {
    vertical-align: middle;
}

/* List Group Item Action */
.list-group-item-action {
    border-left: 3px solid transparent;
}

.list-group-item-action:hover {
    border-left-color: #007bff;
}

/* Scrollbar for todo list area */
.recent-todos-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0; /* Important for flex scrolling */
    padding-right: 2px;
}

.recent-todos-scroll::-webkit-scrollbar {
    width: 4px;
}

.recent-todos-scroll::-webkit-scrollbar-thumb {
    background: #e9ecef;
    border-radius: 2px;
}

.recent-todos-scroll::-webkit-scrollbar-thumb:hover {
    background: #ced4da;
}

/* =========================================
   New UI Styles from detailed_ui_spec.md
   ========================================= */

/* --- Compact Rich Todo Item - Modern Design --- */
.todo-rich-item {
    background: var(--bg-surface);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--border-color);
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
}

.todo-rich-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
    border-color: var(--primary-light);
    z-index: 1;
}

/* 优先级颜色 - 使用左边框和背景渐变 */
.priority-p0, .priority-重要紧急 {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.05) 0%, transparent 100%);
    border-left-color: #ef4444 !important;
}
.priority-p1, .priority-重要不紧急  {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.05) 0%, transparent 100%);
    border-left-color: #f59e0b !important;
}
.priority-p2, .priority-不重要紧急  {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, transparent 100%);
    border-left-color: #3b82f6 !important;
}
.priority-p4, .priority-不重要不紧急 {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, transparent 100%);
    border-left-color: #10b981 !important;
}

/* 复选框区域 */
.check-area {
    padding-top: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.custom-check {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin-top: 1px;
    border: 2px solid var(--text-tertiary);
    border-radius: 6px;
    transition: all 0.2s;
}
.custom-check:hover {
    border-color: var(--primary-color);
}
.todo-rich-item:hover .custom-check {
    border-color: var(--primary-color);
}

/* 内容主体 */
.content-area {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center; /* 垂直居中 */
}

/* 第一行：标题行 */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px; /* [关键改动] 极小的行间距 */
    line-height: 1.2;
}
.todo-title {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 8px;
    line-height: 1.4;
}

/* Badge 微调 */
.badge-compact {
    font-size: 10px !important;
    padding: 2px 4px !important;
    line-height: 1;
    vertical-align: text-top;
}

/* 第二行：元数据行 */
.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
    align-items: center;
    line-height: 1.2;
}
.meta-item {
    display: flex;
    align-items: center;
    gap: 3px;
    background: var(--bg-body);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.7rem;
}
.meta-item i {
    font-size: 0.85rem;
}
/* 日期图标颜色 */
.meta-item .bi-calendar-check,
.meta-item .bi-calendar-event {
    color: #3b82f6;
}
/* 超期图标颜色 */
.meta-item .bi-alarm {
    color: #ef4444;
}
/* 子任务图标颜色 */
.meta-item .bi-diagram-3 {
    color: #8b5cf6;
}
/* 数量图标颜色 */
.meta-item .bi-check2-all {
    color: #10b981;
}
.meta-item.overdue {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    font-weight: 500;
}
.meta-item.today {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    font-weight: 500;
}

/* 第三行：描述摘要 (可选，如果需要极度紧凑可隐藏或Hover显示) */
.desc-row {
    font-size: 11px;
    color: #adb5bd; /* 更浅的颜色 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    max-width: 100%;
}

/* 微型进度条 */
.mini-progress {
    height: 2px; /* [关键改动] 变细 */
    background: #f1f3f5;
    border-radius: 1px;
    margin-top: 4px;
    width: 100%;
    overflow: hidden;
}
.mini-progress-bar {
    height: 100%;
    background: #20c997;
    transition: width 0.3s ease;
}

/* 操作按钮 */
.action-area {
    opacity: 0;
    padding-top: 0;
    transition: opacity 0.2s;
}
.todo-rich-item:hover .action-area { opacity: 1; }

/* 分组标题样式 */
.todo-group-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 8px;
}
.todo-group-title.overdue {
    color: #ef4444;
    border-bottom-color: rgba(239, 68, 68, 0.3);
}
.todo-group-title.overdue::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* --- Full Month Calendar --- */
/* 日历正方形容器 */
.calendar-square-container {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: 100%;
    overflow: hidden;
}

/* 日历容器 */
.calendar-wrapper {
    background: #fff;
    border-radius: 8px;
    padding: 8px;
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* 头部导航 */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #f0f0f0;
}
.calendar-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
    letter-spacing: -0.025em;
}
.calendar-nav-btn {
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.calendar-nav-btn:hover {
    background: var(--bg-body);
    color: var(--primary-color);
}

/* 星期表头 */
.week-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    margin-bottom: 3px;
}
.week-day-name {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 日期网格 - 核心部分 */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(6, 1fr); /* 强制 6 行，适应所有月份 */
    gap: 2px; /* 极小的间隙 */
    flex-grow: 1; /* 自动填充剩余高度 */
    min-height: 0;
}

/* 单个日期单元格 - 圆形极简设计 */
.calendar-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 0 auto;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-main);
    position: relative;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.calendar-cell:hover {
    background-color: var(--bg-body);
    color: var(--primary-color);
}

/* 状态样式 */
.calendar-cell.other-month {
    color: var(--text-tertiary);
    opacity: 0.4;
}

.calendar-cell.today {
    font-weight: 700;
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.calendar-cell.selected {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    font-weight: 700;
    background-color: transparent;
}

/* 任务指示点 (小圆点) */
.calendar-cell.has-task::after {
    content: '';
    width: 4px;
    height: 4px;
    background-color: var(--danger-color);
    border-radius: 50%;
    position: absolute;
    bottom: 6px;
}

/* today状态下圆点变白 */
.calendar-cell.today::after {
    background-color: white;
}

/* selected状态下圆点使用primary色 */
.calendar-cell.selected.has-task::after {
    background-color: var(--primary-color);
}

/* 日历查看详情浮动层 */
.calendar-summary {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid #e0e0e0;
    z-index: 10;
    backdrop-filter: blur(8px);
}

.calendar-summary-title {
    font-weight: 600;
    color: #2c3e50;
    font-size: 13px;
    margin-bottom: 6px;
}

.calendar-summary-content {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 6px;
}

.calendar-summary-content i {
    margin-right: 4px;
}