/*
CSS 檔案結構：
1. General Styles (通用樣式) - 全站基礎設定，如顏色、字體、容器等。
2. Header (頁首) - 網站最上方的導覽列。
3. Hero Section (主視覺區) - 首頁的大圖橫幅。
4. About Section (關於我們區) - 公司介紹及代理品牌。
5. Products Section (產品區) - 主要產品格狀列表。
6. Technology Section (技術資料區) - 技術特點格狀列表。
7. Contact Section (聯絡資訊區) - 位於頁尾上方的聯絡方式。
8. Footer (頁尾) - 網站最底部的版權資訊。
9. Catalog Page Styles (型錄頁專用樣式) - 僅用於 catalog.html 的特殊樣式。
10. Responsive Design (響應式設計) - 針對不同螢幕尺寸的版面調整。
*/

/* 1. General Styles (通用樣式) */
/* =================================== */

/* :root 用於定義全站可重複使用的 CSS 變數 */
:root {
    --primary-color: #0056b3; /* 核心藍色，用於主要按鈕、連結、標題裝飾 */
    --secondary-color: #f8f9fa; /* 頁面淺灰色背景，用於交錯區塊的底色 */
    --text-color: #333; /* 主要內文文字顏色 */
    --heading-color: #2c3e50; /* 標題文字顏色 */
    --accent-color: #28a745; /* 強調色，如註冊按鈕或成功提示 */
    --border-color: #dee2e6; /* 邊框顏色 */
    --light-grey: #f2f2f2; /* 較淺的灰色，備用 */
}

/* body - 設定頁面的基礎字體、行高、邊距和背景顏色 */
body {
    font-family: 'Segoe UI', 'Microsoft JhengHei', sans-serif; /* 字體，優先使用 Segoe UI，中文則為微軟正黑體 */
    line-height: 1.6; /* 行高 */
    margin: 0;
    padding: 0;
    color: var(--text-color);
    background-color: #fff; /* 預設背景為白色 */
}

/* .container - 主要內容容器，設定最大寬度並使其置中 */
.container {
    max-width: 1200px; /* 最大寬度 1200px */
    margin: 0 auto; /* 左右邊距自動，使其水平置中 */
    padding: 0 20px; /* 左右內邊距 20px，防止內容貼邊 */
}

/* h1, h2, ... - 標題通用樣式 */
h1, h2, h3, h4, h5, h6 {
    color: var(--heading-color);
    margin-bottom: 1rem; /* 標題下方間距 */
}

/* h2 - 主要區塊標題的特殊樣式 */
h2 {
    text-align: center; /* 文字置中 */
    font-size: 2.5rem; /* 字體大小 */
    margin-bottom: 2.5rem;
    position: relative; /* 相對定位，為底線做準備 */
    padding-bottom: 10px; /* 標題文字與底線的距離 */
}

/* h2::after - 區塊標題下方的裝飾底線 */
h2::after {
    content: ''; /* 偽元素必要屬性 */
    position: absolute;
    left: 50%; /* 從中間開始 */
    bottom: 0;
    transform: translateX(-50%); /* 往左移自身寬度的一半，使其完美置中 */
    width: 60px;
    height: 4px;
    background-color: var(--primary-color);
    border-radius: 2px;
}

/* a - 超連結通用樣式 */
a {
    color: var(--primary-color);
    text-decoration: none; /* 去除底線 */
    transition: color 0.3s ease; /* 滑鼠移上時顏色變化的過渡效果 */
}

a:hover {
    color: #003f80; /* 滑鼠移上時的顏色 */
}

/* .section-padding - 區塊通用上下內邊距 */
.section-padding {
    padding: 80px 0;
}

/* .section-alt-bg - 交錯區塊的背景色 */
.section-alt-bg {
    background-color: var(--secondary-color);
}

/* 2. Header (頁首) */
/* =================================== */
header {
    background-color: #fff;
    color: #fff;
    padding: 15px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* 頁首下方的陰影 */
    position: sticky; /* 黏性定位，當頁面捲動時會固定在頂部 */
    top: 0; /* 固定在最頂部 */
    z-index: 1000; /* 確保頁首在最上層 */
}

header .container {
    display: flex; /* 使用 Flexbox 排版 */
    justify-content: space-between; /* 左右兩側對齊 */
    align-items: center; /* 垂直置中 */
}

.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 50px;
    margin-right: 15px;
}

.logo h1 {
    color: var(--heading-color);
    font-size: 1.8rem;
    margin: 0; /* 去除 h1 預設的 margin */
}

/* nav - 導覽列樣式 */
nav ul {
    list-style: none; /* 去除列表的點 */
    margin: 0;
    padding: 0;
    display: flex; /* 讓列表項目水平排列 */
}

nav ul li {
    margin-left: 30px; /* 項目之間的左間距 */
}

nav ul li a {
    color: var(--heading-color);
    font-weight: bold;
    padding: 5px 0;
    transition: color 0.3s ease, border-bottom 0.3s ease;
    border-bottom: 2px solid transparent; /* 預設透明底線 */
}

