/* 英雄列表專屬樣式 - 升級為玻璃擬態風格 */

:root {
  --nav-height: 70px; /* 預設值，會由 JS 動態修正 */
}

/* 搜尋區塊與篩選器 */
#searchContainer {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  padding: 15px 20px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  margin-bottom: 20px;
}

/* 搜尋區塊與篩選器 */
#note {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  padding: 15px 20px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  margin-bottom: 20px;
}

.quick-search-label {
  font-weight: 600;
  color: var(--primary-blue);
  font-size: 16px;
}

#searchInput {
  padding: 10px 16px;
  flex: 1;
  max-width: 300px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 14px;
  transition: all 0.3s ease;
}

#searchInput:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 10px rgba(77, 163, 255, 0.3);
  background: var(--glass-bg);
}

/* 摺疊篩選區 */
.accordion {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  margin-bottom: 30px;
  overflow: hidden;
}

.accordion-header {
  padding: 15px 20px;
  color: var(--primary-blue);
  font-weight: bold;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.3s;
}

.accordion-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* 🚀 修正：摺疊狀態的 CSS */
.accordion.collapsed .accordion-content {
  display: none;
}

.accordion.collapsed {
  margin-bottom: 20px;
}

.accordion-header::after {
  content: "▾";
  transition: transform 0.3s ease;
}

.accordion.collapsed .accordion-header::after {
  transform: rotate(-90deg);
}

.accordion-content {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px; /* 使用 gap 替代 <br>，排版更緊湊 */
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.filter-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
}

.filter-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

.filter-label {
  font-weight: bold;
  color: var(--text-muted);
  min-width: 60px;
  padding-top: 6px; /* 對齊按鈕高度 */
}

.filter-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  background: rgba(77, 163, 255, 0.15);
  border-color: var(--primary-blue);
}

.filter-btn.active {
  background: linear-gradient(135deg, var(--primary-blue), var(--primary-dark));
  border-color: var(--primary-blue);
  box-shadow: 0 4px 12px rgba(77, 163, 255, 0.3);
  color: #ffffff !important; /* 強制白色文字，因為背景固定為藍色漸層 */
}

.clear-btn {
  background: var(--tag-clear-bg);
  border: 1px solid var(--tag-clear-border);
  color: var(--highlight-yellow);
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.clear-btn:hover {
  background: var(--highlight-yellow);
  color: #000;
}

/* 篩選操作區 */
.filter-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* 次要按鈕 (如切換模式) */
.secondary-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.secondary-btn:hover {
  background: var(--primary-blue);
  border-color: var(--primary-blue);
  color: white !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(77, 163, 255, 0.2);
}

.switch-mode-btn {
  margin-left: auto;
}

@media (max-width: 768px) {
  .switch-mode-btn {
    margin-left: 0;
    width: 100%;
  }
  .filter-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

/* 搜尋字詞高亮 */
.highlight {
  background-color: rgba(255, 216, 107, 0.3); /* 半透明黃色底 */
  color: var(--highlight-yellow);
  font-weight: bold;
  border-radius: 4px;
  padding: 2px 4px;
  text-shadow: 0 0 8px rgba(255, 216, 107, 0.4);
}

/* 表格樣式 */
#hero-table-container {
  width: 100%;
  background: transparent;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  overflow: visible; /* 關鍵：確保標題能浮出容器固定 */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

table {
  border-collapse: separate; /* 配合圓角 */
  border-spacing: 0;
  width: 100%;
  table-layout: fixed; /* 🚀 效能關鍵：固定佈局讓瀏覽器渲染更快 */
}

/* 精確設定欄位寬度，避免瀏覽器重新計算 */
thead th:nth-child(1) { width: 75px; }  /* 英雄名稱 */
thead th:nth-child(2) { width: 90px; }  /* 對應光輝 */
thead th:nth-child(3) { width: 60px; }  /* 拜官 */
thead th:nth-child(4) { width: 60px; }  /* 初始 */
thead th:nth-child(5) { width: 60px; }  /* 素質 */
thead th:nth-child(6) { width: 65px; }  /* 個性 */
thead th:nth-child(7) { width: 50px; }  /* 屬性 */
thead th:nth-child(8),
thead th:nth-child(9),
thead th:nth-child(10),
thead th:nth-child(11),
thead th:nth-child(12) { width: 45px; } /* 五圍 (各 45px) */
thead th:nth-child(13) { width: 75px; }  /* 積極度 */
thead th:nth-child(14) { width: 14%; } /* 新專 */
thead th:nth-child(15) { width: 14%; } /* 舊專 */

thead th {
  position: sticky;
  top: 73px; /* 與導覽列底部對齊，預留呼吸空間 */
  z-index: 100;
  background: linear-gradient(180deg, var(--nav-bg-1), var(--nav-bg-2));
  backdrop-filter: blur(15px);
  color: var(--primary-blue);
  padding: 12px 6px;
  font-size: 13px;
  font-weight: 700;
  border-bottom: 1px solid rgba(77, 163, 255, 0.3);
  word-wrap: break-word;
}

/* 確保表格圓角 */
#hero-table-container table tr:first-child th:first-child { border-top-left-radius: 20px; }
#hero-table-container table tr:first-child th:last-child { border-top-right-radius: 20px; }

tbody td {
  padding: 12px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border-separator);
  font-size: 12.5px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03); /* 移除毛玻璃，改用微透明背景 */
}

