/* ===== 深色主题变量 ===== */
:root {
  --bg-color: #14141f;
  --card-bg: #1e1e2d;
  --text-color: #e0e0ff;
  --link-color: #7a6ae6;
  --accent-color: #8a7cf0;
  --hover-color: #9a8dff;
  --border-color: #33334d;
  --header-bg: #1a1a28;
  --badge-bg: rgba(0, 0, 0, 0.6);
}

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

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
}
a {
  color: var(--link-color);
  text-decoration: none;
  transition: color 0.2s;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

@media (max-width: 1024px) {
  .container {
    max-width: 960px;
    padding: 0 16px;
  }
}
@media (max-width: 768px) {
  .container {
    padding: 0 12px;
  }
}

/* ==========================================================================
   ✅ 响应式头部导航（修复移动端布局）
   ========================================================================== */

.site-header {
  background: var(--header-bg);
  color: white;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  gap: 1rem;
}

/* === Logo === */
.site-logo {
  font-size: 1.5rem;
  font-weight: bold;
  color: white;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

/* === 主导航（PC 显示）=== */
.main-nav ul {
  display: flex;
  list-style: none;
  gap: 1rem;
  margin: 0;
  padding: 0;
}

.main-nav a {
  color: #c0c0e0;
  text-decoration: none;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s;
}

.main-nav a:hover,
.main-nav a.active {
  background: var(--accent-color);
  color: white;
}

/* === 右侧功能区（搜索 + 刷新 + 菜单按钮）=== */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.1rem; /* 减小图标之间的间距 */
  flex-shrink: 0;
}


/* 移动端头部布局 */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background: #1a1a1a;
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header .logo {
  font-size: 18px;
  font-weight: bold;
}

.header .search-box {
  flex: 1;
  max-width: 200px;
  margin: 0 10px;
  position: relative;
}

.header .search-box input {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  background: #fff;
  color: #333;
  font-size: 14px;
}

.header .search-box button {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 36px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header .menu-toggle {
  width: 36px;
  height: 36px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}



/* === 搜索框（现代化）=== */
/* 1. 限制搜索框最大宽度 + 居中 */

.search-box {
  position: relative;     /* 提供定位上下文 */
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
}

#search-results {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%; /* 继承 .search-box 宽度 */
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
  z-index: 9999;
  max-height: 300px;
  overflow-y: auto;
  display: none;
  margin-top: 4px;
  font-size: 14px;
}

.search-item {
  display: block;
  padding: 12px 16px;
  text-decoration: none;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease;
}

.search-item:hover {
  background-color: #f8f9fa;
  color: #007bff;
}

.search-item:last-child {
  border-bottom: none;
}
@media (max-width: 768px) {
  #search-results {
    width: 100%;
    max-width: none;
    margin: 0;
  }
}
/* 2. 让 input 和 button 并排 */
.search-form {
  display: flex;
  gap: 4px; /* 按钮和输入框间距 */
}

.search-form input {
  flex: 1; /* 占据剩余空间 */
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px 0 0 4px;
  font-size: 14px;
  min-width: 0; /* 防止 flex 子项溢出 */
}

.search-form button {
  background: #f44336;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  font-size: 14px;
}

/* 4. 响应式：移动端全宽 */
@media (max-width: 768px) {
  .search-box {
    max-width: none;
    margin: 0;
  }
}


#search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px 0 0 4px;
  font-size: 14px;
  outline: none;
}


/* === 刷新图标 === */
.refresh-btn {
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0.5rem;
  border-radius: 50%;
  transition: transform 0.2s;
}
.refresh-btn:hover {
  transform: scale(1.1);
}

/* === 菜单按钮（三道杠）=== */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: white;
  font-size: 1.4rem;
  flex-shrink: 0;
}


/* ==============================
   移动端 & 平板（<= 1024px）
   ============================== */
