/* =============================================
   Main Stylesheet - Jingwei Corporate Website
   ============================================= */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", Arial, Helvetica, sans-serif;
    line-height: 1.7;
    color: #333;
    background: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--color-primary); text-decoration: none; transition: color .25s, background .25s; }
a:hover { color: var(--color-secondary); }
ul, ol { list-style: none; }
table { border-collapse: collapse; width: 100%; }
h1, h2, h3, h4, h5, h6 { line-height: 1.3; font-weight: 700; color: #1a1a1a; }
h1 { font-size: 2rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }
p { margin-bottom: 1em; }

.item-link{
    width:100%;
    height:100%;
    font-size:0px;
    position:absolute;
    top:0;
    bottom:0;
    left:0;
    right:0;
    z-index:30;
	}

/* --- Layout --- */
.site-main { flex: 1; }
.section { padding: 60px 0; }

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 10px 28px;
    font-size: .95rem;
    font-weight: 600;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    text-align: center;
    transition: all .25s;
}
.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); color: #fff; }
.btn-outline { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline:hover { background: var(--color-primary); color: #fff; }

/* --- Header --- */
.mainHeader{
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
}
.site-logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: 1px;
}
.site-logo:hover { color: var(--color-secondary); }

/* Language Switcher */
.lang-switcher { display: flex; gap: 8px; margin-right: 16px; }
.lang-link {
    padding: 4px 10px;
    border-radius: 3px;
    font-size: .85rem;
    color: #555;
    border: 1px solid #ddd;
}
.lang-link:hover, .lang-link.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* Navigation */
.main-nav { flex: 1; }
.nav-list { display: flex; gap: 4px; justify-content: flex-end; }
.nav-item { position: relative; }
.nav-link {
    display: block;
    padding: 8px 16px;
    font-size: .95rem;
    font-weight: 500;
    color: #333;
    border-radius: 4px;
}
.nav-link:hover { color: var(--color-primary); background: #f0f4f8; }
.has-dropdown .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    padding: 6px 0;
    z-index: 100;
}
.has-dropdown:hover .dropdown-menu { display: block; }
.dropdown-item a {
    display: block;
    padding: 8px 18px;
    font-size: .9rem;
    color: #444;
}
.dropdown-item a:hover { background: #f0f4f8; color: var(--color-primary); }

/* Mobile Toggle */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
}
.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: #333;
    border-radius: 2px;
    transition: .3s;
}

