/* ========== 原始全域變數與基礎樣式 ========== */
:root {
  --primary-color: #243d51;
  --highlight-color: #f8ef32;
  --main-font-color: #23396c;
  --secondary-font-color: #999999;
  --white-color: #ffffff;
  --primary-color-dark: #1a2d60;
  --main-font-color-rgb: 35, 57, 108;
  --secondary-blue-accent: #3a5a9a;
  --background-color-light: #fafafa;
  --general-border-color: #dddddd;
  --light-grey-bg: #f9f9f9;
  --modal-pre-bg: #f5f5f5;
  --error-red: #d32f2f;
  --warning-background: #f8d7da;
  --warning-text: #721c24;
  --disabled-button-bg: #6c757d;
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --hover-shadow: 0 8px 20px rgba(var(--main-font-color-rgb), 0.3);
}

::selection {
  color: var(--highlight-color);
  background: var(--primary-color);
}

* {
  font-family: "Noto Sans HK", sans-serif;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  color: var(--main-font-color);
  background-color: var(--background-color-light);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a:link, a:visited, a:hover, a:active {
  color: var(--main-font-color);
  text-decoration: none;
}

a:hover, a:active {
  text-decoration: underline;
}

/* ========== Header 樣式 ========== */
header {
  width: 100%;
  background-color: var(--primary-color);
  color: var(--white-color);
  height: 74px;
  position: relative;
  z-index: 10;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 100%;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--white-color);
  user-select: none;
}

.site-icon {
  height: 80px;
  width: 200px;
  object-fit: contain;
  transition: var(--transition);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.header-button {
  background: transparent;
  color: var(--background-color-light);
  border: 2px solid var(--background-color-light);
  border-radius: 6px;
  font-weight: 700;
  font-size: 14px;
  padding: 4px 12px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  height: 36px;
}

.header-button:hover,
.header-button:focus {
  background: var(--background-color-light);
  color: var(--main-font-color);
}

/* ========== Drawer 樣式 ========== */
.drawer {
  position: fixed;
  top: 0;
  right: -280px;
  width: 280px;
  height: 100%;
  background-color: var(--background-color-light);
  box-shadow: var(--shadow);
  z-index: 2000;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.drawer.open {
  right: 0;
}

.drawer-title {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--general-border-color);
  margin-bottom: 12px;
}

.drawer-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--main-font-color);
  padding: 0;
  line-height: 1;
  user-select: none;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  color: var(--main-font-color);
  text-decoration: none;
  font-weight: 500;
}

.drawer-item:hover {
  color: var(--primary-color);
}

