/* 全局样式 */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background-color: #f9fafb;
    --surface-color: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 8px;
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
}

/* 导航栏 */
.navbar {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.nav-buttons {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.nav-btn:hover {
    background: var(--background-color);
    color: var(--text-primary);
}

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

/* 主要内容区域 */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* 按钮样式 */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

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

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

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

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

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

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

/* 筛选栏 */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-secondary);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
}

.filter-btn:hover {
    background: var(--background-color);
    color: var(--text-primary);
}

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

/* 目标容器 */
.goals-container {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
}

/* 目标卡片 */
.goal-card {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: move;
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 700px; /* 增加卡片最大高度 */
}

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

.goal-card.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.goal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.goal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.goal-status {
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
}

.status-active {
    background: #dcfce7;
    color: #166534;
}

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

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

.goal-progress {
    margin-bottom: 0.75rem;
}

.progress-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--background-color);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--success-color);
    transition: width 0.3s ease;
}

.goal-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    margin-top: auto; /* 推到底部 */
}

.goal-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0; /* 防止压缩 */
}

.goal-actions .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
}

/* 拖拽手柄 */
.drag-handle {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    color: var(--text-secondary);
    cursor: move;
    font-size: 1rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.goal-card:hover .drag-handle {
    opacity: 1;
}

/* 任务列表样式 */
.task-list-container {
    margin: 0.75rem 0;
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
    flex: 1;
    min-height: 0; /* 允许弹性收缩 */
    display: flex;
    flex-direction: column;
}

.task-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    flex-shrink: 0;
}

.task-count {
    color: var(--text-secondary);
    font-size: 0.7rem;
    background: var(--background-color);
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    font-weight: normal;
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 280px; /* 增加任务列表最大高度 */
    overflow-y: auto; /* 添加垂直滚动条 */
    padding-right: 4px; /* 为滚动条留出空间 */
}

/* 自定义滚动条样式 */
.task-list::-webkit-scrollbar {
    width: 4px;
}

.task-list::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 2px;
}

.task-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.task-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.task-list-empty {
    text-align: center;
    padding: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.8rem;
}

.task-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    background: #f9fafb;
    transition: var(--transition);
    border: 1px solid transparent;
    flex-shrink: 0;
}

.task-item:hover {
    background: #f3f4f6;
    border-color: var(--border-color);
}

.task-item.task-completed {
    opacity: 0.65;
    background: #f0f0f0;
}

.task-item.task-completed .task-title {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.task-checkbox-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1.2;
}

.task-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
    margin: 0;
    margin-top: 1px;
    flex-shrink: 0;
}

.task-title {
    flex: 1;
    color: var(--text-primary);
    word-break: break-word;
}

.task-deadline {
    margin-left: 1rem;
    font-size: 0.65rem;
}

.deadline-completed {
    color: var(--success-color);
}

.deadline-overdue {
    color: var(--danger-color);
    font-weight: 500;
}

.deadline-today {
    color: var(--warning-color);
    font-weight: 500;
}

.deadline-soon {
    color: var(--warning-color);
}

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

.task-more {
    text-align: center;
    padding: 0.4rem;
    border-top: 1px dashed var(--border-color);
    margin-top: 0.2rem;
    font-style: italic;
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* 模态框 */
.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.active {
    display: flex;
}

.modal {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* 表单样式 */
.form-group {
    margin-bottom: 1.5rem;
}

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

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

/* 目标详情页样式 */
.goal-detail {
    max-width: 800px;
    margin: 0 auto;
}

.goal-detail-header {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.goal-detail-header .goal-title {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.goal-description {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--background-color);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
}

.goal-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 1rem;
}

.tasks-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.tasks-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* 任务项样式 */
.task-item {
    display: flex;
    align-items: flex-start;
    gap: 0.3rem;
    padding: 0.3rem;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
}

.task-item:hover {
    box-shadow: var(--shadow-lg);
}

.task-item.completed {
    opacity: 0.7;
}

.task-item.completed .task-title {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.task-item.overdue {
    border-left: 4px solid var(--danger-color);
}

.task-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.task-drag-handle {
    color: var(--text-secondary);
    cursor: move;
    font-size: 1.2rem;
    padding: 0.25rem;
    margin-top: 0.25rem;
}

.task-checkbox {
    position: relative;
    margin-top: 0.25rem;
}

.task-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
}

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

.task-title {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    word-wrap: break-word;
}

.task-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.task-meta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.task-type {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.75rem;
}

.task-deadline,
.task-status,
.task-completed {
    color: var(--text-secondary);
}

.task-note {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--background-color);
    border-radius: 4px;
}

.task-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
}

