/* =========================================
   0. 全域變數與重置 (Variables & Reset)
   ========================================= */
:root {
    --primary-blue: #1c355e;   /* 企業主色 (深藍) */
    --accent-red: #d32f2f;     /* 點綴色 (紅色線條) */
    --footer-bg: #b8c1cb;      /* 頁尾灰藍色 */
    --text-dark: #333333;
    --text-light: #ffffff;
    --text-gray: #555555;
    --transition-speed: 0.3s;
    --border-color: rgba(255, 255, 255, 0.4); /* 設計圖中選單的淺色分隔線 */
}

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

body {
    font-family: 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', sans-serif;
    line-height: 1.5;
    color: var(--text-dark);
    background-color: var(--text-light);
}

a { 
    text-decoration: none; 
    transition: color var(--transition-speed); 
}

/* =========================================
   1. 頁首導覽列與語言切換 (共用電腦版)
   ========================================= */
.site-header {
    padding: 15px 0;
    position: sticky;       /* 讓 Header 黏在最上方 */
    top: 0;
    z-index: 1000;
    background-color: var(--primary-blue); /* 預設在最頂端時的深藍色 (完全不透明) */
    transition: transform 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease; 
}

/* 狀態 1：往下滑時 -> 往上隱藏 */
.site-header.header-hidden {
    transform: translateY(-100%);
}

/* 狀態 2：往上滑時 -> 出現且呈現 50% 透明度 */
.site-header.header-scrolled-up {
    background-color: rgba(30, 58, 95, 0.5); 
    backdrop-filter: blur(10px); 
    -webkit-backdrop-filter: blur(10px); 
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); 
}

.header-container { 
    max-width: 1400px; 
    margin: 0 auto; 
    padding: 0 40px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.logo-block { 
    display: flex; 
    align-items: center; 
    gap: 15px; 
}

.logo-icon-placeholder { 
    width: 75px; 
    height: 75px; 
    background-color: #ffffff; 
    border: 2px solid var(--accent-red); 
    border-radius: 50%; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    overflow: hidden; 
}

.logo-text { 
    color: var(--text-light); 
    font-size: 42px; 
    font-weight: bold; 
    letter-spacing: 2px; 
    border-bottom: 4px solid var(--accent-red); 
}

.hamburger-btn { 
    display: none; 
    flex-direction: column; 
    gap: 6px; 
    cursor: pointer; 
    z-index: 100; 
}

.hamburger-btn .bar { 
    width: 20px; 
    height: 2px; 
    background-color: var(--text-light); 
    transition: all 0.3s ease; 
    border-radius: 3px; 
}

.nav-block { 
    display: flex; 
    align-items: center; 
    gap: 40px; 
}

.main-nav { 
    display: flex; 
    align-items: center; 
    gap: 40px; 
}

.main-nav a {
    color: var(--text-light); 
    font-size: 24px; 
    font-weight: 500; 
    text-align: center;
    line-height: 1.5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: normal;
}

.main-nav a:hover, .main-nav a.active { 
    opacity: 0.8; 
}

.main-nav a.active { 
    border-bottom: 2px solid var(--text-light); 
}

/* 語言切換母容器 */
.lang-selector { 
    position: relative; 
    z-index: 10010 !important; /* 強制提高至最頂層，防止被其他層級遮擋 */
}

.lang-trigger { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    color: var(--text-light); 
    cursor: pointer; 
    padding: 10px 0; 
}

.icon-globe { width: 20px; height: 20px; }
.icon-arrow { width: 16px; height: 16px; }

/* 語言下拉選單主體 */
.lang-dropdown { 
    position: absolute; 
    top: 100%; 
    right: -10px; 
    background-color: #172a4d; 
    border-radius: 6px; 
    list-style: none; 
    width: 110px; 
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); 
    overflow: hidden; 
    opacity: 0; 
    visibility: hidden; 
    transform: translateY(-10px); 
    transition: all 0.3s ease; 
    z-index: 10011 !important; 
}

.lang-selector:hover .lang-dropdown { 
    opacity: 1; 
    visibility: visible; 
    transform: translateY(0); 
}

.lang-dropdown li a { 
    display: block; 
    padding: 12px 15px; 
    color: #ffffff; 
    text-align: center;  
    font-size: 15px; 
    font-weight: 500; 
    transition: background-color 0.2s ease; 
}

.lang-dropdown li a:hover { 
    background-color: #5d6d88; 
}