@media (max-width: 1024px) {
  /* 隐藏桌面导航 */
  .main-nav {
    display: none !important;
  }

  /* 显示菜单按钮 */
  .menu-toggle {
    display: flex;
  }

  /* 搜索框缩小 */
  .search-form {
    max-width: 200px;
    min-width: 150px;
  }

  /* 刷新图标保持可见 */
  .refresh-btn {
    display: inline-flex;
  }
}

@media (max-width: 480px) {
  .search-form {
    max-width: 180px;
    min-width: 130px;
  }
  .site-logo {
    font-size: 1.2rem;
  }
}

/* === 移动端菜单弹出样式 === */
@media (max-width: 1024px) {
  .main-nav.active {
    position: absolute;
    top: calc(100% + 8px);
    left: 15rem;
    right: 1rem;
    background: var(--header-bg);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: block !important;
  }
  .main-nav.active ul {
    flex-direction: column;
    gap: 1rem;
  }
  .main-nav.active a {
    display: block;
    padding: 0.8rem;
    border-radius: 6px;
    text-align: center;
  }
}

/* ==========================================================================
   其他样式（保留不变）
   ========================================================================== */

.hero-slider {
  margin: 24px 0 32px;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  height: 200px;
  background: #1a1a2a;
}

.slider-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.slider-poster.active {
  display: block;
}

.slider-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
  padding: 24px;
  color: white;
}

.slider-content h2 {
  font-size: 28px;
  margin-bottom: 8px;
  font-weight: 700;
}

.drama-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 14px 0;
}

@media (max-width: 1024px) {
  .drama-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .drama-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

.drama-card {
  background: var(--card-bg);
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.25s, box-shadow 0.25s;
  border: 1px solid var(--border-color);
  position: relative;
}

.drama-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

.poster {
  aspect-ratio: 3 / 4;
  background: #252535;
  position: relative;
}

.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.poster img.loaded {
  display: block;
}

.poster-year {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: var(--badge-bg);
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
}

.poster-status {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--accent-color);
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
}

.poster-status.completed {
  background: #4caf50;
}

.drama-info {
  padding: 12px;
}

.drama-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drama-meta {
  font-size: 13px;
  color: #aaa;
  display: flex;
  justify-content: space-between;
}

.drama-detail {
  display: flex;
  gap: 32px;
  margin: 32px 0;
}

@media (max-width: 768px) {
  .drama-detail { flex-direction: column; }
}

.poster-large {
  flex: 0 0 300px;
  aspect-ratio: 3 / 4;
  background: #252535;
  position: relative;
}

.poster-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.poster-large img.loaded {
  display: block;
}

.info h1 {
  font-size: 28px;
  margin-bottom: 16px;
  font-weight: 700;
}

.tags {
  margin: 16px 0;
}

.tag {
  display: inline-block;
  background: var(--accent-color);
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 14px;
  margin-right: 8px;
  margin-bottom: 8px;
}

.intro h3 {
  margin: 24px 0 12px;
  font-size: 20px;
  font-weight: 600;
}

.player iframe {
  width: 100%;
  height: 500px;
  background: black;
}

@media (max-width: 768px) {
  .player iframe {
    height: 220px;
  }
}

.site-footer {
  margin-top: 60px;
  padding: 20px 0;
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: #999;
  font-size: 14px;
}

/* ==============================
   移动端 & 平板（<= 1024px）
   ============================== */
