/* 基本排版 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
    "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: #e7edf8;
  color: #222;
  line-height: 1.6;
}

/* 共用容器寬度 */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* 頁首 */
.site-header {
  background: linear-gradient(120deg, #1e88e5, #42a5f5);
  color: #ffffff;
  padding: 1.6rem 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
}

.site-title {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 600;
}

.site-subtitle {
  margin: 0.6rem 0 0;
  font-size: 0.95rem;
  opacity: 0.9;
}

/* 頂部頁面遷移 */
.site-nav {
  background-color: #1b2a3a;
}

.site-nav-inner {
  display: flex;
  gap: 0.75rem;
  padding: 0.3rem 0;
}

.site-nav-link {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  color: #eceff1;
  text-decoration: none;
  border-radius: 999px;
}

.site-nav-link:hover {
  background-color: rgba(255, 255, 255, 0.12);
}

.site-nav-link.active {
  background-color: #ffffff;
  color: #1e88e5;
}

/* 主體 */
.main-content {
  padding: 1.8rem 0 2.5rem;
}

/* 左右欄配置 */
.layout-two-column {
  display: grid;
  grid-template-columns: minmax(0, 3.2fr) minmax(260px, 1fr);
  gap: 1rem;
  align-items: flex-start;
}

.layout-main {
  min-width: 0;
}

.layout-sidebar {
  min-width: 0;
}

/* 分頁標籤 */
.tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.main-tabs {
  margin-bottom: 1rem;
  padding: 0.2rem 0.4rem;
  background-color: #dbe4f6;
  border-radius: 999px;
}

.era-tabs {
  margin-top: 0.2rem;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}

/* 按鈕樣式 */
.tab-button {
  border: none;
  background-color: transparent;
  padding: 0.45rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: 999px;
  color: #455a64;
  transition: background-color 0.15s ease, color 0.15s ease,
    box-shadow 0.15s ease;
}

.tab-button.small {
  padding: 0.32rem 0.9rem;
  font-size: 0.85rem;
}

.main-tabs .tab-button.active {
  background-color: #ffffff;
  color: #1e88e5;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(21, 101, 192, 0.3);
}

.main-tabs .tab-button:hover:not(.active) {
  background-color: rgba(255, 255, 255, 0.6);
}

.era-tabs .tab-button.active {
  background-color: #ffffff;
  border: 1px solid #90caf9;
  color: #1565c0;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(21, 101, 192, 0.25);
}

.era-tabs .tab-button:hover:not(.active) {
  background-color: rgba(255, 255, 255, 0.7);
}

/* 分頁內容 */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* 卡片樣式 */
.card {
  background-color: #ffffff;
  border-radius: 14px;
  padding: 1.2rem 1.4rem 1.4rem;
  box-shadow: 0 3px 10px rgba(15, 32, 68, 0.16);
  border: 1px solid #c5d3f5;
}

.card-header {
  border-bottom: 1px solid #e0e6f5;
  padding-bottom: 0.5rem;
  margin-bottom: 0.6rem;
}

.card-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: #1a237e;
}

/* 搜尋群組：左右排列 */
.search-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.8rem;
  padding: 0.8rem 0.9rem;
  border-radius: 10px;
  background: linear-gradient(
    135deg,
    rgba(227, 242, 253, 0.95),
    rgba(232, 245, 233, 0.9)
  );
}

.search-block {
  flex: 1 1 260px;
  min-width: 0;
}

/* 標題 + 今年按鈕並排 */
.search-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.search-block-header h3 {
  margin: 0;
  font-size: 1rem;
  color: #1565c0;
}

/* 原本沒有 heading 包裹時的 h3（民國區塊） */
.search-block > h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  color: #1565c0;
}

/* 單一搜尋列 */
.search-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.search-row label {
  font-size: 0.85rem;
  color: #455a64;
  white-space: nowrap;
}

/* 下拉選單維持原大小 */
.search-row select {
  padding: 0.35rem 0.5rem;
  font-size: 0.95rem;
  border-radius: 6px;
  border: 1px solid #b0bec5;
  min-width: 80px;
  background-color: #ffffff;
}

/* 數字輸入框：較窄 */
.search-row input[type="number"] {
  padding: 0.35rem 0.4rem;
  font-size: 0.95rem;
  border-radius: 6px;
  border: 1px solid #b0bec5;
  width: 130px;
  min-width: 100px;
  background-color: #ffffff;
}

.search-row input[type="number"]:focus,
.search-row select:focus {
  border-color: #1e88e5;
  box-shadow: 0 0 0 2px rgba(30, 136, 229, 0.18);
  outline: none;
}

/* 日本曆 → 西元年 那一列允許換行（窄螢幕時會自動換） */
.search-row--era {
  flex-wrap: wrap;
}

/* 主要按鈕 */
.btn-primary {
  padding: 0.4rem 0.9rem;
  font-size: 0.95rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #1e88e5, #42a5f5);
  color: #ffffff;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(21, 101, 192, 0.4);
  transition: transform 0.08s ease, box-shadow 0.08s ease,
    background 0.12s ease;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1565c0, #1e88e5);
  box-shadow: 0 3px 8px rgba(21, 101, 192, 0.45);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(21, 101, 192, 0.35);
}