/* =========================================
   2. 公司介紹頁面特定樣式 (Accordion 與矩陣卡片)
   ========================================= */
.about-section {
    background-color: var(--primary-blue);
    padding: 60px 0 100px 0;
    min-height: 70vh;
}

.accordion-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 40px;
}

.accordion-item {
    border-top: 1px solid var(--border-color);
}

.accordion-item:last-child {
    border-bottom: 1px solid var(--border-color);
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px 20px;
    cursor: pointer;
    transition: background-color var(--transition-speed);
}

.accordion-header:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.accordion-title {
    color: var(--text-light);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 2px;
}

.accordion-icon {
    color: var(--text-light);
    width: 24px;
    height: 24px;
    transition: transform 0.4s ease;
}

/* 隱藏內容區塊 (使用 CSS Grid 達成完美滑動) */
.accordion-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.4s ease;
}

.content-inner {
    overflow: hidden;
    padding: 0 20px 0 20px;
    color: rgba(255,255,255,0.7);
    transition: padding 0.4s ease;
    font-size: 20px;
    text-align: justify;
    text-justify: inter-ideograph;
    line-height: 1.8;
}

/* Accordion 激活狀態 */
.accordion-item.active .accordion-content {
    grid-template-rows: 1fr;
    overflow: visible !important; /* 允許溢出防止遮擋上方提示框 */
}

.accordion-item.active .content-inner {
    padding: 0 20px 30px 20px;
    overflow: visible !important;
}

.accordion-item.active .accordion-icon {
    transform: rotate(180deg); 
}

/* 內容圖片與自適應樣式 */
.accordion-img {
    width: 100%;
    max-width: 1000px;
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: 8px;
}

/* 「組織架構」全寬顯示專屬微調 */
#organization-item .content-inner {
    padding: 0 0 20px 0 !important;
}
#organization-item .accordion-img {
    max-width: 100% !important;
    border-radius: 20px !important;
}

/* 自訂列表打勾與圓點樣式 */
.custom-list {
    list-style: none; 
    margin-left: 10px;
}

.custom-list > li::before {
    content: "✔︎ "; 
    color: rgba(255,255,255,0.7); 
    font-weight: bold;
    margin-right: 5px; 
}

.custom-list ul {
    list-style-type: disc !important; 
    margin-top: 8px;
    margin-bottom: 12px;
    margin-left: 30px; 
}

.custom-list ul li::before {
    content: none !important;
}

/* 設備體系證書 3欄網格 */
.equip-matrix-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-top: 15px;
}

.matrix-item {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.matrix-item:hover {
    transform: translateY(-5px);
    background-color: rgba(255, 255, 255, 0.08);
}

.matrix-img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    margin-bottom: 15px;
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.matrix-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 18px;
    line-height: 1.6;
    margin: 0;
    letter-spacing: 1px;
}

/* =========================================
   3. 頁尾區塊 (Footer 共用電腦版)
   ========================================= */
.site-footer { 
    background-color: var(--footer-bg); 
    padding: 24px 0; 
}

