/* 教师移动端原生 App 风格样式表 */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg-app: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

body {
  background-color: #e2e8f0;
  color: var(--text-main);
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

#app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background-color: var(--bg-app);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
  overflow-x: hidden;
}

/* 顶部原生导航栏 */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 状态药丸标签 */
.status-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.status-online {
  background: #dcfce7;
  color: #15803d;
}

.status-offline {
  background: #f1f5f9;
  color: #64748b;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* 主内容区 */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 90px 16px;
}

/* 底部原生 Tab 导航 */
.app-tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 100%;
  max-width: 480px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 var(--safe-bottom) 0;
  z-index: 50;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 16px;
  border-radius: 8px;
  transition: all 0.2s;
}

.tab-item.active {
  color: var(--primary);
  font-weight: 700;
}

.tab-icon {
  font-size: 20px;
}

/* 现代化卡片 */
.ui-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* 按钮规范 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-play {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.28);
}

.btn-secondary {
  background: #f1f5f9;
  color: #475569;
}

.btn-danger {
  background: #fee2e2;
  color: #ef4444;
}

.btn-outline {
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-main);
}

/* 呼叫聊天流气泡 */
.msg-stream {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 108px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.msg-row.teacher {
  align-self: flex-end;
}

.msg-row.student {
  align-self: flex-start;
}

.msg-bubble {
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.msg-bubble.teacher {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.msg-bubble.student {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

/* 消息操作工具栏（再次播放、删除） */
.msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  justify-content: flex-end;
  border-top: 1px dashed rgba(255, 255, 255, 0.25);
  padding-top: 6px;
}

.msg-row.student .msg-actions {
  justify-content: flex-start;
  border-top-color: var(--border-color);
}

.msg-action-btn {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  user-select: none;
}

.msg-action-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.msg-action-btn.btn-delete {
  border-color: rgba(254, 202, 202, 0.4);
  background: rgba(239, 68, 68, 0.25);
  color: #fee2e2;
}

.msg-action-btn.btn-delete:hover {
  background: rgba(239, 68, 68, 0.45);
  color: #ffffff;
}

.msg-row.student .msg-action-btn {
  border: 1px solid var(--border-color);
  background: #f1f5f9;
  color: #475569;
}

.msg-row.student .msg-action-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.msg-row.student .msg-action-btn.btn-delete {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.msg-row.student .msg-action-btn.btn-delete:hover {
  background: #fee2e2;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  margin-top: 4px;
  color: var(--text-muted);
}

.msg-row.teacher .msg-meta {
  justify-content: flex-end;
}

/* 状态角标 */
.badge-ack {
  color: #10b981;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.badge-read {
  color: #2563eb;
  font-weight: 700;
}

/* 底部呼叫输入栏 */
.call-bar-fixed {
  position: fixed;
  bottom: 60px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 45;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.04);
}

.quick-tags {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 2px;
}

.tag-btn {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 9999px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.call-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.call-textarea {
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 15px;
  resize: none;
  height: 44px;
  background: #f8fafc;
  outline: none;
}

.call-textarea:focus {
  border-color: var(--primary);
  background: #ffffff;
}

#voice-record-btn {
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: pointer;
}

#voice-record-btn.recording {
  background: #1e293b !important;
  color: #ffffff !important;
  transform: scale(0.98);
}

#voice-record-btn.canceling {
  background: #dc2626 !important;
  color: #ffffff !important;
}

/* 模态弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.2s ease-in-out;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 20px 20px 32px 20px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease-out;
}

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

.input-field {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border-color);
  font-size: 15px;
  margin-top: 6px;
  margin-bottom: 12px;
  outline: none;
}

.input-field:focus {
  border-color: var(--primary);
}

/* iOS 风格切换开关 */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}
.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #CBD5E1;
  transition: .3s;
  border-radius: 28px;
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.switch-toggle input:checked + .switch-slider {
  background-color: var(--primary);
}
.switch-toggle input:checked + .switch-slider:before {
  transform: translateX(22px);
}
