/* app.css — VOD 播放页全局样式（暗色调，移动端竖屏） */

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

:root {
  --bg: #0d0d0d;
  --surface: #1a1a1a;
  --surface2: #252525;
  --border: #333;
  --text: #f0f0f0;
  --text-muted: #888;
  --accent: #e5251e;
  --accent2: #ff7d00;
  --radius: 8px;
  --bar-h: 56px;
  --header-h: 48px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', sans-serif;
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* ── 布局骨架 ──────────────────────────────────────────────────────────────── */

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  position: relative;
}

/* 标题栏 */
#header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

#page-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* 视频区域 */
#player-list {
  flex-shrink: 0;
  background: #000;
}

.player-wrapper {
  position: relative;
  width: 100%;
  background: #000;
}

.player-video {
  width: 100%;
  display: block;
}

/* 弹幕叠加层 */
.danmaku-layer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 40px;
  overflow: hidden;
  pointer-events: none;
  z-index: 5;
}

.danmaku-item {
  position: absolute;
  right: -100%;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 500;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  animation: danmaku-slide 6s linear forwards;
}

@keyframes danmaku-slide {
  from { right: -100%; }
  to { right: 110%; }
}

/* 聊天区域 */
#chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: none;
}
#chat-area::-webkit-scrollbar { display: none; }

.chat-msg {
  line-height: 1.5;
  font-size: 13px;
  word-break: break-all;
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
  padding: 4px 8px;
}

.chat-nick {
  color: var(--accent2);
  font-weight: 500;
  margin-right: 2px;
}

.chat-text {
  color: var(--text);
}

/* ── 底栏 ────────────────────────────────────────────────────────────────── */

#bottom-bar {
  height: var(--bar-h);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 8px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

#chat-input {
  flex: 1;
  height: 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
#chat-input::placeholder { color: var(--text-muted); }
#chat-input:focus { border-color: #555; }

#chat-send {
  display: none; /* 按 Enter 发送，不显示按钮 */
}

.bar-icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 22px;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
  position: relative;
  flex-shrink: 0;
}
.bar-icon-btn:active { background: rgba(255,255,255,0.08); color: var(--text); }

#gift-btn { font-size: 20px; }
#cart-btn { font-size: 20px; }
#like-btn { font-size: 20px; color: #ff4757; }

.like-float {
  position: absolute;
  bottom: 0;
  font-size: 18px;
  animation: like-fly 1s ease-out forwards;
  pointer-events: none;
}
@keyframes like-fly {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-60px) scale(1.5); opacity: 0; }
}

/* ── 购物车面板 ──────────────────────────────────────────────────────────── */

#cart-panel {
  position: fixed;
  bottom: var(--bar-h);
  left: 0; right: 0;
  max-width: 640px;
  margin: 0 auto;
  max-height: 55vh;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  border-top: 1px solid var(--border);
  z-index: 50;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#cart-panel.visible { transform: translateY(0); }

#cart-header {
  padding: 14px 16px 10px;
  font-size: 15px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#cart-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

.cart-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.cart-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.cart-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface2);
  flex-shrink: 0;
}

.cart-info { flex: 1; min-width: 0; }
.cart-name { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-price { font-size: 15px; font-weight: 700; color: #ff4757; margin-top: 4px; }

.cart-buy-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── 登录遮罩 ────────────────────────────────────────────────────────────── */

#login-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
#login-mask.hidden { display: none; }

#login-panel {
  width: 100%;
  max-width: 640px;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 28px 24px 40px;
}

.login-title {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 12px;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-field {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.login-input {
  flex: 1;
  height: 44px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.login-input:focus { border-color: var(--accent); }

.login-code-btn {
  height: 44px;
  padding: 0 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.login-code-btn:disabled { color: var(--text-muted); cursor: not-allowed; }

.btn-primary {
  width: 100%;
  height: 48px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-wechat {
  width: 100%;
  height: 48px;
  background: #07C160;
  color: #fff;
  border: none;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ── 加载遮罩 ────────────────────────────────────────────────────────────── */

#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  flex-direction: column;
  gap: 16px;
}
#loading-overlay.hidden { display: none; }

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 14px;
  color: var(--text-muted);
}

/* ── Toast ───────────────────────────────────────────────────────────────── */

#toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(40,40,40,0.95);
  color: var(--text);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 300;
  white-space: nowrap;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── 竖屏/横屏自适应 ─────────────────────────────────────────────────────── */

@media (orientation: landscape) {
  #app { flex-direction: row; flex-wrap: wrap; }
  #header { width: 100%; }
  #player-list { width: 55%; flex-shrink: 0; }
  #chat-area, #bottom-bar { width: 45%; }
  #chat-area { height: calc(100dvh - var(--header-h) - var(--bar-h)); }
}

/* iOS safe area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #bottom-bar { padding-bottom: env(safe-area-inset-bottom); height: calc(var(--bar-h) + env(safe-area-inset-bottom)); }
}
