/* 
 * 四象限法工作管理系统 - 主样式表
 * 包含基础样式、变量定义和主要布局
 */

/* CSS变量定义 */
:root {
  /* 颜色方案 */
  --primary-color: #4a6fa5;
  --secondary-color: #166088;
  --accent-color: #4da6ff;
  --text-color: #333;
  --text-light: #666;
  --text-dark: #000;
  --bg-color: #f8f9fa;
  --bg-light: #fff;
  --border-color: #ddd;
  --shadow-color: rgba(0, 0, 0, 0.1);
  
  /* 象限颜色 */
  --q1-color: #e74c3c; /* 重要且紧急 - 红色 */
  --q2-color: #3498db; /* 重要不紧急 - 蓝色 */
  --q3-color: #f39c12; /* 紧急不重要 - 橙色 */
  --q4-color: #27ae60; /* 不重要不紧急 - 绿色 */
  
  /* 尺寸和间距 */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  
  /* 圆角和过渡 */
  --border-radius-sm: 0.25rem;
  --border-radius-md: 0.5rem;
  --border-radius-lg: 1rem;
  --transition-quick: 0.15s ease;
  --transition-normal: 0.3s ease;
  
  /* 阴影 */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* 基础样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-color);
  background-color: var(--bg-color);
}

a {
  color: var(--primary-color);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul, ol {
  list-style: none;
}

/* 通用布局 */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md) var(--spacing-lg);
  background-color: var(--primary-color);
  color: white;
  box-shadow: var(--shadow-md);
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 500;
}

.main-nav {
  display: flex;
  gap: var(--spacing-md);
  align-items: center;
}

.main-content {
  display: grid;
  grid-template-columns: 1fr 300px;
  min-height: calc(100vh - 60px);
  padding: var(--spacing-lg);
  gap: var(--spacing-lg);
}

/* 按钮样式 */
.btn {
  padding: var(--spacing-sm) var(--spacing-md);
  border: none;
  border-radius: var(--border-radius-sm);
  background-color: var(--bg-light);
  color: var(--text-color);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--transition-quick), transform var(--transition-quick);
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  background-color: #f0f0f0;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-primary:hover {
  background-color: #3b9de0;
}

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

.btn-sm {
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: 0.75rem;
}

/* 输入框样式 */
.form-control {
  display: block;
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-color);
  background-color: var(--bg-light);
  background-clip: padding-box;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  transition: border-color var(--transition-quick), box-shadow var(--transition-quick);
}

.form-control:focus {
  border-color: var(--accent-color);
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(77, 166, 255, 0.25);
}

.form-control::placeholder {
  color: #aaa;
}

#search-task {
  padding: var(--spacing-sm) var(--spacing-md);
  border: none;
  border-radius: var(--border-radius-sm);
  width: 250px;
}

/* 四象限布局 */
.quadrants {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: var(--spacing-md);
  height: 100%;
  min-height: 600px;
}

.quadrant {
  background-color: var(--bg-light);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
  border-top: 4px solid #ddd;
  position: relative;
}

.quadrant h2 {
  font-size: 1.1rem;
  margin-bottom: var(--spacing-md);
  color: var(--text-dark);
  font-weight: 500;
}

.quadrant.important.urgent {
  border-top-color: var(--q1-color);
}

.quadrant.important {
  border-top-color: var(--q2-color);
}

.quadrant.urgent {
  border-top-color: var(--q3-color);
}

.quadrant:not(.important):not(.urgent) {
  border-top-color: var(--q4-color);
}

.task-list {
  flex: 1;
  overflow-y: auto;
  margin-bottom: var(--spacing-md);
}

.add-task-btn {
  position: absolute;
  bottom: var(--spacing-md);
  right: var(--spacing-md);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: var(--primary-color);
  color: white;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-quick), background-color var(--transition-quick);
}

.add-task-btn:hover {
  transform: scale(1.1);
  background-color: var(--accent-color);
}

/* 侧边栏样式 */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.sidebar section {
  background-color: var(--bg-light);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--spacing-md);
}

.sidebar section h3 {
  font-size: 1rem;
  margin-bottom: var(--spacing-md);
  color: var(--text-dark);
  font-weight: 500;
}

/* 番茄钟样式 */
.pomodoro {
  text-align: center;
}

