/* ═══════════════════════════════════════════
   海狸浮生 / BeaverFlix 主题
   灵感: Timberborn 游戏 - 海狸、水坝、自然
   ═══════════════════════════════════════════ */

:root {
  --bg-primary: #1a120b;
  --bg-secondary: #2c1810;
  --bg-card: #3d2317;
  --bg-hover: #4d2f1f;
  --wood-light: #d4a057;
  --wood: #b8863c;
  --wood-dark: #8b6914;
  --water: #5dade2;
  --water-dark: #2e86c1;
  --leaf: #52be80;
  --leaf-dark: #2ecc71;
  --text: #e8d5b7;
  --text-dim: #9a7b5a;
  --text-muted: #6b5a44;
  --danger: #e74c3c;
  --border: #4d2f1f;
  --shadow: rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 50px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--wood-dark); }

/* ── Header ── */
header {
  background: linear-gradient(180deg, #2c1810 0%, #1a120b 100%);
  border-bottom: 2px solid var(--wood-dark);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
}
header .logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 18px; font-weight: 700;
  color: var(--wood-light); text-decoration: none;
}
header .logo .beaver { font-size: 22px; }
header .logo span { background: linear-gradient(90deg, var(--wood-light), var(--leaf)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
header nav { display: flex; gap: 2px; }
header nav a {
  padding: 6px 12px; color: var(--text-dim);
  text-decoration: none; font-size: 13px;
  border-radius: 20px; transition: all .2s;
  white-space: nowrap;
}
header nav a:hover { color: var(--wood-light); background: rgba(212,160,87,0.1); }
header nav a.active { color: var(--bg-primary); background: var(--wood-light); font-weight: 600; }

/* ── 通用 ── */
main { flex: 1; overflow: auto; }
.container { max-width: 1300px; margin: 0 auto; padding: 16px; }
@media (min-width: 768px) { .container { padding: 24px; } }

.btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px;
  cursor: pointer; transition: all .2s;
  background: var(--bg-card); color: var(--text);
  font-family: inherit; user-select: none;
}
.btn:hover { background: var(--bg-hover); border-color: var(--wood-dark); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--wood); border-color: var(--wood); color: var(--bg-primary); font-weight: 600; }
.btn-primary:hover { background: var(--wood-light); border-color: var(--wood-light); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

input, select, textarea {
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-secondary);
  color: var(--text); font-size: 14px; outline: none;
  font-family: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--wood); }
textarea { resize: vertical; min-height: 60px; }

/* ── 首页 Hero ── */
.hero {
  text-align: center; padding: 36px 16px 24px;
  position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(82,190,128,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.hero .logo-big { font-size: 48px; display: block; margin-bottom: 4px; }
@media (min-width: 768px) { .hero .logo-big { font-size: 56px; } }
.hero h2 {
  font-size: 26px;
  background: linear-gradient(135deg, var(--wood-light), var(--leaf));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}
@media (min-width: 768px) { .hero h2 { font-size: 32px; } }
.hero p { color: var(--text-dim); font-size: 13px; }
.hero .subtitle { color: var(--text-muted); font-size: 11px; margin-top: 4px; }

.beaver-float { display: inline-block; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ── 过滤栏 ── */
.filter-bar {
  display: flex; gap: 4px; margin-bottom: 16px;
  flex-wrap: wrap; align-items: center;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.filter-bar .filter-label { font-size: 12px; color: var(--text-muted); margin-right: 2px; white-space: nowrap; }
.filter-bar .filter-btn {
  padding: 4px 12px; border-radius: 16px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-dim); cursor: pointer;
  font-size: 12px; transition: all .2s;
  white-space: nowrap; flex-shrink: 0;
  font-family: inherit;
}
.filter-bar .filter-btn:hover { border-color: var(--wood-dark); color: var(--wood-light); }
.filter-bar .filter-btn.active { background: var(--wood); border-color: var(--wood); color: var(--bg-primary); font-weight: 600; }

/* ── 合集区块 ── */
.collection-section { margin-bottom: 28px; }
.collection-header {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.collection-header .col-name { font-size: 17px; font-weight: 700; color: var(--wood-light); }
.collection-header .col-count { font-size: 11px; color: var(--text-muted); }
.collection-header .col-desc { font-size: 11px; color: var(--text-dim); margin-left: auto; }

/* ── 视频网格 (响应式) ── */
.video-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 480px) { .video-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; } }
@media (min-width: 768px) { .video-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
@media (min-width: 1024px) { .video-grid { grid-template-columns: repeat(5, 1fr); gap: 16px; } }
@media (min-width: 1400px) { .video-grid { grid-template-columns: repeat(6, 1fr); gap: 18px; } }

.video-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden; cursor: pointer;
  transition: all .25s ease;
}
.video-card:hover { border-color: var(--wood); transform: translateY(-3px); box-shadow: 0 6px 20px var(--shadow); }
.video-card .thumb {
  width: 100%; aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--bg-secondary), #1e3a2e);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: var(--wood-dark);
  position: relative; overflow: hidden;
}
.video-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-card .thumb .thumb-fallback { font-size: 28px; }
.video-card .thumb .play-badge {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.35);
  opacity: 0; transition: opacity .25s;
  font-size: 36px;
}
.video-card:hover .thumb .play-badge, .video-card:active .thumb .play-badge { opacity: 1; }
.video-card .info { padding: 8px 10px 10px; }
.video-card .info .title {
  font-size: 12px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  line-height: 1.3; min-height: 2.6em;
}
.video-card .info .meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.video-card .info .meta .cat {
  background: rgba(82,190,128,0.15); color: var(--leaf);
  padding: 1px 7px; border-radius: 8px; font-size: 10px;
  display: inline-block;
}

