/* 基本樣式和全域設定 */
body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #eef3f7;
    color: #444;
}

.main-container {
    max-width: 900px;
    margin: 20px auto;
    padding: 0 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

h2 {
    font-size: 20px;
    font-weight: 500;
    color: #2e7d32;
    border-bottom: none;
    margin-top: 0;
    margin-bottom: 15px;
    background-color: #e8f5e9;
    padding: 10px 15px;
    border-radius: 5px;
}

h3 {
    font-size: 18px;
    font-weight: 500;
    color: #2e7d32;
    margin: 0;
}

p, ul {
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 10px 0;
}

a {
    color: #007bff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.card {
    background-color: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    width: 100%;
}

/* 導航列 */
.header {
    background-color: #4CAF50;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 10px 0;
}

.header-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: white;
    margin: 0;
}

.nav-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 20px;
}

.nav-menu a {
    color: white;
    font-size: 14px;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.nav-menu a:hover {
    background-color: rgba(255, 255, 255, 0.2);
    text-decoration: none;
}

.hamburger-menu {
    display: none;
    font-size: 24px;
    color: white;
    cursor: pointer;
}

/* 主內容卡片（包含所有內容） */
.main-content-card {
    width: 100%;
    max-width: 900px;
}

/* 計算機區塊樣式 */
.calculator-section {
    max-width: 500px;
    margin: 0 auto 20px;
    padding: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    background-color: #fafafa;
}

.calculator-section .subtitle {
    margin-top: -10px;
    margin-bottom: 15px;
    font-size: 12px;
    color: #888;
}

.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    font-size: 14px;
    margin-bottom: 5px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
    color: #555;
}

.input-with-unit {
    display: flex;
    gap: 10px;
}

.input-with-unit input {
    flex-grow: 1;
}

.input-with-unit select {
    flex-grow: 1;
}

.calculate-btn {
    width: 100%;
    padding: 10px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    font-weight: 500;
    margin-top: 5px;
}

.calculate-btn:hover {
    background-color: #45a049;
}

/* 計算結果區塊 */
.result-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px 0;
    border-top: 1px solid #ddd;
    margin-top: 20px;
}

.result-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 40px;
    width: 100%;
}

.result-summary {
    flex: 1;
    min-width: 250px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.summary-item p {
    margin: 0;
    font-size: 16px;
}

.summary-item p:first-child {
    font-weight: 500;
}

/* 修復饼状图往下无限滚动 */
.chart-container {
    flex: 1;
    min-width: 250px;
    max-width: 350px;
    aspect-ratio: 1 / 1; /* 固定为正方形 */
    height: auto;        /* 由宽度决定高度 */
    overflow: hidden;    /* 防止撑开 */
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block; /* 去掉 canvas 默认的内联间隙 */
}

.table-container {
    width: 100%;
    overflow-x: auto;
}

.table-container h3 {
    margin-bottom: 10px;
    background-color: #e8f5e9;
    padding: 8px 12px;
    border-radius: 5px;
}

.table-container table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    min-width: 350px;
}

.table-container th, .table-container td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
    font-size: 14px;
}

.table-container th {
    background-color: #f2f2f2;
    font-weight: 500;
}

/* 資訊區塊 */
.info-section-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.info-section {
    margin-bottom: 0;
}

.info-section h2 {
    margin-top: 0;
}

.info-section + .info-section h2 {
    margin-top: 10px;
}

.info-section ul {
    padding-left: 20px;
    list-style-type: disc;
}

/* FAQ 區塊樣式 */
.faq-section {
    margin-top: 20px;
}

.faq-accordion {
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    margin-bottom: 15px;
    overflow: hidden;
}

.faq-accordion .question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    cursor: pointer;
    background-color: #e8f5e9;
    transition: background-color 0.3s ease;
}

.faq-accordion .question:hover {
    background-color: #dcedc8;
}

.faq-accordion .question h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #4CAF50;
    border-bottom: none;
    padding-bottom: 0;
}

.faq-accordion .question i {
    color: #4CAF50;
    font-size: 14px;
    transition: transform 0.3s ease;
}