/* --- Page Banner (sub-pages) --- */
.page-banner {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: #fff;
    padding: 50px 0 40px;
    text-align: center;
}
.page-banner h1 { color: #fff; font-size: 2rem; margin-bottom: 8px; }
.page-subtitle { color: rgba(255,255,255,.8); font-size: 1.05rem; }

/* --- Banner (Homepage) --- */
.bannerSection { position: relative; }
.banner-slider { position: relative; overflow: hidden; min-height: 300px; background: #f0f0f0; }
.banner-slide {
    display: none;
    position: absolute;
    inset: 0;
}
.banner-slide.active { display: block; position: relative; }
.banner-slide img { width: 100%; height: 100%; object-fit: cover; }
.banner-caption {
    position: absolute;
    bottom: 40px;
    left: 0;
    right: 0;
    text-align: center;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.banner-caption h2 { color: #fff; font-size: 2.2rem; }
.banner-placeholder {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: #fff;
    padding: 80px 0;
    text-align: center;
}
.banner-placeholder h1 { color: #fff; font-size: 2.4rem; }
.banner-placeholder p { color: rgba(255,255,255,.85); font-size: 1.1rem; }

/* --- Product Grid --- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}
.product-card {
    position: relative;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    overflow: hidden;
    transition: box-shadow .25s, transform .25s;
}
.product-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.1); transform: translateY(-2px); }
.product-card a { color: inherit; }
.product-card a:hover { color: inherit; }
.product-image { aspect-ratio: 4/3; overflow: hidden; background: #f5f5f5; }
.product-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.product-card:hover .product-image img { transform: scale(1.05); }
.product-info { padding: 16px; }
.product-info h3 { font-size: 1rem; margin-bottom: 4px; }
.product-subtitle { font-size: .85rem; color: #777; margin: 0; }
.product-desc { font-size: .88rem; color: #666; margin: 6px 0 0; }

/* Section header / footer */
.section-header { text-align: center; margin-bottom: 36px; }
.section-header h2 { position: relative; display: inline-block; }
.section-header h2::after {
    content: '';
    display: block;
    width: 50px;
    height: 3px;
    background: var(--color-primary);
    margin: 10px auto 0;
    border-radius: 2px;
}
.section-footer { text-align: center; margin-top: 36px; }

/* --- Product Layout (list page) --- */
.product-list-section { padding: 50px 0; }
.product-layout { display: flex; gap: 30px; }
.product-sidebar { width: 240px; flex-shrink: 0; }
.product-sidebar h3 { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--color-primary); }
.category-list { }
.category-item { margin-bottom: 2px; }
.category-item a {
    display: block;
    padding: 10px 14px;
    border-radius: 4px;
    color: #444;
    font-size: .93rem;
}
.category-item a:hover { background: #f0f4f8; color: var(--color-primary); }
.category-item.active > a { background: var(--color-primary); color: #fff; font-weight: 600; }
.category-sub { padding-left: 16px; }
.category-sub li a { padding: 7px 14px; font-size: .88rem; }
.category-sub li.active a { color: var(--color-primary); font-weight: 600; }
.product-main { flex: 1; min-width: 0; }

/* --- Product Detail --- */
.product-detail { padding: 40px 0 60px; }
.product-detail-layout { display: flex; gap: 40px; margin-bottom: 40px; }
.product-gallery { width: 50%; flex-shrink: 0; }
.product-main-image { border-radius: 6px; overflow: hidden; background: #f5f5f5; }
.product-main-image img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.product-thumbs { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.product-thumb {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border: 2px solid #e5e5e5;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color .2s;
}
.product-thumb:hover { border-color: var(--color-primary); }
.product-info-detail { flex: 1; }
.product-info-detail h1 { font-size: 1.6rem; margin-bottom: 14px; }
.product-short-desc { color: #555; margin-bottom: 20px; line-height: 1.8; }
.product-variants { margin-bottom: 24px; }
.product-variants h3 { margin-bottom: 10px; }
.variant-table { border: 1px solid #e5e5e5; border-radius: 4px; overflow: hidden; }
.variant-table th { background: #f0f4f8; padding: 10px 14px; text-align: left; font-size: .9rem; font-weight: 600; }
.variant-table td { padding: 10px 14px; border-top: 1px solid #eee; font-size: .9rem; }
.product-cta { margin-top: 24px; }
.product-detail-content { margin-top: 40px; }

/* --- Breadcrumb --- */
.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: .88rem;
    color: #888;
    margin-bottom: 24px;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}
.breadcrumb a { color: var(--color-primary); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .separator { color: #ccc; }
.breadcrumb .current { color: #555; }

/* --- News / Tech List --- */
.news-list, .tech-list { display: flex; flex-direction: column; gap: 24px; }
.news-card, .tech-card { position: relative; background: #fff; border: 1px solid #e8e8e8; border-radius: 6px; overflow: hidden; }
.news-card-inner, .tech-card-inner { display: flex; }
.news-image, .tech-image { width: 260px; flex-shrink: 0; }
.news-image img, .tech-image img { width: 100%; height: 100%; object-fit: cover; min-height: 180px; }
.news-content, .tech-content { padding: 24px; flex: 1; }
.news-date { font-size: .85rem; color: #999; display: block; margin-bottom: 6px; }
.news-title, .tech-title { font-size: 1.15rem; margin-bottom: 8px; }
.news-title a, .tech-title a { color: #1a1a1a; }
.news-title a:hover, .tech-title a:hover { color: var(--color-primary); }
.news-excerpt, .tech-excerpt { font-size: .92rem; color: #666; margin-bottom: 12px; }
.tech-meta { font-size: .85rem; color: #999; margin-bottom: 10px; }
.read-more { font-size: .9rem; font-weight: 600; color: var(--color-primary); }
.read-more:hover { color: var(--color-secondary); }

/* --- Article Detail (news/tech shared) --- */
.article-detail { max-width: 860px; margin: 0 auto; }
.article-header { margin-bottom: 28px; }
.article-header h1 { font-size: 1.8rem; margin-bottom: 8px; }
.article-subtitle { font-size: 1.05rem; color: #666; margin-bottom: 10px; }
.article-meta { font-size: .88rem; color: #999; display: flex; gap: 16px; flex-wrap: wrap; }
.article-cover { margin-bottom: 28px; border-radius: 6px; overflow: hidden; }
.article-cover img { width: 100%; }
.article-body { line-height: 1.9; font-size: 1rem; }
.article-body img { border-radius: 4px; margin: 16px 0; }
.article-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 28px; }
.gallery-item img { border-radius: 4px; width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.article-nav { margin-top: 36px; padding-top: 24px; border-top: 1px solid #eee; }

/* --- Rich Text (CMS content) --- */
.rich-text { line-height: 1.9; color: #444; }
.rich-text h2, .rich-text h3 { margin: 20px 0 10px; }
.rich-text p { margin-bottom: 12px; }
.rich-text img { border-radius: 4px; margin: 12px 0; }
.rich-text ul, .rich-text ol { padding-left: 24px; margin-bottom: 12px; }
.rich-text ul { list-style: disc; }
.rich-text ol { list-style: decimal; }
.rich-text a { color: var(--color-primary); text-decoration: underline; }
.rich-text table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.rich-text th, .rich-text td { border: 1px solid #e5e5e5; padding: 8px 12px; vertical-align: top; }
.rich-text th { background: #f8f9fa; font-weight: 600; }
.rich-text iframe.rich-editor-video,
.rich-text iframe { max-width: 100%; border: none; border-radius: 4px; }

/* --- Content Block --- */
.content-block { max-width: 860px; margin: 0 auto; }
.content-block h2 { text-align: center; margin-bottom: 24px; }

/* --- About Sections --- */
.about-intro, .about-history, .about-team { border-bottom: 1px solid #f0f0f0; }
.about-articles .article-list { max-width: 860px; margin: 0 auto; }
.article-item { position: relative; padding: 20px 0; border-bottom: 1px solid #f0f0f0; }
.article-item:last-child { border-bottom: none; }
.article-item h3 { margin-bottom: 6px; }
.article-item p { color: #666; font-size: .93rem; margin: 0; }

/* --- Text Block (index) --- */
.text-block { border-bottom: 1px solid #f0f0f0; }
.text-content { max-width: 860px; margin: 0 auto; }

/* --- Contact --- */
.contact-layout { display: flex; gap: 40px; }
.contact-form-wrapper { flex: 1; }
.contact-form-wrapper h2 { margin-bottom: 20px; }
.contact-info-wrapper { width: 380px; flex-shrink: 0; }
.contact-info-block h2 { margin-bottom: 14px; }
.contact-map { margin-top: 20px; border-radius: 6px; overflow: hidden; }
.contact-map iframe { width: 100%; min-height: 260px; border: 0; }

/* Form */
.contact-form { }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 6px; color: #333; }
.required { color: var(--color-secondary); }
.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d5d5d5;
    border-radius: 4px;
    font-size: .95rem;
    font-family: inherit;
    transition: border-color .25s;
}
.form-group input:focus,
.form-group textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb), .12); }
.btn-submit { width: 100%; padding: 12px; font-size: 1rem; }
.form-message { padding: 12px 16px; border-radius: 4px; margin-top: 12px; font-size: .92rem; }
.form-message.success { background: #eafaf1; color: #1e8449; border: 1px solid #a9dfbf; }
.form-message.error { background: #fdedec; color: var(--color-secondary); border: 1px solid #f5b7b1; }

/* --- FAQ --- */
.faq-list { max-width: 860px; margin: 0 auto; }
.faq-item { position: relative; border: 1px solid #e8e8e8; border-radius: 6px; margin-bottom: 10px; overflow: hidden; }
.faq-item.active { border-color: var(--color-primary); }
.faq-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 16px 20px;
    background: #fff;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    text-align: left;
    font-family: inherit;
    transition: background .2s;
}
.faq-question:hover { background: #f7f9fb; }
.faq-item.active .faq-question { color: var(--color-primary); }
.faq-icon { font-size: 1.4rem; font-weight: 300; color: #999; flex-shrink: 0; margin-left: 12px; }
.faq-answer { padding: 0 20px 16px; }

/* --- Pagination --- */
.pagination { margin-top: 30px; text-align: center; }
.pagination a, .pagination span {
    display: inline-block;
    padding: 6px 14px;
    margin: 0 3px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: .9rem;
    color: #555;
}
.pagination a:hover { background: #f0f4f8; border-color: var(--color-primary); color: var(--color-primary); }
.pagination .current, .pagination .active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* --- Empty State --- */
.empty-state { text-align: center; padding: 60px 20px; color: #999; font-size: 1.05rem; }

/* --- Footer --- */
.site-footer {
    background: #2c3e50;
    color: rgba(255,255,255,.7);
    padding: 30px 0;
    margin-top: auto;
    background-size: cover;
    background-position: center;
}
.footer-inner { display: flex; justify-content: space-between; align-items: center; }
.footer-brand { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.footer-brand p { margin: 0; font-size: .88rem; }
.footer-logo-link { display: inline-flex; }
.footer-logo-img { height: 42px; max-width: 180px; object-fit: contain; }
.footer-links { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.footer-links a { color: rgba(255,255,255,.7); font-size: .88rem; }
.footer-links a:hover { color: #fff; }
.footer-admin-link { opacity: .35; font-size: .8rem !important; transition: opacity .25s; }
.footer-admin-link:hover { opacity: 1; }
.footer-edit-btn {
    background: rgba(255,255,255,.12);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: .75rem;
    line-height: 1;
    padding: 4px 7px;
    cursor: pointer;
    opacity: .5;
    transition: opacity .25s;
}
.footer-edit-btn:hover { opacity: 1; }

/* --- Admin Login Modal --- */
.admin-login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.admin-login-modal {
    position: relative;
    background: #fff;
    border-radius: 10px;
    width: 380px;
    max-width: 92vw;
    padding: 36px 32px 28px;
    box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.admin-login-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    line-height: 1;
}
.admin-login-close:hover { color: #333; }
.admin-login-title {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 24px;
}
.admin-login-field { margin-bottom: 16px; }
.admin-login-field label {
    display: block;
    font-size: .88rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 6px;
}
.admin-login-field input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d5d5d5;
    border-radius: 5px;
    font-size: .95rem;
    font-family: inherit;
    transition: border-color .25s;
}
.admin-login-field input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb), .12);
}
.admin-login-error {
    padding: 10px 14px;
    border-radius: 5px;
    font-size: .88rem;
    color: var(--color-secondary);
    background: #fdedec;
    border: 1px solid #f5b7b1;
    margin-bottom: 12px;
}
.admin-login-btn {
    width: 100%;
    padding: 11px;
    font-size: 1rem;
    margin-top: 4px;
}
.admin-login-btn:disabled {
    opacity: .6;
    cursor: not-allowed;
}

/* --- Edit Modal (Admin) --- */
.edit-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.edit-modal {
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 960px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.edit-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid #e5e5e5;
}
.edit-modal-title { font-weight: 700; font-size: 1.05rem; }
.edit-modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: #888;
    line-height: 1;
}
.edit-modal-close:hover { color: #333; }
.edit-modal-body { flex: 1; overflow: auto; }
.edit-modal-iframe { width: 100%; height: 70vh; border: none; }

/* --- Responsive --- */
@media (max-width: 992px) {
    .product-layout { flex-direction: column; }
    .product-sidebar { width: 100%; }
    .product-detail-layout { flex-direction: column; }
    .product-gallery { width: 100%; }
    .contact-layout { flex-direction: column; }
    .contact-info-wrapper { width: 100%; }
}

@media (max-width: 768px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.3rem; }
    .section { padding: 40px 0; }
    .header-inner { height: 56px; }

    /* Mobile nav */
    .nav-toggle { display: flex; }
    .main-nav {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: #fff;
        border-bottom: 1px solid #e5e5e5;
        box-shadow: 0 4px 12px rgba(0,0,0,.08);
        z-index: 999;
    }
    .main-nav.open { display: block; }
    .nav-list { flex-direction: column; padding: 10px 0; }
    .nav-link { padding: 10px 20px; }
    .has-dropdown .dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        padding-left: 20px;
    }
    .has-dropdown:hover .dropdown-menu { display: block; }

    .product-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
    .news-card-inner, .tech-card-inner { flex-direction: column; }
    .news-image, .tech-image { width: 100%; }
    .news-image img, .tech-image img { min-height: 160px; max-height: 200px; }
    .form-row { flex-direction: column; gap: 0; }
    .footer-inner { flex-direction: column; gap: 12px; text-align: center; }
    .banner-caption h2 { font-size: 1.5rem; }
    .banner-placeholder { padding: 50px 0; }
    .banner-placeholder h1 { font-size: 1.6rem; }
    .page-banner { padding: 35px 0 30px; }
    .page-banner h1 { font-size: 1.5rem; }
}

@media (max-width: 480px) {
    .product-grid { grid-template-columns: 1fr; }
    .lang-switcher { margin-right: 8px; }
    .lang-link { padding: 3px 7px; font-size: .8rem; }
}

/* --- Mobile nav toggle JS hook --- */
@media (max-width: 768px) {
    #nav-toggle.active + .main-nav,
    .main-nav.open { display: block; }
}
