/* ============================================
   打卡网站 - iOS 风格样式系统
   ============================================ */

/* CSS 变量 & 主题 */
:root {
  /* 浅色主题 */
  --bg-primary: #ffffff;
  --bg-secondary: #f2f2f7;
  --bg-tertiary: #e8e8ed;
  --text-primary: #1c1c1e;
  --text-secondary: #636366;
  --text-tertiary: #aeaeb2;
  --border-color: #d1d1d6;
  --border-light: #e5e5ea;
  --accent-blue: #007aff;
  --accent-green: #34c759;
  --accent-orange: #ff9500;
  --accent-red: #ff3b30;
  --accent-purple: #af52de;
  --accent-coral: #ff7b6b;
  --accent-teal: #5ac8fa;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}

[data-theme="dark"] {
  --bg-primary: #1c1c1e;
  --bg-secondary: #2c2c2e;
  --bg-tertiary: #3a3a3c;
  --text-primary: #ffffff;
  --text-secondary: #aeb5bc;
  --text-tertiary: #636366;
  --border-color: #48484a;
  --border-light: #38383a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
}

/* 全局重置 */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg-secondary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* 应用容器 */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* ============================================
   页面视图 - SPA 路由
   ============================================ */
.page-view {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.page-view.active {
  display: flex;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 60px;
}

/* ============================================
   顶部导航栏
   ============================================ */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-primary);
  border-bottom: 0.5px solid var(--border-light);
  min-height: 44px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-bar .title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.nav-bar .right-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================
   底部导航
   ============================================ */
.bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 6px 0 10px;
  background: var(--bg-primary);
  border-top: 0.5px solid var(--border-light);
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 16px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 10px;
  transition: color 0.15s;
}

.nav-item.active {
  color: var(--accent-blue);
}

.nav-item .nav-icon {
  font-size: 22px;
  line-height: 1;
}

/* ============================================
   通用组件
   ============================================ */

/* iOS 风格按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  font-family: inherit;
}

.btn:active {
  transform: scale(0.96);
  opacity: 0.8;
}

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

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

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

.btn-ghost {
  background: transparent;
  color: var(--accent-blue);
}

.btn-block {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-md);
}

/* iOS 风格输入框 */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.input-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  padding-left: 4px;
}

.input-field {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.input-field:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.input-field::placeholder {
  color: var(--text-tertiary);
}

/* 卡片 */
.card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border-light);
  padding: 16px;
  margin-bottom: 12px;
}

/* 标签 / 徽章 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}

.badge-fire {
  background: rgba(255, 149, 0, 0.12);
  color: var(--accent-orange);
}

.badge-success {
  background: rgba(52, 199, 89, 0.12);
  color: var(--accent-green);
}

.badge-danger {
  background: rgba(255, 59, 48, 0.12);
  color: var(--accent-red);
}

.badge-blue {
  background: rgba(0, 122, 255, 0.12);
  color: var(--accent-blue);
}

/* 头像圆形 */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 500;
  color: white;
  flex-shrink: 0;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 20px;
}

/* 分割线 */
.divider {
  height: 0.5px;
  background: var(--border-light);
  margin: 0 -16px;
}

/* Toast 提示 */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
  max-width: 360px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.toast-success {
  background: var(--accent-green);
  color: white;
}

.toast-error {
  background: var(--accent-red);
  color: white;
}

.toast-info {
  background: #5856d6;
  color: white;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* 弹窗 Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  padding: 20px 20px 30px;
  animation: slideUp 0.3s ease;
  overflow-y: auto;
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 20px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* iOS 列表样式 */
.list-group {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 0.5px solid var(--border-light);
}

.list-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 0.5px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:active {
  background: var(--bg-secondary);
}

/* ============================================
   登录页面
   ============================================ */
#page-login {
  justify-content: center;
  align-items: center;
  padding: 40px 24px;
  background: var(--bg-secondary);
}

.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  padding: 32px 24px;
  box-shadow: var(--shadow-sm);
}

.login-box .app-logo {
  text-align: center;
  font-size: 36px;
  margin-bottom: 8px;
}

.login-box h1 {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-box p.subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.login-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 2px;
}

.login-tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  transition: all 0.2s;
}

.login-tab.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ============================================
   日历页面
   ============================================ */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-primary);
}

.calendar-month {
  font-size: 16px;
  font-weight: 600;
}

.calendar-nav-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  color: var(--accent-blue);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar-nav-btn:active {
  background: var(--bg-secondary);
}

/* 项目颜色标签 */
.project-tags {
  display: flex;
  gap: 10px;
  padding: 6px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-primary);
  border-bottom: 0.5px solid var(--border-light);
}

.project-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.project-tag:active {
  background: var(--bg-secondary);
}

.project-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* 星期行 */
.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 4px 8px;
  text-align: center;
  background: var(--bg-primary);
}

.weekday-row span {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* 日历网格 */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 2px 8px 8px;
  background: var(--bg-primary);
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 2px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  min-height: 56px;
}

.cal-day:active {
  background: var(--bg-secondary);
}

.cal-day .day-number {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 2px;
}

.cal-day.other-month .day-number {
  color: var(--text-tertiary);
}

.cal-day.today {
  background: var(--accent-blue);
}

.cal-day.today .day-number {
  color: white;
  font-weight: 600;
}

