/*
  ChanGiDong 公司官方網站樣式表
  此檔定義了整個網站的色系、排版與版面配置。為了確保在各種環境下
  都能以同樣效果呈現，本樣式表使用了 CSS 變數和彈性佈局。
*/

/* 色彩變數設定 */
:root {
  --primary: #1e88e5;      /* 主色 – 藍色 */
  --secondary: #00bcd4;    /* 次色 – 湖水綠 */
  --bg: #f5f7fa;          /* 背景色 */
  --dark: #263238;        /* 深色文字 */
  --nav-bg: rgba(255, 255, 255, 0.9); /* 導覽列背景 */
  --nav-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* 導覽列陰影 */
}

/* 基本樣式 */
body {
  margin: 0;
  font-family: 'Noto Sans TC', 'PingFang TC', 'Helvetica Neue', sans-serif;
  color: var(--dark);
  background-color: var(--bg);
  line-height: 1.6;
}

a {
  color: inherit;
}

/* 導覽列 */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
  background: var(--nav-bg);
  box-shadow: var(--nav-box-shadow);
  backdrop-filter: blur(5px);
}

.logo {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  user-select: none;
}

.logo span {
  color: var(--secondary);
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
}

/* 主題切換按鈕 */
.theme-toggle {
  background: var(--secondary);
  border: none;
  cursor: pointer;
  color: #fff;
  font-size: 1rem;
  padding: 0.4rem 0.75rem;
  margin-left: 1rem;
  border-radius: 4px;
  transition: background 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
}

.theme-toggle:hover {
  background: var(--primary);
  color: #fff;
}

/* 浮動主題切換按鈕 */
.theme-toggle-floating {
  position: fixed;
  bottom: 90px;
  right: 30px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--secondary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: background 0.3s ease;
}

.theme-toggle-floating:hover {
  background: var(--primary);
}

/* 捲動進度條 */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  width: 0%;
  background: var(--secondary);
  z-index: 150;
}

.nav-links a {
  text-decoration: none;
  color: var(--dark);
  font-weight: 500;
  transition: color 0.3s ease;
}

.nav-links a:hover {
  color: var(--primary);
}

/* 英雄區 */
.hero {
  height: 100vh;
  background-image: url('img/hero.png');
  background-size: cover;
  background-position: center center;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
}

.hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* 深色覆蓋，用於抑制背景影像中的文字或圖形 */
  background: rgba(0, 0, 0, 0.9);
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 800px;
  padding: 0 1rem;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  line-height: 1.3;
}

.hero p {
  font-size: 1.2rem;
  margin-bottom: 2rem;
}

.btn {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: var(--secondary);
  color: #fff;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
  transition: background 0.3s ease;
}

.btn:hover {
  background: var(--primary);
}

/* 服務區 */
.services {
  padding: 4rem 2rem;
  background: #fff;
  text-align: center;
}

.services h2 {
  font-size: 2rem;
  margin-bottom: 2rem;
  color: var(--primary);
}

.service-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem;
}

.card {
  background: var(--bg);
  border-radius: 8px;
  padding: 2rem 1.5rem;
  width: 250px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.card img {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  /* 使用過濾器調整圖示顏色 */
  filter: invert(24%) sepia(94%) saturate(1403%) hue-rotate(179deg) brightness(94%) contrast(89%);
}

.card h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--secondary);
}

.card p {
  font-size: 0.95rem;
  color: var(--dark);
}

/* 關於我們區 */
.about {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 4rem 2rem;
  background: var(--bg);
}

.about-content {
  flex: 1;
  min-width: 300px;
  padding-right: 2rem;
}

.about-content h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--primary);
}

.about-content p {
  font-size: 1rem;
  line-height: 1.8;
}

.about-image {
  flex: 1;
  min-width: 300px;
}

.about-image img {
  width: 100%;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* 聯絡區 */
.contact {
  padding: 4rem 2rem;
  background: #fff;
  text-align: center;
}

.contact h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--primary);
}

.contact-info p {
  margin: 0.5rem 0;
  font-size: 1rem;
}

.contact-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 2rem;
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  max-width: 500px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  box-sizing: border-box;
}

.contact-form textarea {
  height: 120px;
  resize: vertical;
}

.contact-form button {
  padding: 0.75rem 2rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.3s ease;
}

.contact-form button:hover {
  background: var(--secondary);
}

/* 表單送出成功訊息樣式 */
.form-success {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--secondary);
  color: #fff;
  border-radius: 4px;
  font-size: 0.95rem;
  animation: fadeInOut 5s ease forwards;
}