.timer {
  font-size: 2.5rem;
  font-weight: 300;
  margin: var(--spacing-md) 0;
}

.timer-controls {
  display: flex;
  gap: var(--spacing-sm);
  justify-content: center;
}

/* 今日概览样式 */
.overview-stats {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.stat-value {
  font-weight: 600;
  color: var(--primary-color);
}

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

.form-group label {
  display: block;
  margin-bottom: var(--spacing-sm);
  font-weight: 600;
  font-size: 0.9rem;
}

.form-row {
  display: flex;
  gap: var(--spacing-md);
}

.form-row .form-group {
  flex: 1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
}

/* 自定义下拉菜单 */
.custom-select-wrapper {
  position: relative;
}

.custom-select-wrapper:after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--text-light);
  pointer-events: none;
}

/* 通用样式补充 */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
}

/* 确保滚动条样式统一 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* 图表相关样式 */
.stats-card {
  position: relative;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  padding: 16px;
  margin-bottom: 16px;
  min-height: 200px;
  transition: all 0.3s ease;
  overflow: hidden;
}

/* 图表加载状态 */
.stats-card.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.7);
  z-index: 5;
  border-radius: 8px;
  transition: opacity 0.3s ease;
}

.stats-card.loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin-top: -15px;
  margin-left: -15px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  z-index: 6;
  animation: spin 1s linear infinite;
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* 图表错误状态 */
.stats-card.error {
  border-left: 4px solid #ff6347;
  transition: border-left-color 0.3s ease;
}

.stats-card[data-loaded="true"] {
  border-left: 4px solid var(--primary-color);
  transition: border-left-color 0.3s ease;
}

/* 饼图容器 */
.pie-chart {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  margin: 15px auto;
  position: relative;
  transition: background 0.5s ease;
}

.pie-chart[data-rendered="true"] {
  box-shadow: 0 0 8px rgba(0,0,0,0.1);
}

.pie-chart[data-rendered="true"]::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50px;
  height: 50px;
  background-color: white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 4px rgba(0,0,0,0.1);
}

.pie-chart[data-fallback="true"] path {
  transition: transform 0.3s ease;
}

.pie-chart[data-fallback="true"] path:hover {
  transform: scale(1.05);
  transform-origin: center;
}

/* 趋势图容器 */
.trend-chart {
  width: 100%;
  height: 200px;
  margin: 15px 0;
  position: relative;
}

.trend-chart svg {
  overflow: visible;
}

.trend-chart circle {
  cursor: pointer;
  transition: r 0.2s ease;
}

/* 图表工具提示 */
.chart-tooltip {
  position: absolute;
  background-color: rgba(0,0,0,0.8);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
}

.chart-tooltip::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px 5px 0;
  border-style: solid;
  border-color: rgba(0,0,0,0.8) transparent transparent transparent;
}

/* 空图表状态 */
.empty-chart {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 150px;
  color: #888;
  font-style: italic;
  text-align: center;
  padding: 20px;
  background-color: #f9f9f9;
  border-radius: 8px;
  border: 1px dashed #ddd;
  margin: 10px 0;
}

/* 错误消息样式 */
.error-message {
  background-color: rgba(255, 99, 71, 0.1);
  color: #ff6347;
  padding: 10px;
  border-radius: 4px;
  margin: 10px 0;
  text-align: center;
  font-size: 14px;
}

/* 洞察列表样式 */
.insights-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.insight-item {
  display: flex;
  align-items: flex-start;
  margin-bottom: 12px;
  padding: 8px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.insight-item:hover {
  background-color: #f5f5f5;
}

.insight-icon {
  margin-right: 10px;
  font-size: 18px;
  flex-shrink: 0;
}

.insight-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
}

/* 进度环样式 */
.progress-ring {
  width: 150px;
  height: 150px;
  position: relative;
  margin: 15px auto;
}

.progress-ring-circle {
  transition: stroke-dashoffset 0.3s;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  stroke-linecap: round;
}

.completion-percentage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  font-weight: bold;
  color: var(--primary-color);
}

/* 进度条样式 */
.progress-bar-container {
  width: 100%;
  height: 20px;
  background-color: #f1f1f1;
  border-radius: 10px;
  margin: 8px 0;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
  color: white;
  font-size: 12px;
  transition: width 0.5s ease-in-out;
}

#focus-time-bar {
  background-color: var(--primary-color);
}