/* ── 原生播放器 ── */
.player-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: #000;
  display: none; flex-direction: column;
}
.player-overlay.active { display: flex; }

.player-wrap {
  flex: 1; display: flex; flex-direction: column;
  max-width: 100%; margin: 0;
  position: relative;
}
@media (min-width: 768px) {
  .player-overlay {
    background: rgba(0,0,0,.92);
    align-items: center; justify-content: center;
    padding: 20px;
  }
  .player-wrap {
    width: 100%; max-width: 1100px;
    max-height: 90vh;
  }
}

.player-topbar {
  display: flex; align-items: center;
  padding: 8px 12px;
  background: rgba(0,0,0,.6);
  position: absolute; top: 0; left: 0; right: 0;
  z-index: 10;
}
@media (min-width: 768px) {
  .player-topbar {
    position: static;
    background: transparent;
    padding: 0 0 8px 0;
    margin-bottom: 0;
  }
  .player-close {
    position: static;
    color: var(--text-dim);
  }
}

.player-title {
  flex: 1; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
@media (min-width: 768px) {
  .player-title { font-size: 14px; }
}

.player-close {
  background: none; border: none;
  color: var(--text-dim); font-size: 20px;
  cursor: pointer; padding: 4px 8px;
  transition: color .2s;
  font-family: inherit;
}
.player-close:hover { color: var(--danger); }

.player-video-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  background: #000;
}
@media (min-width: 768px) {
  .player-video-wrap {
    border-radius: var(--radius);
  }
}

.player-video {
  width: 100%; height: 100%;
  object-fit: contain;
  max-height: 100vh;
}
@media (min-width: 768px) {
  .player-video { max-height: 80vh; }
}

/* 播放器内部状态 */
.player-error, .player-loading {
  position: absolute; inset: 0;
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; z-index: 5;
}
.player-error.active, .player-loading.active { display: flex; }
.player-error { background: rgba(0,0,0,.7); }
.player-error span:first-child { font-size: 32px; }
.player-error span:nth-child(2) { font-size: 13px; color: var(--text-dim); text-align: center; padding: 0 20px; }
.player-loading { background: rgba(0,0,0,.4); }
.player-loading span { font-size: 12px; color: var(--text-muted); }
.player-loading .spinner {
  width: 32px; height: 32px;
  border: 3px solid rgba(255,255,255,.1);
  border-top-color: var(--wood);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 空/加载状态 ── */
.empty-state { text-align: center; padding: 48px 16px; color: var(--text-muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 8px; }
.empty-state p { font-size: 13px; line-height: 1.6; }
.loading { text-align: center; padding: 48px; }
.loading .spinner {
  width: 32px; height: 32px; margin: 0 auto;
  border: 3px solid var(--border);
  border-top-color: var(--wood); border-radius: 50%;
  animation: spin .8s linear infinite;
}

.home-footer { text-align: center; padding: 20px; color: var(--text-muted); font-size: 11px; border-top: 1px solid var(--border); }

/* ═══════════════════════════════════════════
   管理后台 (响应式)
   ═══════════════════════════════════════════ */

.admin-layout {
  display: flex; flex-direction: column;
  height: calc(100vh - var(--header-h));
}
@media (min-width: 768px) {
  .admin-layout { flex-direction: row; }
}

/* 文件浏览器 (移动优先) */
.browser-panel {
  flex: 1; display: flex; flex-direction: column;
  min-height: 50vh;
}
@media (min-width: 768px) {
  .browser-panel { min-height: 0; }
}

.browser-toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.breadcrumb {
  display: flex; align-items: center; gap: 4px;
  flex: 1; min-width: 0; overflow: hidden;
  font-size: 12px;
}
.breadcrumb a { color: var(--text-dim); text-decoration: none; white-space: nowrap; }
.breadcrumb a:hover { color: var(--wood-light); }
.breadcrumb .sep { color: var(--text-muted); }
.breadcrumb .current { color: var(--text); white-space: nowrap; font-size: 12px; }

.browser-body { flex: 1; overflow-y: auto; padding: 8px; }

.file-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
@media (min-width: 480px) { .file-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; } }
@media (min-width: 768px) { .file-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; } }