/* 空状态样式 */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

/* 工具类 */
.text-center {
    text-align: center;
}

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

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.hidden {
    display: none !important;
}

/* 日历页面样式 */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.calendar-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.calendar-grid {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 2rem;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--primary-color);
    color: white;
}

.weekday {
    padding: 1rem;
    text-align: center;
    font-weight: 500;
}

.calendar-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border-color);
}

.calendar-week:last-child {
    border-bottom: none;
}

.calendar-day {
    min-height: 80px;
    padding: 0.5rem;
    border-right: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.calendar-day:last-child {
    border-right: none;
}

.calendar-day:hover {
    background: var(--background-color);
}

.calendar-day.other-month {
    color: var(--text-secondary);
    background: #f8f9fa;
}

.calendar-day.today {
    background: #e0f2fe;
    font-weight: 600;
}

.calendar-day.selected {
    background: var(--primary-color);
    color: white;
}

.calendar-day.has-tasks {
    background: #dcfce7;
}

.calendar-day.goal-deadline {
    border-left: 4px solid var(--danger-color);
}

.calendar-day.task-deadline {
    border-left: 4px solid var(--warning-color);
}

.day-number {
    font-size: 1rem;
    font-weight: 500;
}

.task-count {
    background: var(--success-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: auto;
    margin-left: auto;
}

.calendar-legend {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.has-tasks {
    background: var(--success-color);
}

.legend-dot.goal-deadline {
    background: var(--danger-color);
}

.legend-dot.task-deadline {
    background: var(--warning-color);
}

.date-details {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.date-details-empty {
    text-align: center;
    color: var(--text-secondary);
}

.date-details-content h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h5 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
}

.detail-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.detail-section li {
    padding: 0.25rem 0;
    color: var(--text-secondary);
}

/* 统计页面样式 */
.stats-overview {
    margin-bottom: 2rem;
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

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

.stat-number {
    font-size: 2rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

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

.stats-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.chart-section {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.chart-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.progress-item,
.distribution-item {
    margin-bottom: 1rem;
}

.progress-item:last-child,
.distribution-item:last-child {
    margin-bottom: 0;
}

.progress-header,
.distribution-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.goal-name,
.type-name {
    font-weight: 500;
    color: var(--text-primary);
}

.progress-text,
.type-count {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.distribution-bar {
    height: 8px;
    background: var(--background-color);
    border-radius: 4px;
    overflow: hidden;
}

.distribution-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.recent-tasks-section {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.recent-tasks-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.recent-tasks-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.recent-task-item {
    padding: 1rem;
    background: var(--background-color);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--success-color);
}

.task-title {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.task-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.task-goal,
.task-type,
.task-date {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* 开发者工具面板 */
.dev-tools {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.dev-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: var(--primary-color);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.dev-toggle:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.dev-panel {
    position: absolute;
    bottom: 60px;
    right: 0;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    min-width: 250px;
    display: none;
    border: 1px solid var(--border-color);
}

.dev-panel.active {
    display: block;
}

.dev-panel h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.dev-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dev-buttons .btn {
    justify-content: flex-start;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
}

.dev-info {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.4;
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
}