.footer-container { 
    max-width: 1400px; 
    margin: 0 auto; 
    padding: 0 40px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.contact-header { 
    display: flex; 
    align-items: baseline; 
    flex-wrap: wrap; 
    gap: 20px; 
    margin-bottom: 15px; 
}

.contact-header h2 { 
    color: var(--text-gray); 
    font-size: 30px; 
    font-weight: 800; 
}

.contact-details { 
    color: var(--text-gray); 
    font-size: 18px; 
    font-weight: bold; 
    display: flex; 
    gap: 15px; 
    align-items: center; 
}

.copyright { 
    color: var(--text-gray); 
    font-size: 14px; 
    font-weight: bold; 
}

.footer-logo { 
    color: var(--primary-blue); 
    font-size: 64px; 
    font-weight: 900; 
    line-height: 1; 
}

/* 確保 Email 連結與旁邊的文字看起來一致 */
.footer-email {
    color: var(--text-gray);      /* 保持與 ADD/TEL 相同的顏色 */
    text-decoration: none;        /* 移除底線 */
    cursor: pointer;              /* 滑鼠移入顯示手指指標 */
    transition: opacity 0.2s;
}

/* 當滑鼠移上去時，加上一點視覺反饋 */
.footer-email:hover {
    opacity: 0.7;
    color: #666666;                  /* 滑鼠懸停時微調顏色 */
}

/* =========================================
   4. 共用元件：地圖導航圖標與懸浮提示框 (Tooltip)
   ========================================= */
.col-list li, .contact-details span {
    position: relative; 
}

.nav-icon-link:hover {
    background-color: #ffffff !important;
    color: var(--primary-blue) !important;
    transform: scale(1.1);
}

.nav-icon-link::after {
    content: attr(data-tooltip); 
    position: absolute;
    bottom: 135%; 
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background-color: rgba(0, 0, 0, 0.85); 
    color: #ffffff;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: normal;
    border-radius: 6px;
    white-space: nowrap; 
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    pointer-events: none; 
    letter-spacing: 0;
    line-height: 1.4;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.nav-icon-link::before {
    content: '';
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    border-width: 6px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.85) transparent transparent transparent; 
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.nav-icon-link:hover::after,
.nav-icon-link:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* =========================================
   5. 專屬英文版特定微調 (html[lang="en"] 電腦版)
   ========================================= */
html[lang="en"] .logo-text {
    font-size: 36px;
    line-height: 1.2;
    margin-top: 4px;
}

html[lang="en"] .footer-info {
    display: flex;
    flex-direction: column;
}

html[lang="en"] .copyright-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

html[lang="en"] .copyright-row .copyright {
    margin: 0;
}

html[lang="en"] .footer-email {
    color: var(--text-gray);
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
}


/* =========================================================================
   ★ 響應式核心：所有 RWD 媒體查詢樣式集中管理區塊 ★
   ========================================================================= */

/* ----------------=========================
   RWD 1. 平板模式：視窗寬度 1180px 以下
   ----------------========================= */
@media (max-width: 1180px) {
    .header-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .logo-text { 
        font-size: 30px; 
    }

    .footer-container {
        flex-direction: column;
        text-align: center;
        gap: 30px;
    }
    
    .contact-header { 
        justify-content: center; 
    }

    /* 專屬英文版平板微調 */
    html[lang="en"] .logo-text { 
        font-size: 30px; 
    }
}

/* ----------------=========================
   RWD 2. 手機模式：視窗寬度 768px 以下
   ----------------========================= */
@media (max-width: 768px) {
    /* 終極排版修復：強制清除特定頁面潛在的高度死鎖，移除多餘間距使 Footer 緊貼 */
    html, body, main, .main-content {
        height: auto !important;
        min-height: 0 !important;
    }

    .about-section {
        height: auto !important;          
        min-height: 0 !important;
        padding: 30px 0 0 0 !important;  /* 移除底部內邊距，消除空隙 */
        margin-bottom: 0 !important;
        overflow: visible !important;     
    }

    .site-footer {
        clear: both !important;            
        position: relative !important;     
        margin-top: 0 !important;         /* 強制外邊距歸零，使灰色區塊完美咬合藍色區塊 */
        padding-top: 30px !important;     /* 透過內邊距拉開文字舒適空間 */
    }

    /* 頁首基本排版與 Logo 縮小縮放 */
    .header-container { 
        position: relative; 
        flex-direction: row; 
        justify-content: space-between; 
        align-items: center; 
        padding: 0 20px; 
    }
    
    .logo-block { gap: 10px; }
    .logo-icon-placeholder { width: 45px; height: 45px; }
    .logo-icon-placeholder img { height: 45px !important; }
    
    .logo-text { 
        font-size: 18.5px; 
        border-bottom: 2px solid var(--accent-red); 
    }
    
    /* 漢堡選單喚醒與手機版導覽列下拉面板 */
    .hamburger-btn { 
        display: flex; 
    }
    
    .nav-block { 
        display: none; 
        position: absolute; 
        top: 100%; 
        left: 0; 
        width: 100%; 
        background-color: var(--primary-blue); 
        flex-direction: column; 
        align-items: center; 
        padding: 20px 0; 
        gap: 20px; 
        box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3); 
        z-index: 90; 
    }
    
    .nav-block.active { 
        display: flex; 
    }
    
    .main-nav { 
        flex-direction: column; 
        text-align: center; 
        gap: 20px; 
    }
    
    .main-nav a { 
        font-size: 20px; 
    }
    
    /* 手機版語言下拉切換定位優化 */
    /* 1. 隱藏地球儀與箭頭圖示，減少使用者點擊步驟 */
    .lang-trigger {
        display: none !important;
    }

    /* 2. 讓語言區塊容器滿版，並給予舒適的上下間距 */
    .lang-selector {
        width: 100% !important;
        position: relative !important;
        padding: 5px 50px 0 50px !important;
        z-index: 10010 !important;
    }

    /* 3. 解除原本的滑鼠 Hover 隱藏邏輯，強制變為 Flex 橫向整排顯示 */
    .lang-dropdown {
        position: relative !important;
        top: 0 !important;
        right: 0 !important;
        transform: none !important;
        
        /* 強制永遠顯示並橫向排列 */
        display: flex !important;
        flex-direction: row !important; 
        justify-content: center !important;
        align-items: center !important;
        gap: 3px !important; /* 按鈕彼此之間的左右間距 */
        
        width: 100% !important;
        background-color: transparent !important; /* 拔掉原先的深藍色下拉底色包圍盒 */
        box-shadow: none !important;
        list-style: none !important;
        
        /* 覆蓋掉 Hover 隱藏的開關屬性，讓它直接常駐可見 */
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        padding: 0 !important;
    }

    /* 4. 讓 3 個語言選項平均瓜分整行寬度，並讓內部文字置中 */
    .lang-dropdown li {
        flex: 1 !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        justify-content: center !important; /* 確保內部的 a 標籤置中 */
    }

    /* 5. 移除框線與背景，改為跟首頁導覽列一樣的「純文字 + 預留透明底線」 */
    .lang-dropdown li a {
        display: inline-block !important; /* 讓底線寬度剛剛好包住文字 */
        padding: 8px 2px !important;      /* 縮小左右 padding 讓底線更貼合字數 */
        font-size: 16px !important;       /* 稍微放大字體配合無框線視覺 */
        font-weight: 500 !important;
        color: #ffffff !important;
        white-space: nowrap !important;
        
        /* 移除先前的按鈕樣式 */
        background-color: transparent !important;
        border: none !important;
        border-radius: 0 !important;
        
        /* 預留一條透明的 2px 底線，防止點擊時畫面跳動 */
        border-bottom: 2px solid transparent !important; 
        transition: border-color 0.2s !important;
    }

    /* 6. 當點擊時的反饋效果 */
    .lang-dropdown li a:active {
        border-bottom: 2px solid rgba(255, 255, 255, 0.5) !important;
    }

    /* 7. ★ 核心：讓目前所在語系的按鈕，底線永遠停留保持顯示 ★ */
    /* 當網頁是繁體中文時，底線停留在 [data-lang="tw"] */
    html[lang="zh-Hant"] .lang-dropdown li a[data-lang="tw"],
    /* 當網頁是簡體中文時，底線停留在 [data-lang="cn"] */
    html[lang="zh-Hans"] .lang-dropdown li a[data-lang="cn"],
    /* 當網頁是英文版時，底線停留在 [data-lang="en"] */
    html[lang="en"] .lang-dropdown li a[data-lang="en"] {
        border-bottom: 2px solid var(--text-light) !important;
        font-weight: bold !important; /* (選用) 讓當前語言的字體稍微加粗，視覺更清晰 */
    }

    /* 公司介紹折疊組件手機版間距微調 */
    .accordion-container { 
        padding: 0 20px; 
        margin-bottom: 0 !important; 
        padding-bottom: 20px; 
    }
    
    .accordion-title { font-size: 20px; }
    .accordion-header { padding: 20px 10px; }

    /* 設備體系證書矩陣：強制由 3欄 轉為 1欄直排防破版 */
    .equip-matrix-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .matrix-item { padding: 12px; }
    .matrix-text { font-size: 15px; }

    /* 體系證書區塊內嵌內聯樣式相容性微調 */
    .content-inner div[style*="grid"] {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .content-inner div[style*="flex"] {
        height: auto !important;
        flex-direction: column !important;
        gap: 16px !important;
    }
    
    .content-inner div[style*="flex"] img {
        width: 100% !important;
        max-width: 340px !important;
        height: auto !important;
        margin: 0 auto !important;
    }

    /* 頁尾區塊手機版元素置中堆疊 */
    .contact-header h2 { font-size: 26px; }
    
    .contact-details { 
        font-size: 16px; 
        flex-direction: column; 
        gap: 5px; 
    }
    
    .copyright { font-size: 10px; }
    .footer-logo { font-size: 40px; }
    
    .copyright-row {
        flex-direction: column-reverse; 
        align-items: flex-start;
        gap: 8px;
        margin-top: -5px;
    }

    /* 英文版微調 */
    html[lang="en"] .logo-text { font-size: 18px; }
    html[lang="en"] .footer-email {
        font-size: 16px;
    }
}