/**
 * 🎒 楠溪托管 (Nanxi Care) - 移动端优先原生样式系统 (app.css)
 * 风格：暖调学术风 (Warm Scholastic) - 森林墨绿 + 暖米白 + 陶土橙
 */

:root {
  --primary: #2d5a43;
  --primary-dark: #1b3a2a;
  --primary-light: #417e5f;
  --primary-soft: #edf5f0;
  
  --accent-amber: #d97706;
  --accent-amber-soft: #fef3c7;
  --accent-rose: #e11d48;
  --accent-rose-soft: #ffe4e6;
  --accent-blue: #2563eb;
  --accent-blue-soft: #eff6ff;

  --bg-app: #f6f5f0;
  --bg-card: #ffffff;
  --bg-subtle: #f9f8f4;
  --border-color: #e5e2d8;
  --border-focus: #2d5a43;

  --text-main: #1f2937;
  --text-muted: #6b7280;
  --text-light: #9ca3af;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(45, 90, 67, 0.05);
  --shadow-md: 0 4px 14px rgba(45, 90, 67, 0.08);
  --shadow-lg: 0 10px 25px rgba(45, 90, 67, 0.12);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* 基础重置与排版规范 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(75px + var(--safe-bottom));
}

/* 桌面端居中容器 */
.app-viewport {
  max-width: 580px;
  margin: 0 auto;
  min-height: 100vh;
  background-color: var(--bg-app);
  position: relative;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.04);
}

/* 顶部 App Bar */
.top-app-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(251, 250, 246, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: calc(0.75rem + var(--safe-top)) 1rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: var(--shadow-sm);
}

.brand-text h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.2;
}

.brand-text p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* 视角切换药丸按钮 */
.view-toggle-pill {
  display: inline-flex;
  background: #eae7dd;
  padding: 3px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
}

.view-toggle-btn {
  border: none;
  background: transparent;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.view-toggle-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* 通用 Bento 卡片 */
.bento-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin: 0.85rem 1rem;
  box-shadow: var(--shadow-sm);
}

.bento-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.bento-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* 置顶公告横幅 */
.announcement-banner {
  background: #fffbeb;
  border: 1px solid #fef08a;
  border-radius: var(--radius-md);
  margin: 0.85rem 1rem;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  position: relative;
}

.ann-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.ann-content h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: #854d0e;
  margin-bottom: 0.2rem;
}

.ann-content p {
  font-size: 0.8rem;
  color: #713f12;
  line-height: 1.45;
}

/* 统计胶囊矩阵 */
.stat-capsule-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin: 0.85rem 1rem;
}

.stat-capsule {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.4rem;
  text-align: center;
}