tbody tr {
  transition: background 0.2s;
  cursor: pointer;
}

tbody tr:hover {
  background: rgba(77, 163, 255, 0.1) !important; /* 使用淡藍色高亮取代白色高亮 */
}

tbody tr:hover td {
  color: var(--text-main);
}

/* 排序箭頭美化 */
.sort-caret-container {
  display: inline-flex;
  flex-direction: column;
  margin-left: 5px;
  vertical-align: middle;
  line-height: 0.7;
}

.sort-caret-container span {
  color: var(--text-muted);
  font-size: 9px;
  transition: all 0.2s ease;
  opacity: 0.3;
}

th.sort-asc .caret-up,
th.sort-desc .caret-down {
  color: var(--primary-blue) !important;
  text-shadow: 0 0 8px rgba(77, 163, 255, 0.6);
  transform: scale(1.1);
  opacity: 1;
}

/* Modal 彈出視窗 */
#modalOverlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  z-index: 2000;
}

#modalBox {
  display: none;
  position: fixed;
  top: 55%; /* 稍微下移，避免與頂部導覽列過近 */
  left: 50%;
  transform: translate(-50%, -50%);
  width: 88vw;
  max-width: 620px; /* 寬度縮小 */
  max-height: 72vh; /* 高度縮小，確保不被 nav 擋到 */
  overflow-y: auto;
  z-index: 2001;
  background: linear-gradient(135deg, var(--nav-bg-1), var(--nav-bg-2));
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
  color: var(--text-main);
  padding: 30px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-blue) transparent;
}

/* 圖片容器置中 */
.hero-images {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 25px;
  width: 100%;
}

.hero-images img {
  max-width: 100%; /* 圖片顯示 100% */
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease;
}

.hero-images img:hover {
  transform: scale(1.02);
}

.hero-details-container {
  display: flex;
  justify-content: space-between; /* 左右分散 */
  flex-wrap: wrap;
  gap: 15px;
  padding: 5px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.hero-column-base {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 18px;
  border-radius: 16px;
  box-sizing: border-box;
}

.hero-column {
  flex: 0 0 calc(50% - 10px); /* 左右兩邊 */
}

.hero-column-details,
.hero-playerdata {
  flex: 0 0 100%; /* 底部掉落與資訊維持滿版 */
  margin-top: 5px;
}

.hero-column-base p {
  margin: 8px 0;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-muted);
}

.hero-column-base p strong {
  color: var(--primary-blue);
  margin-right: 8px;
}

#modalBox .close-btn {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 32px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
  z-index: 2002;
}

#modalBox .close-btn:hover {
  color: var(--primary-blue);
  transform: rotate(90deg);
}

[data-theme="light"] #modalBox {
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.18);
}