.drawer-actions {
  margin-top: auto;
  border-top: 1px solid var(--general-border-color);
  padding-top: 12px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-action-link {
  padding: 8px 0;
  text-align: left;
  color: var(--main-font-color);
  text-decoration: none;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-action-link:hover {
  background-color: rgba(var(--main-font-color-rgb), 0.05);
  border-radius: 4px;
}

.drawer hr {
  border: none;
  border-top: 1px solid var(--general-border-color);
  margin: 12px 0;
}

.drawer .copyright {
  text-align: left;
  padding-left: 0;
  font-size: 0.64rem;
  color: var(--secondary-font-color);
  border-top: 1px solid var(--general-border-color);
  padding-top: 8px;
  user-select: none;
}

/* ========== 主內容區塊 ========== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 12px 40px;
  width: 100%;
  margin: 0 auto;
}

.container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.title,
.div_02 {
  font-weight: 700;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  text-align: center;
  margin-bottom: 1rem;
  line-height: 1.2;
  color: var(--main-font-color);
  min-height: 2.64em;
  display: flex;
  justify-content: center;
  align-items: center;
}

.highlight-bg-font {
  color: var(--primary-color);
  position: relative;
  display: inline-block;
  line-height: 1.2;
  font-size: 16px;
  z-index: 1;
}

.highlight-bg-font::before {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 0;
  width: 100%;
  height: 40%;
  background-color: var(--highlight-color);
  z-index: -1;
  border-radius: 2px;
}

.typing-text {
  border-right: 2px solid var(--main-font-color);
  padding-right: 2px;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  from, to { border-color: transparent; }
  50% { border-color: var(--main-font-color); }
}

.time-display {
  font-size: 24px;
  font-weight: bold;
  text-align: center;
  color: var(--main-font-color);
}

.date.time-display {
  color: var(--secondary-font-color);
  font-size: 14px;
}

.info-title,
.ai-title,
.atlas-title {
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 1rem;
  line-height: 1.3;
  padding: 4px 12px;
  border-radius: 6px;
  display: inline-block;
  width: 100%;
}

/* ========== Tab 樣式 ========== */
.tab-header {
  display: flex;
  justify-content: center;
  margin-bottom: 15px;
  position: relative;
  background: #ffffff;
  border: 1px solid var(--general-border-color);
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  width: 320px;
  margin: 0 auto 20px;
}

.tab-text {
  margin-left: 6px;
  white-space: nowrap;
  font-weight: 600;
}

.tab-button {
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: var(--main-font-color);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  border-radius: 10px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-button.active {
  color: var(--white-color);
  background: var(--primary-color);
}

.tab-content {
  display: none;
  padding: 15px;
  animation: fadeIn 0.3s;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ========== 搜尋與 AI 元件樣式 ========== */
.search-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 新增：資訊手冊 Tab 桌面寬度 */
@media (min-width: 769px) {
  #infoTab .search-container {
    max-width: 600px;
    margin: 0 auto;
  }
}

.search-input-container {
  position: relative;
  width: 100%;
  border: 1px solid var(--general-border-color);
  border-radius: 8px;
  background-color: var(--white-color);
  padding: 4px 8px;
  box-sizing: border-box;
  height: 50px; 
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 1rem;
  padding: 8px 32px 8px 8px;
  background: transparent;
  box-sizing: border-box;
  resize: none;
  height: 100%;
}

.clear-icon {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--secondary-font-color);
  cursor: pointer;
  display: none;
}

.search-input:valid ~ .clear-icon,
.search-input:not(:placeholder-shown) ~ .clear-icon {
  display: block;
}

.search-button {
  padding: 8px 16px;
  font-size: 0.9rem;
  border: 1px solid var(--general-border-color);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;          
  align-items: center;           
  white-space: nowrap;           
  gap: 2px;                      
  width: auto;                   
  height: 50px;
}

.search-button.active {
  background-color: var(--primary-color);
  color: var(--white-color);
  border-color: var(--primary-color);
}

.search-button:disabled {
  cursor: default !important;
  pointer-events: none;
}

/* ========== Grid View 樣式 ========== */
.grid_view_container {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: flex-start;
  background-color: #fafafa;
  border-radius: 15px;
  padding: 20px;
  box-shadow: none;
  margin-bottom: 5px;
  border: none;
  min-height: 300px;
}

.document_block {
  width: 250px;
  background-color: var(--light-grey-bg);
  border-radius: 10px;
  padding: 12px;
  border: 1px solid var(--general-border-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.3s ease;
  cursor: default;
}

.document_block:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.title_div {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 6px;
  color: var(--primary-color);
}

.subtitle_div {
  font-size: 0.9rem;
  color: var(--secondary-font-color);
  margin-bottom: 12px;
  min-height: 40px;
  display: flex;
  align-items: center;
}

.learn-more-btn {
  align-self: flex-start;
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-color);
  background-color: transparent;
  border: 2px solid var(--primary-color);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.learn-more-btn:hover,
.learn-more-btn:focus {
  background-color: var(--primary-color);
  color: var(--white-color);
  outline: none;
  box-shadow: var(--hover-shadow);
  border-color: #1a2d60;
}

/* ========== 新增：Map Blocks 樣式 ========== */
.map_block {
  width: 250px;
  background-color: var(--light-grey-bg);
  border-radius: 10px;
  padding: 12px;
  border: 1px solid var(--general-border-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.3s ease;
  cursor: default;
}

.map_block:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.map_title_div {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 6px;
  color: var(--primary-color);
}

.map_subtitle_div {
  font-size: 0.9rem;
  color: var(--secondary-font-color);
  margin-bottom: 12px;
  min-height: 40px;
  display: flex;
  align-items: center;
}

.view-map-btn {
  align-self: flex-start;
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-color);
  background-color: transparent;
  border: 2px solid var(--primary-color);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.view-map-btn:hover,
.view-map-btn:focus {
  background-color: var(--primary-color);
  color: var(--white-color);
  outline: none;
  box-shadow: var(--hover-shadow);
  border-color: #1a2d60;
}

.loading-message {
  text-align: center;
  padding: 40px 20px;
  color: var(--secondary-font-color);
  font-size: 1.1rem;
  width: 100%;
}

.error-message {
  color: var(--error-red);
  text-align: center;
  padding: 40px 20px;
  font-size: 1rem;
  width: 100%;
}

/* ========== 響應式 ========== */
@media (max-width: 768px) {
  .site-icon {
    height: 64px;
    width: 160px;
  }

  .drawer {
    width: 45%;
  }

  .search-container {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input-container {
    width: 100%;
  }

  .search-button {
    width: 100%;
    margin-top: 8px;
  }

  /* Mobile：只顯示 icon */
  .tab-text {
    display: none;
  }
  
  .tab-button {
    padding: 8px 10px;
    justify-content: center;
  }
  
  .tab-button i {
    font-size: 1.1rem;
    margin: 0;
  }

  .grid_view_container {
    justify-content: center;
    padding: 15px;
  }

  .document_block {
    width: 100%;
    max-width: 280px;
  }

  .map_block {
    width: 100%;
    max-width: 280px;
  }
}

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

@media (max-width: 768px) {
  .index_container_03 {
    padding: 0 12px;
  }
}