.faq-accordion.active .question i {
    transform: rotate(45deg);
}

.faq-accordion .answer {
    max-height: 0;
    padding: 0 15px;
    transition: max-height 0.3s ease, padding 0.3s ease;
    background-color: #fff;
}

.faq-accordion.active .answer {
    max-height: 500px;
    padding: 15px;
}

.faq-accordion .answer ul {
    margin-top: 5px;
}

.faq-accordion .answer p {
    margin-bottom: 0;
}

/* 底部優化 */
.footer {
    background-color: #4CAF50;
    padding: 20px 0;
    margin-top: 20px;
    text-align: center;
    font-size: 12px;
    line-height: 1.5;
    color: white;
}

.disclaimer {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 15px;
    text-align: left;
}

.disclaimer p {
    margin-bottom: 10px;
}

/* 響應式設計 */
@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
        padding: 0;
        margin: 0;
        gap: 0;
    }

    .card {
        box-shadow: none;
        border-radius: 0;
        margin-bottom: 15px;
        padding: 20px 15px;
    }
    
    .header {
        background-color: #4CAF50;
    }
    
    .logo {
        color: white;
    }
    
    .nav-menu {
        display: none;
        width: 100%;
        position: absolute;
        top: 48px;
        left: 0;
        padding: 10px 0;
        background-color: #3e8e41;
    }

    .nav-menu.show {
        display: block;
    }
    
    .nav-menu ul {
        flex-direction: column;
        gap: 0;
    }

    .nav-menu li {
        width: 100%;
    }

    .nav-menu a {
        display: block;
        padding: 12px 20px;
        color: white;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .nav-menu a:hover {
        background-color: #4CAF50;
    }
    
    .nav-menu li:last-child a {
        border-bottom: none;
    }
    
    .hamburger-menu {
        display: block;
        color: white;
    }
    
    /* 手機端排版調整 */
    .calculator-section {
        width: 100%;
        max-width: 500px;
        margin: 0 auto 20px;
        padding: 20px;
        border: 1px solid #e0e0e0;
        border-radius: 5px;
        background-color: #fafafa;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        box-sizing: border-box; /* 確保邊框和內邊距不造成溢出 */
    }

    .calculator-section .subtitle {
        margin-bottom: 10px;
    }

    .form-group {
        width: 100%;
        max-width: 300px;
        margin: 0 auto 10px; /* 新增: 水平置中 */
    }

    .form-group input,
    .form-group select {
        width: 100%;
    }

    .input-with-unit {
        flex-direction: column;
        gap: 0;
    }
    
    .input-with-unit input,
    .input-with-unit select {
        width: 100%;
        margin-bottom: 10px;
        box-sizing: border-box;
    }

    .input-with-unit select {
        margin-bottom: 0;
    }

    .result-container {
        flex-direction: column;
        gap: 20px;
        align-items: center; /* 修復: 確保子元素垂直堆疊並置中 */
        justify-content: center;
        width: 100%;
    }

    .result-summary, .chart-container {
        min-width: unset;
        width: 100%;
    }
    
    /* 新增樣式 */
    .chart-container h3 {
        text-align: center;
        margin-bottom: 15px;
    }

    .chart-container {
        max-width: 300px;
    }
    
    .info-section-container {
        width: 100%;
        padding: 0;
    }
    
    .info-section h2,
    .table-container h3 {
        border-radius: 0;
        padding: 10px 0;
        text-align: center;
        margin-bottom: 10px;
    }

    .table-container {
        overflow-x: auto;
    }

    .table-container table {
        min-width: 350px;
    }

    .faq-accordion {
        border: none;
        padding: 0;
    }

    .faq-accordion .question {
        padding: 10px;
        border-bottom: 1px solid #ddd;
    }

    .faq-accordion .answer {
        padding-left: 0;
        border-left: none;
    }

    .footer {
        margin-top: 0;
        background-color: #4CAF50;
        color: white;
    }
}
.btn.btn-success {
    display: inline-block;
    margin-top: 10px;
    padding: 10px 15px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.2s;
}

.btn.btn-success:hover {
    background-color: #45a049;
    text-decoration: none;
}