[data-theme="light"] .hero-images img {
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

/* 手機版卡片 (預設桌面版隱藏) */
#hero-card-container, #awakening-container {
  display: none;
  flex-direction: column;
  gap: 15px;
  margin-top: 20px;
}

/* 手機版簡化卡片 (效能優化版) */
.hero-summary-card {
  background: rgba(255, 255, 255, 0.05); /* 移除毛玻璃 */
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 手機版通用卡片 (覺醒技能使用) */
.card-item {
  background: rgba(255, 255, 255, 0.05); /* 移除毛玻璃 */
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.card-item h3 {
  color: var(--primary-blue);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 5px;
  padding-bottom: 10px;
  text-align: center;
  font-size: 1.3rem;
  margin-top: 0;
}

.card-item p {
  margin: 5px 0;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.card-item strong {
  color: var(--primary-blue);
}

.hero-summary-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary-blue);
  transform: translateY(-2px);
}

.hero-summary-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

.hero-summary-card .hero-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary-blue);
  margin: 0;
}

.hero-summary-card .hero-promotion {
  font-size: 0.9rem;
  background: rgba(77, 163, 255, 0.15);
  color: var(--primary-blue);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(77, 163, 255, 0.3);
}

.hero-summary-card .card-body {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

.hero-summary-card .card-body p {
  margin: 4px 0;
}

.hero-summary-card .card-body strong {
  color: var(--primary-blue);
}

.hero-summary-card .card-footer {
  text-align: right;
  font-size: 12px;
  color: var(--primary-blue);
  opacity: 0.8;
  margin-top: 5px;
}

/* 其他修正 */
.hero-images img {
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.page-bottom-spacer {
  height: 100px;
}
/* 英雄/裝備連結樣式 (複用 map.js 風格) */
.hero-link {
  color: var(--primary-blue);
  text-decoration: none;
  border-bottom: 1px dashed var(--primary-blue);
  transition: all 0.2s ease;
  display: inline-block;
  cursor: pointer;
}

.hero-link:hover {
  color: var(--highlight-yellow);
  border-bottom: 1px solid var(--highlight-yellow);
  transform: translateY(-1px);
}
/* 🚀 專屬安全牌：只在容器內含垃圾表格時才修正圓角，絕對不影響其他頁面 */

/* 1. 表格節點分離配置 */
#hero-table-container:has(#garbageTable) #garbageTable {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

/* 2. 左上角與右上角（Th 的邊緣） */
#hero-table-container:has(#garbageTable) #garbageTable thead tr:first-child th:first-child {
  border-top-left-radius: 20px;
}
#hero-table-container:has(#garbageTable) #garbageTable thead tr:first-child th:last-child {
  border-top-right-radius: 20px;
}

/* 3. 左下角與右下角（最後一列 Td 的邊緣） */
#hero-table-container:has(#garbageTable) #garbageTable tbody tr:last-child td:first-child {
  border-bottom-left-radius: 20px;
}
#hero-table-container:has(#garbageTable) #garbageTable tbody tr:last-child td:last-child {
  border-bottom-right-radius: 20px;
}

/* 4. 順手加上垃圾圖片本身的圓角與微外框 */
#garbageTable td img {
  border-radius: 6px !important;
  border: 1px solid #ddd;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: inline-block;
  vertical-align: middle;
}

/* === 手機版響應式修正 === */
@media (max-width: 768px) {
  #heroes-table, #hero-table-container {
    display: none !important;
  }

  #searchContainer {
    flex-direction: column;
    align-items: stretch;
  }

  #searchInput {
    max-width: none;
  }

  #modalBox {
    width: 95vw;
    padding: 20px 15px;
    top: 50%;
    max-height: 80vh;
  }

  .hero-name {
    font-size: 22px;
  }

  .hero-images img {
    max-width: 140px;
  }

  .hero-column {
    flex: 1 1 100%;
  }

  /* 確保手機版卡片容器正確顯示 */
  #hero-card-container, #awakening-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  /* 針對 JS 渲染的卡片進行樣式加強 */
  #hero-card-container .accordion {
    margin-bottom: 10px;
  }
}