@media (max-width: 1024px) {
  /* 隐藏桌面导航 */
  .main-nav {
    display: none !important;
  }

  /* 显示菜单按钮 */
  .menu-toggle {
    display: flex;
  }

  /* 启用移动端菜单 */
  .mobile-menu,
  .menu-overlay {
    display: none; /* 默认隐藏 */
  }

  .mobile-menu.active,
  .menu-overlay.active {
    display: block; /* 激活状态下显示 */
  }

  .mobile-menu {
    position: fixed;
    top: 0;
    left: -100%;
    width: min(280px, 50vw);
    max-width: 280px; /* 强制最大宽度 */
    height: 100vh;
    background: #1e1e1e; /* 深灰黑 */
    color: #ffffff; /* 白色文字 */
    border-right: 1px solid #333;
    z-index: 10000;
    transition: left 0.3s ease;
    padding-top: 60px;
    overflow-y: auto;
  }

  .mobile-menu.active {
    left: 0;
  }

  .mobile-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .mobile-menu li {
    padding: 0;
    margin: 0;
  }

  .mobile-menu a {
    display: block;
    padding: 1rem 1.2rem;
    color: #ffffff; /* 白色文字 */
    text-decoration: none;
    border-bottom: 1px solid #333;
    font-size: 16px;
  }

  .mobile-menu a i {
    margin-right: 0.5rem;
  }

  .mobile-menu a:hover {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
  }

  /* 遮罩层 */
  .menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  .menu-overlay.active {
    opacity: 1;
    visibility: visible;
  }
}

/* ==============================
   PC端（> 1024px）
   ============================== */
@media (min-width: 1025px) {
  /* 隐藏移动端菜单 */
  .mobile-menu {
    display: none !important;
  }

  /* 显示桌面导航 */
  .main-nav {
    display: block !important;
  }

  /* 隐藏菜单按钮 */
  .menu-toggle {
    display: none;
  }
}

/* ===== 首页栏目标题样式（全局生效，不限于移动端）===== */
.section-title {
  font-size: 1.4rem;
  margin: 1.6rem 0 1rem;
  padding: 0.5rem 1rem;
  background: rgba(231, 76, 60, 0.08); /* 浅红底 */
  border-left: 4px solid #e74c3c;        /* 红色左框 */
  color: var(--text-color);
  display: block;
  border-radius: 0 6px 6px 0;
}

/* 在你的 CSS 文件中（如 static/css/style.css） */
.site-footer {
  margin-top: 2rem;
  padding: 1rem 0;
  text-align: center;
  color: #666;
  font-size: 0.9rem;
}


.main-nav a.active,
.mobile-menu a.active {
  color: #e0e0ff;
  font-weight: bold;
}


/* 搜索结果容器 */
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e1e5e9;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
  display: none;
}

/* 搜索结果列表 */
.search-results ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* 每一项 */
.search-results li {
  padding: 10px 16px;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease;
}

.search-results li:hover {
  background-color: #f8f9fa;
  cursor: pointer;
}

/* 链接样式 */
.search-results a {
  text-decoration: none;
  color: #333;
  font-size: 14px;
  line-height: 1.4;
  display: block;
}

/* 关键词高亮 */
.search-results mark {
  background-color: #fff3cd;
  color: #856404;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 500;
}

/* 无结果提示 */
.search-results .no-result {
  padding: 16px;
  color: #666;
  text-align: center;
  font-size: 14px;
}


/* 观影记录下拉面板 */
.history-panel {
  position: absolute;
  top: 100%;
  
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
  z-index: 9998;
  min-width: 220px;
  max-height: 300px;
  overflow-y: auto;
  display: none;
  font-size: 14px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  text-decoration: none;
  color: #333;
  border-bottom: 1px solid #f5f5f5;
}

.history-item:hover {
  background-color: #f8f9fa;
  color: #007bff;
}

.history-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.history-date {
  font-size: 12px;
  color: #888;
  flex-shrink: 0;
}

#clear-history {
  background: #ff4d4d;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
@media (max-width: 768px) {
  .history-title { max-width: 150px; }
  .history-item { padding: 10px 12px; }
}

.friend-links {
  margin: 0rem 0;
  padding: 0.1rem;
  text-align: center;
  font-size: 0.85rem;
}

.friend-links h3 {
  margin-bottom: 0.8rem;
  font-size: 1.2rem;
  color: #8a7cf0;
}

.friend-links ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

.friend-links li {
  margin: 0;
}

.friend-links a {
  color: #8a7cf0;
  text-decoration: none;
  border-bottom: 1px dashed #999;
  transition: color 0.2s ease;
}

.friend-links a:hover {
  color: #007acc;
  border-bottom-style: solid;
}