/* ========== ✅ 原始全域變數與基礎樣式 ========== */
: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-bottom-links {
  border-top: 1px solid var(--general-border-color);
  margin-top: 16px;
  padding-top: 8px;
  font-size: 0.68rem;
  color: var(--secondary-font-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drawer-bottom-links a,
.drawer-bottom-links a:hover {
  color: var(--secondary-font-color);
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
}

.drawer-bottom-links a:hover {
  text-decoration: underline;
}

/* ✅ 本次修改：Drawer 版權靠左對齊 */
.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 取代 div */
.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;
}

.page_title {
  font-size: 32px;
  font-weight: bold;
}

.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 {
  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: 240px;
  margin: 0 auto 20px;
}

.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;
}

.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,
.ai-container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto 1.5rem;
}

.search-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ✅ 修改：統一輸入框樣式，與 ai-textarea-wrapper 相同 */
.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;
}

/* ✅ 修改：統一按鈕樣式，與 ai-send 相同 */
.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;
}

.ai-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.ai-textarea-wrapper {
  position: relative;
  width: 100%;
}

.ai-textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  font-size: 1rem;
  padding: 12px;
  border: 1px solid var(--general-border-color);
  border-radius: 8px;
  box-sizing: border-box;
}

.char-count {
  position: absolute;
  right: 12px;
  bottom: 8px;
  color: var(--secondary-font-color);
  font-size: 12px;
}

.ai-button-group {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.ai-reset,
.ai-send {
  padding: 6px 12px;
  font-size: 0.9rem;
  border: 1px solid var(--general-border-color);
  border-radius: 0.5rem;
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
}

.ai-send.active {
  background-color: var(--primary-color);
  color: var(--white-color);
  border-color: var(--primary-color);
}

.ai-send:disabled {
  cursor: default !important;
  pointer-events: none;
}

/* ========== ✅ 新增：Grid View 樣式 (從 grid_project 移植) ========== */
.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_container {
  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_container: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;
}

/* ========== ✅ 新增：載入中和錯誤訊息樣式 ========== */
.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%;
}

/* ========== ✅ 錯誤頁面專屬樣式 ========== */
.error-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 12px;
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.error-icon {
  font-size: 4rem;
  color: var(--error-red);
  margin-bottom: 1.5rem;
}

.error-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  color: var(--main-font-color);
  margin-bottom: 1rem;
}

.error-message {
  font-size: 1.1rem;
  color: var(--secondary-font-color);
  margin-bottom: 2rem;
  max-width: 400px;
}

.error-button {
  padding: 10px 24px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary-color);
  background-color: transparent;
  border: 2px solid var(--primary-color);
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: inline-block;
}

.error-button:hover {
  background-color: var(--primary-color);
  color: var(--white-color);
  box-shadow: var(--hover-shadow);
  text-decoration: none;
}

/* ========== ✅ 響應式（768px以下） ========== */
@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;
  }

  .ai-textarea {
    max-width: 100%;
  }

  .error-icon {
    font-size: 3rem;
  }

  .error-title {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
  }

  .error-message {
    font-size: 0.95rem;
  }

  /* ✅ 新增：Grid View 響應式 */
  .grid_view_container {
    justify-content: center;
    padding: 15px;
  }

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

/* ========== ✅ 內容區域樣式調整 ========== */
.index_container_03 {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.content-section {
  width: 80%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
  background-color: var(--white-color);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.content-section h2,
.content-section h3 {
  color: var(--primary-color);
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

.content-section p,
.content-section ul {
  margin-bottom: 1em;
  line-height: 1.6;
}

.content-section ul {
  padding-left: 1.5em;
}

.content-section li {
  margin-bottom: 0.5em;
}

/* ========== ✅ 響應式設計 ========== */
@media (max-width: 768px) {
  .content-section {
    width: 100%;
    padding: 15px;
  }

  .index_container_03 {
    padding: 0 12px;
  }
}