/* 當滑鼠移上或目前頁面時的樣式 */
nav ul li a:hover,
nav ul li a.active-nav-link {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color); /* 顯示藍色底線 */
}


/* 3. Hero Section (主視覺區) */
/* =================================== */
#hero {
    background: url('https://raw.githubusercontent.com/rawpixel_images/5903616/photo-image-background-public-domain-blue.jpg') no-repeat center center/cover;
    color: white;
    text-align: center;
    padding: 80px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 280px; /* 最小高度 */
    position: relative;
}

/* #hero::before - 黑色半透明遮罩，讓文字更清晰 */
#hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 1;
}

#hero .container {
    position: relative;
    z-index: 2; /* 確保內容在遮罩之上 */
}

#hero h2 {
    font-size: 3rem;
    margin-bottom: 15px;
    color: white;
    line-height: 1.2;
}

#hero h2::after {
    background-color: white; /* Hero 區的標題底線為白色 */
}

#hero p {
    font-size: 1.3rem;
    max-width: 700px;
    margin: 0 auto;
}

/* 4. About Section (關於我們區) */
/* =================================== */
#about p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    text-align: justify; /* 文字左右對齊 */
}

.agency-list {
    margin-top: 30px;
}

/* .agency-item - 代理品牌的卡片樣式 */
.agency-item {
    margin-bottom: 40px;
    background-color: #fcfcfc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.agency-item h4 {
    text-align: left;
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    display: inline-block;
}

.agency-content {
    display: flex;
    align-items: flex-start; /* 頂部對齊 */
    gap: 20px; /* 項目間距 */
}

.agency-content img {
    max-width: 112.5px;
    height: auto;
    border-radius: 5px;
    flex-shrink: 0; /* 防止圖片被壓縮 */
    border: 1px solid #eee;
}

.agency-content p {
    font-size: 1rem;
    line-height: 1.7;
    text-align: justify;
    margin: 0;
    color: var(--text-color);
}

/* 5. Products Section (產品區) */
/* =================================== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* 自適應格線佈局 */
    gap: 30px;
}

/* .product-item - 產品卡片樣式 */
.product-item {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.product-item:hover {
    transform: translateY(-5px); /* 滑鼠移上時向上移動 */
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
}

.product-item img {
    width: 100%;
    max-height: 180px;
    object-fit: contain; /* 圖片等比例縮放並完整顯示 */
    border-radius: 4px;
    margin-bottom: 15px;
    display: block;
    border: 1px solid var(--border-color);
}

.product-item h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 10px;
}

.product-item h4 {
    font-size: 1rem;
    color: var(--heading-color);
    margin-bottom: 10px;
}

.product-item p {
    font-size: 0.95rem;
    line-height: 1.7;
    color: #555;
}

/* 6. Technology Section (技術資料區) */
/* =================================== */
.tech-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.tech-item {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.tech-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
}

.tech-item h3 {
    font-size: 1.4rem;
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 10px;
}

.tech-item p {
    font-size: 0.95rem;
    line-height: 1.7;
    color: #555;
}

/* 7. Contact Section (聯絡資訊區) */
/* =================================== */
.contact-footer {
    background: linear-gradient(to right, #ffdd57, #ffc300); /* 黃色漸層背景 */
    color: #333;
    padding: 60px 0;
    text-align: center;
}

/* 隱藏此區塊的 h2 標題，因為設計上不需要 */
.contact-footer h2 {
    display: none;
}

.contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    align-items: flex-start;
}

.contact-column {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    text-align: left;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.contact-column h3 {
    color: var(--heading-color);
    font-size: 1.6rem;
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.contact-column p {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #555;
    margin-bottom: 10px;
}

.contact-column a {
    color: var(--primary-color);
    font-weight: normal;
    transition: color 0.3s ease;
}

.contact-column a:hover {
    color: #003f80;
    text-decoration: underline;
}

/* 8. Footer (頁尾) */
/* =================================== */
footer {
    background-color: var(--heading-color);
    color: #fff;
    text-align: center;
    padding: 25px 0;
    font-size: 0.9rem;
}

/* 9. Catalog Page Styles (型錄頁專用樣式) */
/* =================================== */
.catalog-page-wrapper {
    background: var(--secondary-color);
    padding: 40px 0;
}

.main-content {
    display: flex;
    gap: 20px;
    background: transparent;
    box-shadow: none;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* .sidebar - 左側邊欄樣式 */
.sidebar {
    flex: 0 0 280px; /* flex-grow:0, flex-shrink:0, flex-basis:280px (固定寬度) */
    background: #ffffff;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid var(--primary-color);
}

.sidebar h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.5rem;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

.category-list {
    list-style: none;
    padding: 0;
}

.category-item {
    margin-bottom: 10px;
}

/* .category-btn - 側邊欄分類按鈕 */
.category-btn {
    width: 100%;
    padding: 15px 20px;
    background: #f0f4f8;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    text-align: left;
}

.category-btn:hover {
    background: #d4e2f0;
    transform: none; /* 取消其他按鈕的 hover 效果 */
}

.category-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* .content-area - 右側主內容區 */
.content-area {
    flex: 1; /* 佔滿剩餘空間 */
    padding: 0;
}

.category-content {
    display: none; /* 預設隱藏所有分類內容 */
}

.category-content.active {
    display: block; /* 只顯示當前啟用的分類 */
}

.category-title {
    color: var(--heading-color);
    font-size: 2rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 3px solid var(--primary-color);
    text-align: left;
}

.category-title::after {
    display: none; /* 覆蓋通用的 h2::after 樣式 */
}

/* .products-grid - 型錄頁的產品格線 */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
}

/* .product-card - 型錄頁的產品卡片 */
.product-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.12);
    border-color: var(--primary-color);
}

