/* ========================================== 
   全局样式 - 温柔粉色系
   ========================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  background: linear-gradient(135deg, #ffeef8 0%, #ffe4f1 100%);
  min-height: 100vh;
  color: #5a4a5e;
}

#app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* ========================================== 
   登录页面
   ========================================== */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: #8b7a8f;
}

.login-box {
  background: white;
  border-radius: 24px;
  padding: 48px;
  box-shadow: 0 8px 32px rgba(219, 174, 211, 0.3);
  max-width: 400px;
  width: 90%;
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, #d4a5c8 0%, #b88aaa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: 32px;
}

.login-input {
  width: 100%;
  padding: 14px 20px;
  border: 2px solid #f5e6f1;
  border-radius: 12px;
  font-size: 16px;
  margin-bottom: 20px;
  transition: border 0.3s;
}

.login-input:focus {
  outline: none;
  border-color: #d4a5c8;
}

.login-btn {
  width: 100%;
  padding: 14px;
  border: none;
  background: linear-gradient(135deg, #d4a5c8 0%, #b88aaa 100%);
  color: white;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(212, 165, 200, 0.4);
}

.login-error {
  color: #d4a5c8;
  text-align: center;
  margin-top: 12px;
  font-size: 14px;
}

/* ========================================== 
   加载屏幕
   ========================================== */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: #b88aaa;
  font-size: 18px;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f5e6f1;
  border-top-color: #d4a5c8;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========================================== 
   顶部导航
   ========================================== */
.app-header {
  background: white;
  border-radius: 20px;
  padding: 24px 32px;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(219, 174, 211, 0.15);
}

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

.app-title {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, #d4a5c8 0%, #b88aaa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.user-info {
  display: flex;
  gap: 12px;
  align-items: center;
}

.user-name {
  background: linear-gradient(135deg, #d4a5c8 0%, #b88aaa 100%);
  color: white;
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: 600;
}

.logout-btn {
  padding: 8px 16px;
  border: 2px solid #d4a5c8;
  background: white;
  color: #b88aaa;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.logout-btn:hover {
  background: #d4a5c8;
  color: white;
}

/* ========================================== 
   标签页导航
   ========================================== */
.tab-nav {
  background: white;
  border-radius: 20px;
  padding: 12px;
  margin-bottom: 20px;
  display: flex;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(219, 174, 211, 0.15);
}

.tab-btn {
  flex: 1;
  padding: 12px 24px;
  border: none;
  background: transparent;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  color: #a092a5;
}

.tab-btn:hover {
  background: #fef5fb;
}

.tab-btn.active {
  background: linear-gradient(135deg, #d4a5c8 0%, #b88aaa 100%);
  color: white;
}

/* ========================================== 
   主内容区
   ========================================== */
.main-content {
  background: white;
  border-radius: 20px;
  padding: 24px;
  min-height: 600px;
  box-shadow: 0 4px 20px rgba(219, 174, 211, 0.15);
}

.tab-content {
  display: none;
}

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

/* ========================================== 
   筛选栏
   ========================================== */
.filter-bar {
  margin-bottom: 24px;
}

.filter-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.calendar-toggle-btn {
  padding: 10px 20px;
  border: 2px solid #d4a5c8;
  background: white;
  color: #b88aaa;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.calendar-toggle-btn:hover {
  background: #d4a5c8;
  color: white;
}

.search-input {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid #f5e6f1;
  border-radius: 12px;
  font-size: 14px;
  transition: border 0.3s;
}

.search-input:focus {
  outline: none;
  border-color: #d4a5c8;
}

.filter-select {
  padding: 10px 16px;
  border: 2px solid #f5e6f1;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  background: white;
  transition: border 0.3s;
}

.filter-select:focus {
  outline: none;
  border-color: #d4a5c8;
}

.batch-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.batch-btn {
  padding: 8px 16px;
  border: none;
  background: #fef5fb;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  color: #8b7a8f;
}

.batch-btn:hover {
  background: #f5e6f1;
}

.batch-btn.delete-btn {
  background: #ffe4f1;
  color: #c57ba6;
}

.batch-btn.delete-btn:hover {
  background: #ffcce5;
  color: #b55d8f;
}

/* ========================================== 
   日历视图
   ========================================== */
.calendar-view {
  background: #fef5fb;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
  position: relative;
  z-index: 10;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.month-nav-btn {
  padding: 8px 16px;
  border: none;
  background: white;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(219, 174, 211, 0.2);
  color: #8b7a8f;
}

.month-nav-btn:hover {
  background: #d4a5c8;
  color: white;
}

.current-month {
  font-size: 20px;
  font-weight: 700;
  color: #5a4a5e;
}

.close-calendar-btn {
  padding: 8px 16px;
  border: none;
  background: #ffcce5;
  color: #b55d8f;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.close-calendar-btn:hover {
  background: #ffb3d9;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  padding: 12px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  padding: 8px 4px;
  border: 2px solid transparent;
  color: #5a4a5e;
  min-height: 60px;
}

.calendar-day:hover {
  border-color: #d4a5c8;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(212, 165, 200, 0.2);
}

.calendar-day.has-conversations {
  background: linear-gradient(135deg, #d4a5c8 0%, #b88aaa 100%);
  color: white;
  font-weight: 700;
}

.calendar-day.selected {
  border: 3px solid #b88aaa !important;
  box-shadow: 0 0 0 3px rgba(212, 165, 200, 0.3) !important;
}

.calendar-day-number {
  font-size: 18px;
  margin-bottom: 4px;
  font-weight: 600;
}

.calendar-day-count {
  font-size: 11px;
  opacity: 0.9;
  font-weight: 500;
}

.calendar-day.empty {
  background: #f5e6f1;
  cursor: default;
  opacity: 0.4;
}

.calendar-day.empty:hover {
  border-color: transparent;
  transform: none;
  box-shadow: none;
}

/* ========================================== 
   对话卡片
   ========================================== */
.conversations-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.conversation-card {
  background: #fef5fb;
  border-radius: 16px;
  padding: 20px;
  transition: all 0.3s;
  border: 2px solid transparent;
}

.conversation-card:hover {
  border-color: #d4a5c8;
  box-shadow: 0 4px 16px rgba(212, 165, 200, 0.25);
}

.conversation-card.selected {
  border-color: #d4a5c8;
  background: #f5e6f1;
}

.conversation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.conversation-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.conversation-id {
  font-size: 12px;
  color: #a092a5;
  font-weight: 600;
}

.conversation-time {
  font-size: 12px;
  color: #c4b5c8;
}

.conversation-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.tag.日常 { background: #e8d4f0; color: #7a5a86; }
.tag.思辨 { background: #d4e8f0; color: #5a7a86; }
.tag.关系 { background: #f0d4e0; color: #865a6e; }
.tag.创作 { background: #f0e8d4; color: #867a5a; }
.tag.情绪 { background: #f0e0d4; color: #866e5a; }

.conversation-importance {
  color: #e8b4d4;
  font-size: 14px;
}

.conversation-content {
  margin-bottom: 12px;
}

.conversation-message {
  margin-bottom: 8px;
  line-height: 1.6;
  color: #5a4a5e;
  white-space: pre-wrap; /* 保留换行 */
}

.message-text {
  display: inline;
  word-wrap: break-word;
  white-space: pre-wrap; /* 确保有这一行 */
}

.conversation-message strong {
  color: #b88aaa;
  font-weight: 700;
}

.conversation-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #a092a5;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #d4a5c8;
}

.delete-btn-single {
  padding: 8px 16px;
  border: none;
  background: #ffe4f1;
  color: #c57ba6;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.delete-btn-single:hover {
  background: #ffcce5;
  color: #b55d8f;
}

/* ========================================== 
   摘要卡片
   ========================================== */
.summaries-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.summary-card {
  background: #fef5fb;
  border-radius: 16px;
  padding: 20px;
  transition: all 0.3s;
  border: 2px solid transparent;
}

.summary-card:hover {
  border-color: #d4a5c8;
  box-shadow: 0 4px 16px rgba(212, 165, 200, 0.25);
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 12px;
}

.summary-range {
  font-size: 14px;
  color: #a092a5;
  font-weight: 600;
}

.summary-text {
  line-height: 1.8;
  margin-bottom: 12px;
  color: #5a4a5e;
}

/* ========================================== 
   日记页面
   ========================================== */
.diary-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.diary-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.diary-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fef5fb;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  padding: 12px;
  border: 2px solid transparent;
  color: #5a4a5e;
}

.diary-day:hover {
  border-color: #d4a5c8;
  transform: translateY(-2px);
}

.diary-day.has-diary {
  background: linear-gradient(135deg, #e8b4d4 0%, #d4a5c8 100%);
  color: white;
  font-weight: 700;
}

.diary-day.empty {
  background: #f5e6f1;
  cursor: default;
  opacity: 0.5;
}

.diary-day.empty:hover {
  border-color: transparent;
  transform: none;
}

.diary-detail {
  background: linear-gradient(135deg, #fff0f8 0%, #ffe8f4 100%);
  border-radius: 16px;
  padding: 32px;
  margin-top: 24px;
}

.diary-detail h3 {
  font-size: 24px;
  margin-bottom: 20px;
  color: #8b7a8f;
}

.diary-content {
  line-height: 2;
  font-size: 16px;
  color: #5a4a5e;
  white-space: pre-wrap;
  margin-bottom: 20px;
}

.diary-actions {
  display: flex;
  justify-content: flex-end;
}

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

.stat-card {
  background: linear-gradient(135deg, #d4a5c8 0%, #b88aaa 100%);
  border-radius: 16px;
  padding: 24px;
  color: white;
  text-align: center;
}

.stat-card h3 {
  font-size: 16px;
  margin-bottom: 12px;
  opacity: 0.9;
}

.stat-number {
  font-size: 36px;
  font-weight: 700;
}

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

.chart-card {
  background: #fef5fb;
  border-radius: 16px;
  padding: 24px;
}

.chart-card.full-width {
  grid-column: 1 / -1;
}

.chart-card h3 {
  font-size: 18px;
  margin-bottom: 16px;
  color: #5a4a5e;
}

/* ========================================== 
   分页
   ========================================== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.pagination button {
  padding: 8px 16px;
  border: none;
  background: #fef5fb;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  color: #8b7a8f;
}

.pagination button:hover:not(:disabled) {
  background: #d4a5c8;
  color: white;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination .page-info {
  font-size: 14px;
  color: #a092a5;
  font-weight: 600;
}

/* ========================================== 
   确认对话框
   ========================================== */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(212, 165, 200, 0.3);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.dialog-box {
  background: white;
  border-radius: 20px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(212, 165, 200, 0.4);
}

.dialog-box h3 {
  font-size: 20px;
  margin-bottom: 12px;
  color: #5a4a5e;
}

.dialog-box p {
  font-size: 16px;
  color: #a092a5;
  margin-bottom: 24px;
  line-height: 1.6;
}

.dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.dialog-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.cancel-btn {
  background: #fef5fb;
  color: #a092a5;
}

.cancel-btn:hover {
  background: #f5e6f1;
}

.confirm-btn {
  background: #ffcce5;
  color: #b55d8f;
}

.confirm-btn:hover {
  background: #ffb3d9;
}

/* ========================================== 
   空状态
   ========================================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #c4b5c8;
}

.empty-state h3 {
  font-size: 24px;
  margin-bottom: 12px;
  color: #a092a5;
}

.empty-state p {
  font-size: 16px;
}

/* ========================================== 
   响应式设计（手机端适配 - 修复日历溢出）
   ========================================== */
@media (max-width: 768px) {
  #app {
    padding: 10px;
  }

  .filter-row {
    flex-direction: column;
  }

  /* 手机端日历优化 */
  .calendar-view {
    padding: 8px;
    width: 100%;
    overflow: hidden;
  }

  .calendar-header {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
  }

  .month-nav-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 12px;
    white-space: nowrap;
  }

  .current-month {
    font-size: 16px;
    width: 100%;
    text-align: center;
    order: -1;
    margin-bottom: 8px;
  }

  .close-calendar-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* 强制日历 7 等分且不撑开容器 */
  .calendar-grid,
  .diary-calendar {
    display: grid !important;
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    gap: 4px;
    padding: 4px;
    width: 100%;
  }

  .calendar-day,
  .diary-day {
    min-height: unset !important; /* 撤销固定高度 */
    width: 100%;
    aspect-ratio: 1; /* 保持正方形 */
    padding: 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .calendar-day-number {
    font-size: 13px;
    margin-bottom: 0;
  }

  .calendar-day-count {
    font-size: 8px;
    transform: scale(0.85);
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .app-title {
    font-size: 20px;
  }

  .tab-btn {
    font-size: 14px;
    padding: 10px 16px;
  }

  /* 内容区域布局调整 */
  .conversation-header,
  .conversation-meta,
  .conversation-actions,
  .summary-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .login-box {
    padding: 32px 24px;
  }

  /* 对话卡片手机端优化 */
  .conversation-card {
    padding: 16px;
  }

  .conversation-meta {
    gap: 8px;
  }

  .conversation-tags {
    width: 100%;
  }
}