.file-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 6px;
  cursor: pointer; transition: all .2s; text-align: center;
}
.file-card:hover { border-color: var(--wood); background: var(--bg-hover); }
.file-card .icon { font-size: 24px; margin-bottom: 2px; }
.file-card .name {
  font-size: 11px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.file-card .meta { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.file-card.video { border-color: rgba(93,173,226,0.3); }
.file-card.video:hover { border-color: var(--water); }
.file-card.image { border-color: rgba(82,190,128,0.3); }
.file-card.image:hover { border-color: var(--leaf); }
.file-card.active { border-color: var(--wood-light); box-shadow: 0 0 8px rgba(212,160,87,0.3); }

.pagination-bar {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 10px; background: var(--bg-secondary);
  border-top: 1px solid var(--border); font-size: 12px;
}
.pagination-bar .page-info { color: var(--text-dim); }

/* 侧边面板 (移动端放在底部, 桌面端在右侧) */
.side-panel {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column;
  max-height: 40vh;
}
@media (min-width: 768px) {
  .side-panel {
    width: 340px; border-top: none;
    border-left: 1px solid var(--border);
    max-height: none;
  }
}

.side-tabs {
  display: flex; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.side-tab {
  flex: 1; padding: 8px; text-align: center;
  font-size: 12px; color: var(--text-dim);
  cursor: pointer; border: none; background: transparent;
  transition: all .2s; border-bottom: 2px solid transparent;
  font-family: inherit;
}
.side-tab:hover { color: var(--wood-light); }
.side-tab.active { color: var(--wood-light); border-bottom-color: var(--wood); }

.side-body { flex: 1; overflow-y: auto; padding: 8px; }

/* 已选视频列表 */
.pick-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-radius: var(--radius-sm);
  transition: background .2s; font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.pick-item:hover { background: var(--bg-hover); }
.pick-item .pick-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-item .pick-cat {
  color: var(--leaf); font-size: 10px;
  background: rgba(82,190,128,0.1);
  padding: 1px 5px; border-radius: 6px;
}
.pick-item .pick-actions { display: flex; gap: 2px; flex-shrink: 0; }
.pick-item .pick-btn {
  background: none; border: none; cursor: pointer;
  font-size: 14px; padding: 2px 4px; border-radius: 4px;
  transition: background .2s; color: var(--text-muted); line-height: 1;
  font-family: inherit;
}
.pick-item .pick-btn:hover { background: rgba(255,255,255,0.1); }
.pick-item .pick-btn.edit:hover { color: var(--wood-light); }
.pick-item .pick-btn.del:hover { color: var(--danger); }
.pick-item .pick-btn.add:hover { color: var(--leaf); }

/* 合集卡片 */
.collection-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px;
  margin-bottom: 8px;
}
.collection-item .col-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px; flex-wrap: wrap;
}
.collection-item .col-header .col-name { flex: 1; font-size: 13px; font-weight: 600; }
.collection-item .col-header .col-count { font-size: 11px; color: var(--text-muted); }
.collection-item .col-header .col-actions { display: flex; gap: 4px; }
.collection-item .col-desc { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; }
.collection-item .col-video {
  font-size: 11px; color: var(--text-dim);
  padding: 3px 6px; background: var(--bg-secondary);
  border-radius: 4px;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 3px;
}
.collection-item .col-video .cv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collection-item .col-video .cv-remove { color: var(--danger); cursor: pointer; font-size: 12px; }

/* ── 弹窗 (响应式) ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.7);
  display: none; align-items: center; justify-content: center;
  padding: 10px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 {
  font-size: 16px; font-weight: 700;
  margin-bottom: 14px; color: var(--wood-light);
}
.modal .field { margin-bottom: 10px; }
.modal .field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 3px; }
.modal .actions {
  display: flex; gap: 8px;
  justify-content: flex-end; margin-top: 14px;
}

/* 封面选择 */
.poster-selector { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.poster-option {
  width: 70px; height: 44px;
  border-radius: 4px; overflow: hidden;
  cursor: pointer; border: 2px solid transparent;
  transition: all .2s; background: var(--bg-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.poster-option:hover { border-color: var(--text-dim); }
.poster-option.active { border-color: var(--wood); }
.poster-option img { width: 100%; height: 100%; object-fit: cover; }
.poster-preview { margin-top: 6px; width: 100%; max-width: 200px; aspect-ratio: 16/9; border-radius: 4px; overflow: hidden; background: var(--bg-primary); }
.poster-preview img { width: 100%; height: 100%; object-fit: cover; }

.title-prefix { color: var(--text-muted); font-size: 11px; }