.stat-capsule .num {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.stat-capsule .lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* 学生头像打卡矩阵 (10秒快速点名) */
.student-matrix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.student-card-tile {
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.4rem;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.student-card-tile:active {
  transform: scale(0.96);
}

.student-card-tile.arrived {
  border-color: var(--primary);
  background: #f0fdf4;
}

.student-card-tile.left-shop {
  border-color: #9ca3af;
  background: #f3f4f6;
  opacity: 0.75;
}

.student-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  position: relative;
}

.tile-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.tile-grade {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.tile-status-tag {
  font-size: 0.64rem;
  font-weight: 600;
  margin-top: 0.25rem;
  padding: 1px 6px;
  border-radius: 4px;
  display: inline-block;
}

.tile-status-tag.waiting {
  background: #fee2e2;
  color: #b91c1c;
}

.tile-status-tag.here {
  background: #dcfce7;
  color: #15803d;
}

.tile-status-tag.left {
  background: #e5e7eb;
  color: #4b5563;
}

/* 展开式学生作业与反馈督导卡片 */
.student-detail-accordion {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  background: #ffffff;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.accordion-bar {
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  background: #ffffff;
}

.accordion-bar:hover {
  background: var(--bg-subtle);
}

.student-info-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.accordion-panel {
  display: none;
  padding: 1rem;
  background: #fdfdfc;
  border-top: 1px dashed var(--border-color);
}

.accordion-panel.open {
  display: block;
}

/* 作业科目三态切换器 */
.subject-row {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f3f1ea;
}

.subject-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.subject-name {
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* 三态单选按钮组 */
.tri-state-group {
  display: inline-flex;
  background: #edebe4;
  padding: 2px;
  border-radius: var(--radius-full);
}

.tri-state-btn {
  border: none;
  background: transparent;
  padding: 0.22rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  cursor: pointer;
  color: var(--text-muted);
}

.tri-state-btn.active.not_started {
  background: #ffffff;
  color: #dc2626;
  font-weight: 700;
}

.tri-state-btn.active.doing {
  background: #ffffff;
  color: #d97706;
  font-weight: 700;
}

.tri-state-btn.active.done {
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

/* 免打字流式气泡标签 (南京苏教/译林特色) */
.chip-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.4rem 0;
}

.bubble-chip {
  background: #f3f1ea;
  border: 1px solid #e5e1d5;
  color: #4b5563;
  padding: 0.28rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.bubble-chip:active {
  transform: scale(0.95);
}

.bubble-chip.selected {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}

/* 照片拍照与上传网格 */
.photo-uploader-section {
  margin: 0.8rem 0;
}

.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.photo-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #f9f9f9;
}

.photo-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}

.photo-delete-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border: none;
  cursor: pointer;
}

.upload-trigger-tile {
  width: 100%;
  aspect-ratio: 1;
  border: 1.5px dashed var(--border-color);
  border-radius: var(--radius-sm);
  background: #faf9f6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  gap: 0.2rem;
  transition: border-color 0.2s;
}

.upload-trigger-tile:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.upload-trigger-tile span {
  font-size: 1.25rem;
}

.upload-trigger-tile small {
  font-size: 0.65rem;
}

/* 家长端独立安全看护锁屏 */
.parent-lock-card {
  text-align: center;
  padding: 2.5rem 1.5rem;
  margin: 2rem 1rem;
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

.parent-lock-icon {
  width: 64px;
  height: 64px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1.2rem;
}

.code-input-box {
  width: 100%;
  max-width: 240px;
  margin: 1.2rem auto;
  font-size: 1.4rem;
  text-align: center;
  letter-spacing: 4px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.7rem;
  border: 2px solid var(--primary);
  border-radius: var(--radius-md);
  outline: none;
}

/* 家长端今日时光轴 (Timeline) */
.timeline-wrap {
  position: relative;
  padding-left: 1.8rem;
  margin: 1rem 0;
}

.timeline-wrap::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 9px;
  width: 2px;
  background: #e5e2d8;
}

.timeline-item {
  position: relative;
  margin-bottom: 1.25rem;
}

.timeline-node {
  position: absolute;
  left: -1.8rem;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  box-shadow: var(--shadow-sm);
}

.timeline-node.done {
  background: var(--primary);
  color: #fff;
}

.timeline-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.timeline-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.timeline-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

/* 排行榜样式 */
.rank-podium {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  align-items: flex-end;
  gap: 0.4rem;
  margin: 1.5rem 0 1rem;
  text-align: center;
}

.podium-box {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.8rem 0.4rem;
  box-shadow: var(--shadow-sm);
}

.podium-box.rank-1 {
  background: #fffbeb;
  border-color: #fde047;
  transform: translateY(-8px);
}

.podium-badge {
  font-size: 1.4rem;
  margin-bottom: 0.2rem;
}

.podium-score {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.rank-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid #f3f1ea;
}

.rank-index {
  width: 26px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

/* 底部原生 Tab 导航 */
.bottom-nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  max-width: 580px;
  margin: 0 auto;
}

.nav-tab-btn {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.68rem;
  cursor: pointer;
  padding: 0.25rem 0.6rem;
  gap: 0.15rem;
  min-width: 56px;
  height: 100%;
}

.nav-tab-btn .nav-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.nav-tab-btn.active {
  color: var(--primary);
  font-weight: 700;
}

/* 全屏大图预览灯箱 (Lightbox) */
.lightbox-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.lightbox-modal.show {
  display: flex;
}

.lightbox-modal img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.lightbox-close-btn {
  position: absolute;
  top: calc(1rem + var(--safe-top));
  right: 1.2rem;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
}

/* 现代化通用按钮与输入控件规范 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-outline {
  background: #ffffff;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-sm {
  min-height: 32px;
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  font-size: 16px; /* 防止 iOS 自动缩放聚焦 */
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #ffffff;
  outline: none;
  font-family: inherit;
  color: var(--text-main);
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--border-focus);
}

/* 胶囊轻提示 Toast */
.app-toast-capsule {
  position: fixed;
  top: calc(1.5rem + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(27, 58, 42, 0.94);
  color: #ffffff;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-toast-capsule.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
