@font-face {
  font-family: 'TencentSans';
  src: url('./TencentSans-W3.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap; /* 添加字体显示策略 */
}

/* 使用腾讯字体作为全局字体 */
html, body {
  font-family: 'TencentSans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

:root {
  --border: #e5e7eb;
  --muted: #6b7280;
  --text: #111827;
  --primary: #2563eb;
  --save-ok: #16a34a;
  --save-busy: #f59e0b;
  --save-fail: #dc2626;
  --bg: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  background-size: 100% auto;
  background-position: center top;
  background-repeat: no-repeat;
  background-attachment: fixed;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: 100% auto;
  background-position: center top;
  background-repeat: no-repeat;
  opacity: 0.3;
  z-index: -1;
}

/* 搜索页面特殊样式 */
.search-container {
  background-color: rgba(255, 255, 255, 0.5);
  padding: 20px;
  border-radius: 8px;
  margin: 20px auto;
  max-width: 980px;
}

.search-results {
  background-color: rgba(255, 255, 255, 0.5);
  padding: 15px;
  border-radius: 8px;
  margin-top: 20px;
}

.search-form {
  background-color: rgba(255, 255, 255, 0.5);
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

/* 认证状态行样式 */
.auth-status-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  gap: 8px;
  flex-wrap: nowrap;
  width: 100%;
  overflow: hidden;
}

/* 弹性空间占位符 */
.flex-spacer {
  flex-grow: 1;
}

.auth-label {
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.auth-value {
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0; /* 允许内容收缩 */
  flex: 0 1 auto; /* 不增长，但可以收缩 */
}

.auth-separator {
  color: var(--muted);
  font-size: 14px;
  flex-shrink: 0;
}

.container {
  max-width: 980px;
  margin: 24px auto;
  padding: 0 16px;
}

h1 {
  margin: 0 0 16px;
  font-size: 22px;
  color: white;
}

.auth-section {
  background-color: rgba(255, 255, 255, 0.5);
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 20px;
  min-width: 0; /* 允许子元素收缩 */
}

#auth-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
}

#auth-form input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 220px;
}

.auth-actions {
  display: flex;
  gap: 8px;
}

button {
  padding: 8px 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

/* 用户信息组样式 */
.user-info-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow: hidden; /* 防止溢出 */
  min-width: 0; /* 允许内容收缩 */
}

/* 退出登录按钮特殊样式 */
#btn-sign-out {
  white-space: nowrap;
  padding: 8px 16px; /* 与nav-button保持一致 */
  font-size: 14px;
  align-self: center;
  flex-shrink: 0;
  margin-left: auto; /* 将按钮推到最右侧 */
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px; /* 与nav-button保持一致 */
  cursor: pointer;
  font-family: 'TencentSans', sans-serif;
  width: 100px; /* 设置固定宽度确保按钮大小完全一致 */
  text-align: center; /* 文字居中 */
  transition: all 0.3s ease; /* 添加过渡效果 */
}

#btn-sign-out:hover {
  background-color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.3);
}

#btn-sign-out:active {
  background-color: #1e40af;
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(29, 78, 216, 0.4);
}

/* 搜索日历按钮样式已移除，统一使用nav-button类 */

/* 按钮行样式 */
.button-row {
  display: flex;
  gap: 8px;
  padding: 10px 0;
  justify-content: flex-start;
}

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

.hint {
  color: var(--muted);
  margin: 8px 0 0;
}

.msg {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.hidden { display: none; }

/* 日历控制区域样式 */
.calendar-controls {
  margin-bottom: 20px;
}

/* 控制容器 - 包含导航和保存状态 */
.controls-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

/* 月份导航栏样式 - 确保所有元素在同一行并挨在一起 */
.month-nav {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 5px;
}

/* 当前月份显示 */
.current-month-display {
  margin: 0;
  font-size: 18px;
  font-weight: normal;
  white-space: nowrap;
}

/* 导航按钮样式 */
.nav-button {
  padding: 8px 16px;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  text-decoration: none; /* 移除下划线 */
  display: inline-block; /* 确保链接表现像按钮 */
  text-align: center; /* 文字居中 */
  font-size: 14px; /* 统一字体大小 */
  width: 100px; /* 设置固定宽度确保按钮大小完全一致 */
  font-family: 'TencentSans', sans-serif;
}

.nav-button:hover {
  background-color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.3);
}

.nav-button:active {
  background-color: #1e40af;
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(29, 78, 216, 0.4);
}

.nav-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: all 0.4s ease;
  z-index: 0;
}

.nav-button:active::before {
  width: 120px;
  height: 120px;
}

.nav-button span {
  position: relative;
  z-index: 1;
}

/* 年月选择区域 */
.year-month-select {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

/* 选择框样式 */
#year-select, #month-select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  font-family: TencentSans, sans-serif;
  cursor: pointer;
}

#save-indicator {
  font-size: 14px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  margin-left: auto; /* 将元素推到右侧 */
  white-space: nowrap;
}

#save-indicator.saving {
  border-color: var(--save-busy);
  color: var(--save-busy);
}

#save-indicator.loading {
  border-color: #6366f1;
  color: #6366f1;
}

#save-indicator.saved {
  border-color: var(--save-ok);
  background-color: rgba(255, 255, 255, 0.5);
  color: #007bff;
}

#save-indicator.loading-complete {
  border-color: #3b82f6;
  color: #3b82f6;
}