.product-image {
    width: 100%;
    height: 200px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 10px;
}

/* 確保產品圖片在容器內正常顯示 */
.product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* 關鍵屬性：等比例縮放並完整顯示圖片 */
}

.product-info {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* 讓此區塊填滿卡片的剩餘高度 */
}

.product-model {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.product-overview {
    color: #666;
    line-height: 1.6;
    margin-bottom: 15px;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
    flex-grow: 1;
}

.product-details {
    text-align: right;
    margin-top: auto; /* 將按鈕推到卡片底部 */
}

.details-link {
    display: inline-block;
    padding: 10px 20px;
    background: var(--accent-color);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.details-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

/* @keyframes - 定義淡入動畫效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 10. Responsive Design (響應式設計) */
/* =================================== */

/* 平板尺寸 (寬度小於 992px) */
@media (max-width: 992px) {
    .main-content {
        flex-direction: column; /* 型錄頁主內容改為垂直排列 */
    }
    .sidebar {
        flex: none;
        width: auto;
    }
}

/* 手機尺寸 (寬度小於 768px) */
@media (max-width: 768px) {
    header .container {
        flex-direction: column; /* 頁首內容垂直排列 */
        text-align: center;
    }
    .logo { margin-bottom: 15px; }
    /* nav ul { flex-direction: column; align-items: center; } *//* 導覽列項目垂直排列 */
    /* nav ul li { margin: 10px 0; } */
    #hero h2 { font-size: 2.5rem; }
    #hero p { font-size: 1.2rem; }
    h2 { font-size: 2rem; }
    .section-padding { padding: 50px 0; }
    .product-grid, .tech-grid, .contact-grid { grid-template-columns: 1fr; } /* 所有格線佈局改為單欄 */
    .contact-column, .agency-content { text-align: center; }
    .agency-content { flex-direction: column; align-items: center; }
    .agency-content img { margin-bottom: 15px; }
    .products-grid { grid-template-columns: 1fr; }
}

/* 較小手機尺寸 (寬度小於 480px) */
@media (max-width: 480px) {
    .logo h1 { font-size: 1.5rem; }
    #hero h2 { font-size: 2rem; }
    #hero p { font-size: 1rem; }
    h2 { font-size: 1.8rem; }
}

/* 手機版優化：導覽列改為三欄式 */
@media (max-width: 768px) {
    header nav ul {
        display: flex;         /* 啟用 Flexbox */
        flex-wrap: wrap;       /* 允許項目換行 */
        justify-content: center; /* 讓項目在容器中置中 */
        padding-top: 15px 0 0 0;     /* 增加一點頂部空間 */
    }
    header nav li {
        flex: 0 0 32%;         /* 設定每個項目的基礎寬度約為 1/3 */
        text-align: center;    /* 讓文字置中 */
        margin: 0 0 15px 0; /* 新增：重設 padding，避免影響寬度計算 */
        mpadding: 0;
    }
}

   /* --- 優化導覽列與語言切換器排列 --- */
   header nav {
    display: flex;
   align-items: center;
   gap: 20px; /* 在導覽列和語言切換器之間增加 20px 的間距 */
   }
   
   /* 新增：防止選單項目文字被不當換行 */
    header nav ul li {
   white-space: nowrap;
   }
   }
        /* 如果您希望導覽列和語言切換器都盡量靠右對齊，可以使用 justify-content: flex-end; */
        justify-content: flex-end; 
        }

    /* --- 調整特定文字大小 --- */
    
    /* 承信環境科技股份有限公司 (Logo 中的標題) */
    .logo h1 {
   font-size: 1.4rem; /* 電腦版大小 (原為 1.8rem，縮小至 1.4rem) */
    }
    
    /* 導覽列連結 (公司介紹, 產品介紹, 設備型錄, 技術資料, 聯絡我們) */
    nav ul li a {
   font-size: 0.9rem; /* 電腦版大小 (約為預設的 90%) */
   }
  
   /* --- 手機版調整 (針對小螢幕進一步縮小) --- */
   @media (max-width: 768px) {
   .logo h1 {
   font-size: 1.2rem; /* 手機版 Logo 標題大小 */
   }
    nav ul li a {
   font-size: 0.8rem; /* 手機版導覽列連結大小 */
   }
   }