#task-time-bar {
  background-color: var(--accent-color);
}

/* 后备图表样式 */
.fallback-chart {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  overflow: hidden;
  margin: 15px auto;
}

.fallback-chart .quadrant {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
}

/* 加载中动画 */
.loading-chart {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 150px;
}

.loading-chart::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* 自适应样式 */
@media (max-width: 768px) {
  .stats-card {
    padding: 12px;
  }
  
  .pie-chart, .progress-ring {
    width: 120px;
    height: 120px;
  }
  
  .trend-chart {
    height: 150px;
  }
  
  .completion-percentage {
    font-size: 22px;
  }
}

/* 环形图容器和文本 */
.progress-ring-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 15px auto;
  position: relative;
  width: 120px;
  height: 120px;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  transform-origin: center;
  overflow: visible;
}

.progress-ring-circle {
  transition: stroke-dashoffset 0.8s ease-in-out;
  transform-origin: center;
  stroke-linecap: round;
}

.progress-ring-circle-bg {
  stroke: #eee;
  stroke-width: 8;
  fill: transparent;
}

/* 环形图文本样式 */
.progress-text {
  fill: var(--primary-color);
  font-size: 16px;
  font-weight: bold;
  text-anchor: middle;
  dominant-baseline: middle;
  transform: rotate(90deg);
  transform-origin: center;
}

/* 环形图备用文本显示 */
.completion-text-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px auto;
  padding: 10px;
  background-color: #f5f5f5;
  border-radius: 8px;
  font-weight: bold;
  color: var(--primary-color);
  text-align: center;
  min-height: 80px;
  border-left: 4px solid var(--primary-color);
}

/* 确保所有SVG元素在图表卡片中正确显示 */
.stats-card svg {
  max-width: 100%;
  max-height: 100%;
  display: block;
  margin: 0 auto;
}

/* 饼图刷新时的闪烁效果 */
.pie-chart:not([data-rendered]) {
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

.pie-chart[data-rendered="true"] {
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* 确保模态框显示后图表能正常渲染 */
.modal.active .stats-card {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* 标签选择器样式 */
.tags-selector {
  margin-bottom: 20px;
}

.tags-selector label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-color);
  font-weight: 500;
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-color);
}

.tag-item {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  background-color: var(--primary-color-light);
  border-radius: 16px;
  font-size: 14px;
  color: var(--primary-color);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tag-item:hover {
  background-color: var(--primary-color);
  color: white;
}

.tag-item.selected {
  background-color: var(--primary-color);
  color: white;
}

.tag-item .tag-remove {
  margin-left: 6px;
  font-size: 12px;
  opacity: 0.7;
}

.tag-item .tag-remove:hover {
  opacity: 1;
}

/* 标签颜色样式 */
.tag-item[data-color] {
  background-color: var(--tag-color);
  color: white;
}

.tag-item[data-color]:hover {
  filter: brightness(1.1);
}

/* 空状态提示 */
.tags-container:empty::before {
  content: '点击下方"管理标签"按钮添加标签';
  color: var(--text-color-light);
  font-style: italic;
  opacity: 0.7;
}

/* 标签管理按钮 */
.manage-tags-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--primary-color);
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.manage-tags-link:hover {
  text-decoration: underline;
}

/* 编辑任务模态框中的标签选择器特殊样式 */
#edit-task-modal .tags-selector {
  margin-bottom: 24px;
}

#edit-task-modal .tags-container {
  background-color: var(--bg-color-light);
}

/* 任务标签样式 */
.task-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
  padding: 2px 0;
}

.task-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all 0.2s ease;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.task-tag:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* 确保深色标签有足够的对比度 */
.task-tag[style*="background-color: #000"],
.task-tag[style*="background-color: #111"],
.task-tag[style*="background-color: #222"],
.task-tag[style*="background-color: #333"],
.task-tag[style*="background-color: #444"],
.task-tag[style*="background-color: #555"] {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

/* 确保浅色标签有足够的对比度 */
.task-tag[style*="background-color: #fff"],
.task-tag[style*="background-color: #eee"],
.task-tag[style*="background-color: #ddd"],
.task-tag[style*="background-color: #ccc"],
.task-tag[style*="background-color: #bbb"],
.task-tag[style*="background-color: #aaa"] {
  color: #333;
  border-color: rgba(0, 0, 0, 0.1);
} 