#save-indicator.error {
  border-color: var(--save-fail);
  color: var(--save-fail);
}

.calendar-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  table-layout: fixed;
}

.calendar-table th, .calendar-table td {
  border: 1px solid var(--border);
  vertical-align: top;
  width: calc(100% / 7);
}

.calendar-table th {
  background: #f9fafb;
  padding: 8px 6px;
  font-weight: 200;
  text-align: center;
}

.calendar-table th {
  background: transparent;
  color: white;
}

.calendar-table td {
  height: 180px;
  padding: 6px;
}

.day-cell {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

.day-label {
  font-size: 12px;
  color: white;
  margin-bottom: 6px;
}

.day-content {
  font-family: 'TencentSans', sans-serif;
  font-size: 9px;
  flex: 1;
  padding: 6px;
  border: 1px dashed transparent;
  border-radius: 6px;
  outline: none;
  overflow: auto;
  white-space: pre-wrap;
  background-color: rgba(255, 255, 255, 0.5);
}

/* 格子内容中的链接样式 */
.day-content a,
.day-content .clickable-link {
  color: #2563eb !important;
  text-decoration: underline !important;
  font-weight: 500 !important;
  transition: all 0.2s ease !important;
  word-break: break-all !important;
  cursor: pointer !important;
  pointer-events: auto !important;
  position: relative !important;
  z-index: 10 !important;
  display: inline !important;
}

.day-content a:hover,
.day-content .clickable-link:hover {
  color: #1d4ed8 !important;
  background-color: rgba(37, 99, 235, 0.1) !important;
  padding: 1px 2px !important;
  border-radius: 2px !important;
}

.day-content a:visited {
  color: #7c3aed !important;
}

/* 图片拖放区域 */
.image-drop-zone {
  margin-top: 5px;
  border: 2px dashed #ccc;
  border-radius: 4px;
  padding: 5px;
  text-align: center;
  font-size: 10px;
  color: #999;
  cursor: pointer;
  transition: all 0.3s;
  display: none; /* 默认隐藏，鼠标悬停时显示 */
}

.day-cell:hover .image-drop-zone {
  display: block; /* 鼠标悬停时显示 */
}

.image-drop-zone.dragover {
  border-color: var(--primary);
  background-color: rgba(37, 99, 235, 0.1);
}

/* 图片容器 */
.cell-images {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 5px;
}

/* 图片缩略图 */
.cell-thumbnail {
  width: 30px;
  height: 30px;
  object-fit: cover;
  border-radius: 3px;
  cursor: pointer;
  transition: transform 0.2s;
}

.cell-thumbnail:hover {
  transform: scale(1.1);
}

/* 为有内容的格子添加白色透明背景 */
.day-content:not(:empty) {
  background-color: rgba(255, 255, 255, 0.5);
}

.day-content:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.5);
}

/* 悬停效果 */
.day-cell.hover {
  background-color: transparent;
}

/* 浮窗样式 */
.content-tooltip {
  position: absolute;
  background-color: #ddeee4;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  font-family: 'TencentSans', sans-serif;
  font-size: 13px; /* 原始大小的2倍 */
  width: 300px;
  max-height: 600px;
  overflow: auto;
  white-space: pre-wrap;
  pointer-events: none; /* 防止浮窗阻挡鼠标事件 */
}

/* 浮窗中的链接样式 */
.content-tooltip a,
.content-tooltip .clickable-link {
  color: #2563eb !important;
  text-decoration: underline !important;
  font-weight: 500 !important;
  word-break: break-all !important;
  cursor: pointer !important;
}

.content-tooltip a:hover,
.content-tooltip .clickable-link:hover {
  color: #1d4ed8 !important;
}

.content-tooltip a:visited {
  color: #7c3aed !important;
}

/* 搜索表单样式 */
.search-container {
  background: rgba(255, 255, 255, 0.9);
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  margin: 20px auto;
  max-width: 1000px;
}

.search-row {
  display: flex;
  gap: 15px;
  align-items: end;
  flex-wrap: wrap;
}

.search-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* 日期选择框组 - 紧凑宽度 */
.search-group.date-group {
  flex: 0 0 auto;
  min-width: 80px;
}

/* 搜索内容输入框组 - 占据剩余空间 */
.search-group.content-group {
  flex: 1;
  min-width: 200px;
}

/* 搜索按钮组 */
.search-group.button-group {
  flex: 0 0 auto;
}

.search-group label {
  font-weight: 500;
  color: #2c3e50;
  font-size: 14px;
  margin-bottom: 5px;
}

.search-group select,
.search-group input {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.3s ease;
  background: white;
  font-family: 'TencentSans', sans-serif;
}

/* 日期选择框 - 紧凑宽度 */
.search-group.date-group select {
  width: 80px;
  padding: 10px 8px;
}

.search-group select:focus,
.search-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* 搜索按钮样式 */
.search-button {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.3s ease;
  font-family: 'TencentSans', sans-serif;
}

.search-button:hover {
  background-color: #1d4ed8;
}

.search-button:active {
  background-color: #1e40af;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .month-nav {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .calendar-table td {
    height: 80px;
  }
  
  .day-content {
    min-height: 30px;
  }
  
  .search-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-group.date-group {
    min-width: 100%;
  }
  
  .search-group.date-group select {
    width: 100%;
  }
}