/* 小型「今年」按鈕（共用） */
.btn-ghost {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  border-radius: 999px;
  border: 1px solid #b0bec5;
  background-color: #ffffff;
  color: #455a64;
  cursor: pointer;
  white-space: nowrap;
}

.btn-ghost:hover {
  background-color: #eceff1;
}

/* 放在標題右側的「今年」 */
.btn-heading {
  padding-inline: 0.7rem;
}

/* 查找結果文字 */
.search-result {
  font-size: 0.9rem;
  color: #37474f;
  min-height: 1.2em;
}

/* 表格外容器 */
.table-wrapper {
  margin-top: 1rem;
  max-height: 520px;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid #c5d3f5;
  background-color: #ffffff;
}

/* 表格本身 */
table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

/* 固定表格標題（表頭，實心色） */
thead {
  background-color: #dde7ff;
}

thead th,
tbody td {
  box-sizing: border-box;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 0.45rem 0.6rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  color: #102a43;
  background-color: #dde7ff;
  border-bottom: 2px solid #90a4f9;
  white-space: nowrap;
}

/* 資料列 */
td {
  padding: 0.45rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid #e3e7f5;
}

/* 年齡欄：偏窄、置中 */
.table-wrapper table th:nth-child(3),
.table-wrapper table td:nth-child(3) {
  width: 70px;
  text-align: center;
  white-space: nowrap;
}

/* 斑馬線列 + 每十行插入分隔列 */
tbody tr:nth-child(even):not(.separator-row) {
  background-color: #f5f7ff;
}

.separator-row td {
  border-bottom: 1px solid #9fa8da;
  background: repeating-linear-gradient(
    -45deg,
    #e8eaf6,
    #e8eaf6 6px,
    #c5cae9 6px,
    #c5cae9 12px
  );
  font-size: 0.75rem;
  color: #303f9f;
}

/* 滑過、查找高亮 */
tbody tr.highlight {
  background-color: #fff3cd !important;
}

tbody tr:not(.separator-row):hover {
  background-color: #e3f2fd;
}

/* 頁首下方的廣告區塊 */
.ad-top-wrapper {
  margin-bottom: 1.2rem;
}

.ad-slot--top {
  min-height: 90px;
  background-color: #eceff1;
  border: 1px dashed #90a4ae;
  border-radius: 10px;
  padding: 0.75rem;
  text-align: center;
  font-size: 0.9rem;
  color: #546e7a;
}

/* 下方廣告區塊 */
.ad-wrapper {
  margin-top: 1.5rem;
}

.ad-slot {
  border-radius: 10px;
  border: 1px dashed #90a4ae;
  padding: 0.75rem;
  text-align: center;
  font-size: 0.85rem;
  color: #546e7a;
  background-color: #eceff1;
}

.ad-slot--bottom {
  min-height: 80px;
}

/* 右側廣告欄 */
.ad-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ad-slot--side {
  min-height: 120px;
}

/* 右側祝日卡片：橘色系閃爍 */
.holiday-mini-card {
  margin-bottom: 1.2rem;
}

.holiday-link {
  text-decoration: none;
  color: inherit;
}

.holiday-mini-box {
  padding: 0.8rem 1rem;
  border-radius: 10px;
  background-color: #fff3e0;
  border: 1px solid #ffb74d;
  cursor: pointer;
  animation: holiday-pulse 1.4s infinite;
}

.holiday-mini-box h3 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
  font-weight: 700;
  color: #e65100;
}

.holiday-mini-box p {
  margin: 0;
  font-size: 0.85rem;
  color: #ff6f00;
}

@keyframes holiday-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 167, 38, 0.7);
    transform: scale(1);
  }
  60% {
    box-shadow: 0 0 0 10px rgba(255, 167, 38, 0);
    transform: scale(1.02);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 167, 38, 0);
    transform: scale(1);
  }
}

/* 頁尾 */
.site-footer {
  border-top: 1px solid #cfd8dc;
  background-color: #f5f5f5;
  padding: 0.9rem 0;
  font-size: 0.85rem;
  color: #607d8b;
  text-align: center;
}

/* RWD 微調 */
@media (max-width: 900px) {
  .layout-two-column {
    grid-template-columns: minmax(0, 1fr);
  }

  .layout-sidebar {
    order: -1;
  }

  .site-nav-inner {
    justify-content: center;
    flex-wrap: wrap;
  }
}

@media (max-width: 700px) {
  .search-group {
    flex-direction: column;
  }

  .tab-button {
    font-size: 0.9rem;
    padding: 0.4rem 0.7rem;
  }
}

#holiday-tbody td,
.table-wrapper table th {
  white-space: nowrap;     
  overflow: hidden;        
  text-overflow: ellipsis; 
}

/* 三欄比例布局 */
.table-wrapper table th:nth-child(1),
.table-wrapper table td:nth-child(1) {
  width: 30%;              /* 日付欄 */
}

.table-wrapper table th:nth-child(2),
.table-wrapper table td:nth-child(2) {
  width: 30%;              /* 曜日欄 */
  text-align: center;
}

.table-wrapper table th:nth-child(3),
.table-wrapper table td:nth-child(3) {
  width: 40%;              /* 祝日名欄，較長 */
}