@keyframes fadeInOut {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  10% {
    opacity: 1;
    transform: translateY(0);
  }
  90% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* 頁尾 */
footer {
  background: var(--dark);
  color: #fff;
  text-align: center;
  padding: 1rem 0;
  font-size: 0.875rem;
}

/* FAQ 區塊 */
.faq {
  padding: 4rem 2rem;
  background: var(--bg);
  max-width: 800px;
  margin: 0 auto;
}

.faq h2 {
  font-size: 2rem;
  margin-bottom: 2rem;
  text-align: center;
  color: var(--primary);
}

.faq-list {
  border-top: 1px solid #ddd;
}

.faq-item {
  border-bottom: 1px solid #ddd;
}

.faq-question {
  padding: 1rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
}

.faq-question::after {
  content: '+';
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
  transition: transform 0.3s ease;
}

.faq-item.active .faq-question::after {
  transform: translateY(-50%) rotate(45deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--dark);
  padding: 0 1rem;
  transition: max-height 0.3s ease;
}

.faq-item.active .faq-answer {
  max-height: 200px;
  padding: 0 1rem 1rem;
}

/* 回到頂部按鈕 */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  z-index: 200;
  transition: background 0.3s ease;
}

.back-to-top:hover {
  background: var(--secondary);
}

#backToTop.show {
  display: flex;
}

/* 響應式調整 */
@media (max-width: 900px) {
  .about {
    flex-direction: column;
  }
  .about-content {
    padding-right: 0;
    margin-bottom: 2rem;
  }
  .navbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .nav-links {
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
  }
}

@media (max-width: 600px) {
  .hero h1 {
    font-size: 1.8rem;
  }
  .hero p {
    font-size: 1rem;
  }
  .service-cards {
    flex-direction: column;
  }
  .card {
    width: 100%;
  }
}

/* 了解更多按鈕 */
.learn-more {
  display: inline-block;
  margin-top: 1rem;
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.3s ease;
}

.learn-more:hover {
  color: var(--secondary);
}

/* 客戶見證區塊 */
.testimonials {
  padding: 4rem 2rem;
  background: var(--bg);
  text-align: center;
}

.testimonials h2 {
  font-size: 2rem;
  margin-bottom: 2rem;
  color: var(--primary);
}

.testimonial-container {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}

.testimonial {
  display: none;
  color: var(--dark);
  font-size: 1.1rem;
  line-height: 1.8;
  min-height: 120px;
}

.testimonial.active {
  display: block;
  animation: fadeIn 0.8s ease;
}

.testimonial span {
  display: block;
  margin-top: 1rem;
  font-weight: bold;
  color: var(--secondary);
}

.testimonial-nav {
  margin-top: 1rem;
}

.testimonial-nav span {
  display: inline-block;
  cursor: pointer;
  font-size: 2rem;
  margin: 0 1rem;
  color: var(--primary);
  transition: color 0.3s ease;
  user-select: none;
}

.testimonial-nav span:hover {
  color: var(--secondary);
}

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

/* 數字統計區塊 */
.stats {
  padding: 4rem 2rem;
  background: #fff;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2rem;
  text-align: center;
}

.stat {
  flex: 1;
  min-width: 150px;
}

.counter {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  display: block;
}

.stat p {
  margin-top: 0.5rem;
  font-size: 1.1rem;
  color: var(--dark);
}

/* 地圖嵌入 */
.map-embed {
  width: 100%;
  height: 400px;
  border: none;
  margin-top: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 模態視窗 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
  max-width: 600px;
  width: 90%;
  position: relative;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.close-modal {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--dark);
  transition: color 0.3s ease;
}

.close-modal:hover {
  color: var(--primary);
}

/* ---------------------------------------------- */
/* 暗色模式設定                                    */
/* ---------------------------------------------- */

/* 當 body 擁有 dark-mode 類別時，覆蓋顏色變數及背景 */
body.dark-mode {
  --primary: #90caf9;     /* 暗色模式主色 – 淡藍 */
  --secondary: #4fc3f7;   /* 暗色模式次色 – 淺天藍 */
  --bg: #121212;         /* 背景色 – 極深灰 */
  --dark: #f5f5f5;       /* 文字顏色 – 極淺灰 */
  --nav-bg: rgba(0, 0, 0, 0.8);
  --nav-box-shadow: 0 2px 4px rgba(255, 255, 255, 0.1);
}

/* 導覽列暗色模式色彩微調 */
body.dark-mode .navbar {
  color: var(--dark);
}

/* 主要區塊背景與文字顏色調整 */
body.dark-mode .services,
body.dark-mode .about,
body.dark-mode .testimonials,
body.dark-mode .stats,
body.dark-mode .faq,
body.dark-mode .contact {
  background: var(--bg);
  color: var(--dark);
}

/* 卡片暗色背景 */
body.dark-mode .card {
  background: #1e1e1e;
}

/* FAQ 問題符號顏色調整 */
body.dark-mode .faq-question::after {
  background-color: var(--primary);
  color: #fff;
}

/* FAQ 答案背景調整 */
body.dark-mode .faq-item.active .faq-answer {
  background: #1e1e1e;
}

/* 頁尾暗色背景 */
body.dark-mode footer {
  background: #0d0d0d;
  color: var(--dark);
}

/* 模態視窗暗色背景 */
body.dark-mode .modal-content {
  background: #1e1e1e;
  color: var(--dark);
}

/* 表單與輸入框暗色背景 */
body.dark-mode .contact-form input,
body.dark-mode .contact-form textarea {
  background: #1e1e1e;
  color: var(--dark);
  border-color: #444;
}

body.dark-mode .contact-form button {
  background: var(--primary);
  color: #fff;
}
