/* ========== 拍摄助手 PWA 样式 ========== */

:root {
  --bg: #0f0f1a;
  --bg-surface: #1a1a2e;
  --bg-card: #1e1e32;
  --bg-hover: #252540;
  --text: #e0e0e0;
  --text-secondary: #888;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e74c3c;
  --border: rgba(255,255,255,0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, 'PingFang SC', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#app { max-width: 480px; margin: 0 auto; position: relative; min-height: 100vh; }

/* ========== 页面 ========== */
.page { display: none; }
.page.active { display: flex; flex-direction: column; min-height: 100vh; }

/* ========== 头部 ========== */
.app-header {
  background: linear-gradient(135deg, var(--bg-surface), #16213e);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header h1 { font-size: 17px; font-weight: 700; letter-spacing: 0.5px; }
.header-actions { display: flex; gap: 4px; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}
.btn-icon:active { background: rgba(255,255,255,0.06); }

/* ========== 首页 ========== */
main { flex: 1; padding: 16px; overflow-y: auto; }

/* 模式选择 */
.mode-selector {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
  cursor: pointer;
}
.mode-btn.active, .mode-btn.active:hover {
  border-color: #4a9eff;
  background: rgba(74, 158, 255, 0.15);
}
.mode-btn:hover {
  background: rgba(255,255,255,0.03);
  border-color: var(--text-secondary);
}
.mode-icon { font-size: 32px; margin-bottom: 4px; }
.mode-label { font-size: 16px; font-weight: 600; }
.mode-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; text-align: center; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state h2 { font-size: 20px; margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; line-height: 1.5; }

.btn-large { width: 100%; padding: 14px !important; margin-bottom: 8px; font-size: 15px !important; }
.hint-text { font-size: 12px; color: var(--text-secondary); margin-top: 12px; }

/* ========== 按钮 ========== */
.btn-primary, .btn-secondary, .btn-accent, .btn-cancel {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-hover); color: var(--text-secondary); }
.btn-secondary:active { background: rgba(255,255,255,0.1); }
.btn-accent { background: rgba(233,69,96,0.1); color: var(--accent); }
.btn-accent:active { background: rgba(233,69,96,0.2); }
.btn-cancel { background: transparent; color: var(--text-secondary); }

/* ========== 底部操作栏 ========== */
.bottom-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}
.bottom-actions button { flex: 1; padding: 12px 10px; font-size: 13px; }

/* ========== 底部导航 ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: 480px;
  width: 100%;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 100;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  padding: 4px 16px;
  transition: color 0.2s;
}
.nav-item.active { color: var(--accent); }

/* ========== 卡片列表 ========== */
.card-list { display: flex; flex-direction: column; gap: 10px; }

.script-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid var(--accent);
}
.script-card:active { background: var(--bg-hover); }
.script-card h3 { font-size: 15px; margin-bottom: 4px; }
.script-card .meta { font-size: 12px; color: var(--text-secondary); }

.progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ff6b81);
  border-radius: 2px;
  transition: width 0.3s;
}

/* ========== 剧本详情 ========== */
.info-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.info-card .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}

.scene-group {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}
.scene-group h3 { font-size: 14px; margin-bottom: 8px; }

.shot-card {
  display: flex;
  align-items: center;
  padding: 10px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.shot-card:active { background: rgba(255,255,255,0.08); }

.shot-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 10px;
  flex-shrink: 0;
}
.shot-status.pending { background: var(--warning); }
.shot-status.done { background: var(--success); }

.shot-info { flex: 1; min-width: 0; }
.shot-info .name { font-size: 13px; font-weight: 600; }
.shot-info .desc { font-size: 11px; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.shot-duration { font-size: 11px; color: var(--text-secondary); margin-left: 8px; }

/* ========== 拍摄页 ========== */
#page-shooting .page { padding: 0; }

#camera-container {
  position: relative;
  width: 100%;
  height: 100vh;
  background: #000;
  overflow: hidden;
}

#camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.script-float {
  position: absolute;
  top: 60px;
  left: 12px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  border-radius: 10px;
  padding: 8px 12px;
  z-index: 30;
  max-width: 60%;
}
#script-float-main {
  display: flex;
  gap: 6px;
  align-items: center;
}
#float-shot-code { font-size: 14px; font-weight: 700; color: var(--accent); }
#float-shot-framing { font-size: 12px; color: var(--text-secondary); }
#script-float-detail { margin-top: 6px; font-size: 12px; line-height: 1.5; }

.btn-expand-float {
  position: absolute;
  top: 60px;
  right: 12px;
  width: 28px;
  height: 28px;
  background: rgba(0,0,0,0.4);
  border: none;
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  z-index: 30;
}

#shooting-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(0,0,0,0.6), transparent);
  z-index: 20;
}
.btn-icon-light {
  background: rgba(0,0,0,0.4);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.shot-counter-badge {
  background: rgba(0,0,0,0.4);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
}

.hint-top {
  position: absolute;
  top: 55px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.5);
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 11px;
  z-index: 20;
  white-space: nowrap;
}

/* ========== 取景框 ========== */
.framing-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}
.frame-shape {
  width: 100%;
  height: 100%;
  border: 2px solid rgba(255,255,255,0.3);
}
.frame-status {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 12px;
  background: rgba(0,0,0,0.4);
  padding: 4px 12px;
  border-radius: 16px;
}

/* ========== 录制 ========== */
.recording-timer {
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  z-index: 25;
  background: rgba(0,0,0,0.3);
  padding: 4px 14px;
  border-radius: 20px;
}

.record-btn {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 3px solid #fff;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.record-btn.recording { border-color: var(--accent); }
.record-btn:active { transform: translateX(-50%) scale(0.9); }

#shot-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(0,0,0,0.6), transparent);
  z-index: 20;
}
.btn-nav, .btn-mark {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-nav { background: rgba(255,255,255,0.15); color: #fff; }
.btn-mark { background: var(--accent); color: #fff; font-size: 20px; }
#shot-label { font-size: 13px; color: #fff; min-width: 80px; text-align: center; }

/* ========== 拍摄进度页 ========== */
.scene-progress {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.scene-progress h3 { font-size: 14px; margin-bottom: 8px; }
.shot-row {
  display: flex;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}
.shot-row .status-icon { margin-right: 8px; font-size: 11px; }
.shot-row .shot-name { flex: 1; }
.shot-row .shot-action { color: var(--text-secondary); font-size: 12px; }
.progress-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

/* ========== 设置 ========== */
.settings-content { padding: 16px; }
.setting-group {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.setting-group h3 { font-size: 14px; margin-bottom: 12px; }
.setting-group label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; margin-top: 8px; }
.setting-group label:first-of-type { margin-top: 0; }
.input-field {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.input-field:focus { border-color: var(--accent); }
.setting-group .btn-primary { margin-top: 12px; }

/* ========== 对话框 ========== */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
}
.dialog {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  background: var(--bg-surface);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
  z-index: 201;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateX(-50%) translateY(100%); }
  to { transform: translateX(-50%) translateY(0); }
}
.dialog h2 { font-size: 17px; margin-bottom: 16px; text-align: center; }
.dialog .form-group { margin-bottom: 12px; }
.dialog label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.dialog input, .dialog select, .dialog textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.dialog input:focus, .dialog select:focus, .dialog textarea:focus {
  border-color: var(--accent);
}
.dialog textarea { min-height: 70px; resize: vertical; }
.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.dialog-actions button { flex: 1; padding: 12px; font-size: 15px; }

/* ========== 辅助类 ========== */
.hidden { display: none !important; }
#toast { 
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 300;
  backdrop-filter: blur(4px);
  transition: opacity 0.3s;
  white-space: nowrap;
  max-width: 90%;
  pointer-events: none;
}