.cal-day.has-checkin {
  /* 无特殊背景，通过缩略图表示 */
}

/* 缩略图区域 */
.day-thumbnails {
  display: flex;
  gap: 1px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.day-thumb {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  border: 0.5px solid rgba(255,255,255,0.3);
}

.day-thumb.more {
  font-size: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  font-weight: 600;
}

/* ============================================
   打卡详情页（点击缩略图展开）
   ============================================ */
.checkin-detail {
  padding: 16px;
}

.checkin-media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 16px;
}

.checkin-media-item {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-tertiary);
  cursor: pointer;
}

.checkin-media-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.checkin-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  padding: 12px 0;
}

/* 评论区 */
.comment-section {
  margin-top: 16px;
}

.comment-item {
  display: flex;
  gap: 8px;
  padding: 8px 0;
}

.comment-item .avatar {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.comment-body {
  flex: 1;
}

.comment-body .username {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-blue);
}

.comment-body .text {
  font-size: 13px;
  color: var(--text-primary);
}

.comment-input {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  border-top: 0.5px solid var(--border-light);
}

.comment-input input {
  flex: 1;
  border: none;
  background: var(--bg-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-xl);
  font-size: 13px;
  outline: none;
  color: var(--text-primary);
}

/* ============================================
   好友 & 聊天页面
   ============================================ */
.chat-layout {
  display: flex;
  height: 100%;
}

.friend-list {
  width: 100px;
  flex-shrink: 0;
  border-right: 0.5px solid var(--border-light);
  overflow-y: auto;
  background: var(--bg-secondary);
}

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.friend-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  cursor: pointer;
  gap: 4px;
  border-bottom: 0.5px solid var(--border-light);
  transition: background 0.1s;
}

.friend-item.active {
  background: var(--bg-primary);
}

.friend-item .friend-name {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}

.msg-bubble.incoming {
  background: var(--bg-secondary);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.msg-bubble.outgoing {
  background: var(--accent-blue);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.msg-bubble .msg-image {
  max-width: 200px;
  border-radius: var(--radius-sm);
  display: block;
}

.msg-bubble .msg-audio {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-time {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 0.5px solid var(--border-light);
  background: var(--bg-primary);
}

.chat-input-area input {
  flex: 1;
  border: 0.5px solid var(--border-color);
  background: var(--bg-secondary);
  padding: 10px 14px;
  border-radius: var(--radius-xl);
  font-size: 14px;
  outline: none;
  color: var(--text-primary);
}

.chat-input-area .chat-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}

.chat-input-area .chat-btn:active {
  opacity: 0.7;
}

.chat-input-area .send-btn {
  background: var(--accent-blue);
  color: white;
}

/* ============================================
   Admin 后台
   ============================================ */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 12px 16px;
}

.admin-stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 14px;
}

.admin-stat-card .stat-number {
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
}

.admin-stat-card .stat-label {
  font-size: 12px;
  color: var(--text-tertiary);
}

.user-row {
  display: grid;
  grid-template-columns: 1fr 1.5fr 0.8fr 0.8fr 0.8fr;
  gap: 4px;
  align-items: center;
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 0.5px solid var(--border-light);
}

.user-row:active {
  background: var(--bg-secondary);
}

.user-row .username {
  color: var(--accent-blue);
  font-weight: 500;
  cursor: pointer;
}

/* Admin 用户穿透详情浮层 */
.admin-detail-panel {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 300;
  display: none;
  flex-direction: column;
  animation: slideIn 0.3s ease;
}

.admin-detail-panel.active {
  display: flex;
}

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

/* ============================================
   上传组件
   ============================================ */
.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 12px 0;
}

.upload-item {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px dashed var(--border-color);
  font-size: 24px;
  color: var(--text-tertiary);
}

.upload-item.preview {
  border-style: solid;
  border-color: transparent;
}

.upload-item.preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-item .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
}

/* ============================================
   设置页面
   ============================================ */
.settings-section {
  padding: 16px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 0.5px solid var(--border-light);
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-item .label {
  font-size: 15px;
}

.settings-item .value {
  font-size: 14px;
  color: var(--text-tertiary);
}

/* 开关 */
.toggle-switch {
  width: 48px;
  height: 30px;
  border-radius: 15px;
  background: var(--border-color);
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
  border: none;
}

.toggle-switch.on {
  background: var(--accent-green);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch.on::after {
  transform: translateX(18px);
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
  font-size: 14px;
  text-align: center;
  gap: 8px;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

/* 加载动画 */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.loading-spinner::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* 滚动条 */
::-webkit-scrollbar {
  width: 0;
}

/* ============================================
   通知权限引导
   ============================================ */
.serverchan-guide {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 12px 0;
}

.serverchan-guide ol {
  padding-left: 20px;
  font-size: 13px;
  line-height: 2;
  color: var(--text-secondary);
}

/* 收音机列表 (选择好友) */
.select-list {
  max-height: 240px;
  overflow-y: auto;
}

.select-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border-light);
  cursor: pointer;
}

.select-item:last-child {
  border-bottom: none;
}

.checkbox {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1.5px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.checkbox.checked {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
}

.checkbox.checked::after {
  content: '✓';
  color: white;
  font-size: 12px;
  font-weight: 700;
}
