/* 全局基础样式 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}

/* 主页：统计栏 — 顶部安全区适配刘海/灵动岛 */
.stats-bar {
  display: flex;
  justify-content: space-around;
  padding: 16px 16px 20px;
  padding-top: max(20px, calc(env(safe-area-inset-top) + 16px));
  background: #111;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  color: #888;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
}

/* 主页：卡片网格 — 底部留够空间避免被 FAB 遮挡 */
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
  padding-bottom: max(96px, calc(env(safe-area-inset-bottom) + 88px));
}

/* 空状态 */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 16px;
  color: #666;
  line-height: 2;
}

/* 悬浮添加按钮 — 底部/右侧安全区，防止被 home 横条遮挡 */
.fab {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 20px));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fff;
  color: #000;
  font-size: 28px;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
  touch-action: manipulation;
  transition: opacity 0.12s, transform 0.12s;
}

.fab:active {
  opacity: 0.75;
  transform: scale(0.93);
}

/* 添加页：顶部导航 — 顶部安全区 + sticky 保证返回键常驻 */
.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  padding-top: max(16px, calc(env(safe-area-inset-top) + 12px));
  background: #111;
  position: sticky;
  top: 0;
  z-index: 10;
}

/* 返回按钮 — 保证 44px 最小触摸面积（Apple HIG 标准） */
.back-btn {
  color: #fff;
  text-decoration: none;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-right: 12px;
  touch-action: manipulation;
}

.page-header h1 {
  font-size: 18px;
  font-weight: 600;
}

/* 添加页：表单区 — 底部安全区避免保存按钮被遮挡 */
.add-form {
  padding: 12px 16px;
  padding-bottom: max(20px, calc(env(safe-area-inset-bottom) + 16px));
}

/* 海报上传区 — v0.3 压缩到 140px，横向铺满 */
.poster-upload {
  width: 100%;
  height: 140px;
  background: #1a1a1a;
  border: 2px dashed #333;
  border-radius: 12px;
  margin-bottom: 12px;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.poster-placeholder {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.poster-icon {
  font-size: 22px;
}

.poster-hint {
  font-size: 13px;
  color: #555;
}

.poster-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 识别按钮 — 海报下方副 CTA */
.scan-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 44px;
  margin-bottom: 8px;
  background: #1a1a1a;
  color: #fff;
  border: 1px solid #fff;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.15s;
}

.scan-btn:active {
  opacity: 0.75;
}

.scan-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.scan-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 14px;
  line-height: 1;
}

/* 识别中：转圈 loading */
.scan-icon.loading {
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  font-size: 0;
  animation: scan-spin 0.8s linear infinite;
}

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

/* Toast — 顶部居中，2 秒后消失 */
.toast {
  position: fixed;
  top: max(24px, calc(env(safe-area-inset-top) + 16px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(40, 40, 40, 0.95);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  max-width: calc(100% - 32px);
  text-align: center;
}

/* 表单字段组 */
.form-fields {
  display: flex;
  flex-direction: column;
}

.field-group {
  padding: 10px 0;
  border-bottom: 1px solid #1e1e1e;
}

.field-label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

/* font-size: 16px 防止 iOS Safari 在聚焦输入框时自动放大 */
.field-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 16px;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.field-input::placeholder {
  color: #3a3a3a;
}

/* iOS 上 datetime-local 的日历图标反色 */
.field-input::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: 0.4;
  cursor: pointer;
}

/* 保存按钮 */
.save-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  background: #fff;
  color: #000;
  border: none;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.15s;
}

.save-btn:disabled {
  background: #1e1e1e;
  color: #444;
  cursor: not-allowed;
}

.save-btn:not(:disabled):active {
  opacity: 0.8;
}

/* 主页：电影卡片 */
.movie-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-y;
}

/* 卡片内所有子元素禁止系统长按菜单 */
.movie-card * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.card-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
  -webkit-user-drag: none;
  pointer-events: none;
}

.card-info {
  padding: 8px 8px 10px;
  color: #000;
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  font-size: 11px;
  color: #555;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.card-divider {
  height: 1px;
  background: #e8e8e8;
  margin-bottom: 6px;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.card-date {
  font-size: 10px;
  color: #888;
}

.card-price {
  font-size: 12px;
  font-weight: 700;
  color: #000;
}

/* 空状态图标 */
.empty-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

/* 编辑模式：卡片抖动 */
@keyframes wobble {
  0%   { transform: rotate(-1deg) translate(-0.5px,  0.5px); }
  50%  { transform: rotate( 1deg) translate( 0.5px, -0.5px); }
  100% { transform: rotate(-1deg) translate(-0.5px,  0.5px); }
}

.movie-card.editing {
  animation: wobble 0.25s ease-in-out infinite;
}

/* 删除按钮：44×44 透明热区 + ::after 画 30px 红圆，完全在卡片内部 */
.delete-btn {
  position: absolute;
  top: 0;
  left: 0;
  width: 44px;
  height: 44px;
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  z-index: 10;
  touch-action: manipulation;
}

.delete-btn::after {
  content: '−';
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #FF3B30;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

.movie-card.editing .delete-btn {
  display: flex;
}

/* 删除确认弹窗：iOS 底部弹出样式 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  background: #fff;
  border-radius: 14px;
  width: calc(100% - 24px);
  margin: 0 12px max(12px, env(safe-area-inset-bottom));
  overflow: hidden;
}

.modal-sep {
  height: 1px;
  background: #e0e0e0;
}

.modal-btn {
  display: block;
  width: 100%;
  padding: 16px;
  background: transparent;
  border: none;
  font-size: 17px;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.modal-btn-delete {
  color: #FF3B30;
}

.modal-btn-cancel {
  color: #000;
}
