/* ============================================
   一宁's世界 - 全局样式
   主色调：浅淡浅蓝色
   全局圆角卡片布局
   ============================================ */

:root {
  /* 主色调 - 浅淡浅蓝色 */
  --primary: #7EB6E8;
  --primary-light: #B3D9F2;
  --primary-lighter: #E3F2FD;
  --primary-pale: #F0F8FF;
  --primary-dark: #5A9BC9;
  --primary-darker: #4A89B5;

  /* 功能色 */
  --success: #81C784;
  --warning: #FFB74D;
  --danger: #E57373;
  --info: #64B5F6;

  /* 中性色 */
  --bg: #F5F9FC;
  --card-bg: #FFFFFF;
  --text-primary: #2C3E50;
  --text-secondary: #5A6C7D;
  --text-tertiary: #95A5B5;
  --border: #E3ECF2;
  --border-light: #F0F4F8;
  --shadow: 0 2px 12px rgba(126, 182, 232, 0.12);
  --shadow-lg: 0 8px 32px rgba(126, 182, 232, 0.18);
  --shadow-sm: 0 1px 4px rgba(126, 182, 232, 0.08);

  /* 圆角 */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* 动画 */
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: 3px;
}

/* ========== APP 主容器 ========== */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ========== 侧边导航栏 ========== */
.sidebar {
  width: 220px;
  min-width: 220px;
  height: 100vh;
  background: linear-gradient(180deg, #FFFFFF 0%, var(--primary-pale) 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-header {
  padding: 20px 16px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-logo {
  width: 48px;
  height: 48px;
  margin: 0 auto 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(126, 182, 232, 0.3);
}

.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-subtitle {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
  position: relative;
  user-select: none;
}

.nav-item:hover {
  background: var(--primary-lighter);
  color: var(--primary-dark);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(126, 182, 232, 0.35);
}

.nav-item.active .nav-icon {
  color: #fff;
}

.nav-icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

.nav-item.active .nav-badge {
  background: rgba(255,255,255,0.25);
}

/* 排序编辑模式 */
.nav-item.editing {
  cursor: grab;
}
.nav-item.editing:active {
  cursor: grabbing;
}
.nav-item.dragging {
  opacity: 0.5;
}
.nav-item.drag-over {
  border-top: 2px solid var(--primary);
}

/* ========== 主内容区 ========== */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* 顶部栏 */
.topbar {
  height: 56px;
  min-height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 50;
  overflow: hidden;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* 双倒计时 */
.dual-countdown {
  display: flex;
  gap: 8px;
}

.countdown-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-pale);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-size: 12px;
}

.countdown-chip .label {
  color: var(--text-secondary);
}

.countdown-chip .value {
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 13px;
}

/* 番茄钟 */
.pomodoro-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(126, 182, 232, 0.3);
  transition: var(--transition);
}

.pomodoro-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(126, 182, 232, 0.4);
}

.pomodoro-btn.running {
  background: linear-gradient(135deg, var(--danger), #D32F2F);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

/* 内容滚动区 */
.content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ========== 卡片 ========== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: var(--transition);
  margin-bottom: 16px;
}

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

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  color: var(--primary);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-left: auto;
}

/* ========== 网格 ========== */
.grid {
  display: grid;
  gap: 16px;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  color: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(126, 182, 232, 0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(126, 182, 232, 0.4);
}

.btn-outline {
  background: #fff;
  color: var(--primary-dark) !important;
  border: 1px solid var(--primary-light);
}
.btn-outline:hover {
  background: var(--primary-pale);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary) !important;
}
.btn-ghost:hover {
  background: var(--border-light);
}

.btn-danger {
  background: var(--danger);
  color: #fff !important;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}
.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}
.btn-block {
  width: 100%;
}

/* ========== 标签 ========== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}
.tag-primary { background: var(--primary-lighter); color: var(--primary-dark); }
.tag-success { background: #E8F5E9; color: #43A047; }
.tag-warning { background: #FFF3E0; color: #EF6C00; }
.tag-danger { background: #FFEBEE; color: #C62828; }
.tag-info { background: #E3F2FD; color: #1976D2; }
.tag-default { background: var(--border-light); color: var(--text-secondary); }

/* ========== 统计数字 ========== */
.stat {
  text-align: center;
  padding: 16px;
  background: var(--primary-pale);
  border-radius: var(--radius);
  border: 1px solid var(--primary-lighter);
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary-dark);
  line-height: 1.2;
}
.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ========== 进度条 ========== */
.progress {
  height: 6px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

/* ========== 外部跳转组件 ========== */
.ext-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--primary-pale);
  border-radius: var(--radius);
  margin-top: 16px;
}

.ext-link {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}
.ext-link:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-lighter);
}
.ext-link .ext-icon {
  font-size: 16px;
}

/* ========== 番茄钟弹窗 ========== */
.pomodoro-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}
.pomodoro-overlay.show {
  display: flex;
}

.pomodoro-modal {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 32px;
  text-align: center;
  width: 320px;
  box-shadow: var(--shadow-lg);
}

.pomodoro-display {
  font-size: 48px;
  font-weight: 800;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
  margin: 16px 0;
}

.pomodoro-modes {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
}
.pomodoro-mode {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
}
.pomodoro-mode.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pomodoro-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

/* ========== 表单 ========== */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: #fff;
  color: var(--text-primary);
  transition: var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(126, 182, 232, 0.15);
}
.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* ========== 列表 ========== */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  transition: var(--transition);
  cursor: pointer;
}
.list-item:hover {
  background: var(--primary-pale);
}
.list-item-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--primary-lighter);
  color: var(--primary-dark);
  flex-shrink: 0;
}
.list-item-content {
  flex: 1;
  min-width: 0;
}
.list-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.list-item-desc {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-tertiary);
}
.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #fff;
  border-radius: var(--radius);
  padding: 12px 20px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.3s ease;
  border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.danger { border-left-color: var(--danger); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ========== 日历 ========== */
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  position: relative;
}
.calendar-day.checked {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}
.calendar-day.today {
  border: 2px solid var(--primary);
}
.calendar-day.other-month {
  opacity: 0.3;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    min-width: 0;
    z-index: 100;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .menu-toggle {
    display: flex !important;
  }
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }
  .topbar-title {
    font-size: 15px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .pomodoro-btn {
    padding: 5px 12px;
    font-size: 12px;
    flex-shrink: 0;
  }
  .pomodoro-btn span:first-child {
    display: none;
  }
  .content-scroll {
    padding: 12px;
  }
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--primary-pale);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 20px;
  color: var(--primary-dark);
}

/* 移动端遮罩 */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 99;
}
.sidebar-overlay.show {
  display: block;
}

/* ========== 页面切换动画 ========== */
.page {
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== 通用工具类 ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary-dark); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-tertiary); }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 20px; }
.font-bold { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.hidden { display: none; }
