/* 財報分析工具樣式表 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft JhengHei', '微軟正黑體', 'PingFang TC', 'Apple LiGothic Medium', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    padding: 0;
    font-size: 16px;
    line-height: 1.6;
}

strong {
    font-weight: 900;
}

/* 表格中的粗體項目 */
table td strong {
    font-weight: 900;
    font-size: 16px;
    color: #202124;
}

.main-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header 樣式 */
.header {
    background: linear-gradient(to right, #1a1d29, #2d3142);
    padding: 0;
    margin-bottom: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo h1 {
    color: #ffffff;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin: 0;
}

.header-nav {
    display: flex;
    gap: 30px;
}

.header-nav-item {
    color: #b8bdc9;
    font-size: 15px;
    text-decoration: none;
    transition: color 0.2s;
    cursor: pointer;
}

.header-nav-item:hover {
    color: #ffffff;
}

.header-bottom {
    padding: 16px 40px;
    background: rgba(255,255,255,0.03);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #8b92a5;
}

.breadcrumb-separator {
    color: #4a5064;
}

/* 搜尋區樣式 */
.search-section {
    background: white;
    padding: 30px 40px;
    border-bottom: 1px solid #e8eaed;
    margin-bottom: 0;
}

.search-box {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
    min-width: 300px;
}

.search-box input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #dadce0;
    border-radius: 2px;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: #202124;
}

.search-box input.placeholder-mode {
    color: #9aa0a6;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.search-box input::placeholder {
    color: #5f6368;
    opacity: 1;
}

.search-box input:focus::placeholder {
    color: transparent;
}

.search-box input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 1px #1a73e8;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dadce0;
    border-top: none;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.search-suggestions.show {
    display: block;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.suggestion-item:hover {
    background: #f8f9fa;
}

.suggestion-item.highlighted {
    background: #e8f0fe;
    border-left: 3px solid #1a73e8;
    padding-left: 13px;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-code {
    font-weight: 500;
    color: #202124;
    margin-right: 8px;
}

.suggestion-name {
    color: #5f6368;
    font-size: 13px;
}

.suggestion-chinese {
    color: #5f6368;
    font-size: 13px;
    margin-left: 8px;
}

.search-box button {
    padding: 12px 32px;
    background: #1a73e8;
    color: white;
    border: none;
    border-radius: 2px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    display: none; /* 隱藏查詢按鈕 */
}

.search-box button:hover {
    background: #1557b0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}

/* 分頁標籤樣式 */
.tabs-container {
    background: white;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.tabs {
    display: flex;
    background: white;
    border-bottom: 1px solid #e8eaed;
    padding: 0 24px;
}

.tab {
    flex: 1;
    padding: 16px 24px;
    text-align: center;
    cursor: pointer;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 15px;
    font-weight: 500;
    color: #5f6368;
    transition: all 0.2s;
    position: relative;
}

.tab:hover {
    background: #f8f9fa;
    color: #202124;
}

.tab.active {
    background: transparent;
    color: #1a73e8;
    border-bottom: 2px solid #1a73e8;
}

.tab-content {
    display: none;
    padding: 30px;
    animation: fadeIn 0.5s;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 資訊卡片樣式 */
.info-card {
    background: white;
    padding: 24px;
    margin: 24px 20px;
    border: 1px solid #e8eaed;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.info-card h3 {
    color: #202124;
    margin-bottom: 16px;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0.2px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.info-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.info-item label {
    display: block;
    color: #666;
    font-size: 14px;
    margin-bottom: 5px;
}

.info-item .value {
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

/* 表格樣式 */
.table-container {
    overflow-x: auto;
    margin-top: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

thead {
    background: #f8f9fa;
    color: #202124;
    border-bottom: 2px solid #e8eaed;
}

th {
    padding: 12px 16px;
    text-align: right;
    font-weight: 500;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* 第一欄標題（項目）保持左對齊 */
th:first-child {
    text-align: left;
}

/* 第二欄標題（趨勢）置中對齊 */
th:nth-child(2) {
    text-align: center;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 15px;
    color: #3c4043;
    text-align: right;
}

/* 第一欄（項目名稱）保持左對齊 */
td:first-child {
    text-align: left;
}

/* 第二欄（趨勢圖）置中對齊 */
td:nth-child(2) {
    text-align: center;
}

tbody tr:hover {
    background: #fafafa;
}

tbody tr:last-child td {
    border-bottom: none;
}

.positive {
    color: #28a745;
}

.negative {
    color: #dc3545;
}

/* 估值表單樣式 */
.valuation-form {
    background: white;
    padding: 24px;
    border: 1px solid #e8eaed;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: #202124;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dadce0;
    border-radius: 2px;
    font-size: 15px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 1px #1a73e8;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.calculate-btn {
    width: 100%;
    padding: 14px;
    background: #1a73e8;
    color: white;
    border: none;
    border-radius: 2px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.2s, box-shadow 0.2s;
}

.calculate-btn:hover {
    background: #1557b0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}

/* 結果顯示樣式 */
.result-box {
    background: white;
    padding: 24px;
    margin-top: 20px;
    border: 1px solid #e8eaed;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.result-box h3 {
    color: #202124;
    margin-bottom: 16px;
    font-size: 17px;
    font-weight: 500;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #e0e0e0;
}

.result-item:last-child {
    border-bottom: none;
    font-size: 19px;
    font-weight: 500;
    color: #1a73e8;
}

.result-label {
    color: #5f6368;
    font-size: 15px;
}

.result-value {
    color: #202124;
    font-weight: 500;
}

/* 財務比率表特殊樣式 */
#financial-ratios-table table {
    table-layout: fixed;
    width: 100%;
}

/* 第一列（項目名稱）固定寬度 */
#financial-ratios-table th:first-child,
#financial-ratios-table td:first-child {
    width: 200px;
    min-width: 200px;
}

/* 第二列（趨勢圖）固定寬度 */
#financial-ratios-table th:nth-child(2),
#financial-ratios-table td:nth-child(2) {
    width: 80px;
    min-width: 80px;
    max-width: 80px;
    text-align: center;
}

/* 其他數據列平均分配 */
#financial-ratios-table th:nth-child(n+3),
#financial-ratios-table td:nth-child(n+3) {
    width: auto;
    text-align: right;
}

#financial-ratios-table h4 {
    margin-top: 30px;
    margin-bottom: 15px;
    color: #1a73e8;
    font-size: 16px;
    font-weight: 600;
    padding-left: 4px;
    border-left: 3px solid #1a73e8;
}

#financial-ratios-table h4:first-of-type {
    margin-top: 0;
}

/* 圖表佔位樣式 */
.chart-placeholder {
    background: #fafafa;
    height: 400px;
    border: 1px solid #e8eaed;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5f6368;
    font-size: 14px;
    margin-top: 20px;
}

/* 股票資訊樣式 */
.stock-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stock-info-item {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 2px;
    text-align: center;
    border: 1px solid #e8eaed;
}

.stock-info-item .label {
    color: #5f6368;
    font-size: 12px;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stock-info-item .value {
    color: #202124;
    font-size: 18px;
    font-weight: 500;
}

/* 增率樣式 */
.growth-rate-positive {
    color: #34a853;  /* 淺綠色 */
    font-weight: 500;
}

.growth-rate-negative {
    color: #ea4335;  /* 淺紅色 */
    font-weight: 500;
}

.growth-rate-na {
    color: #999;
    font-size: 0.9em;
}

.growth-rate-options {
    display: flex;
    align-items: center;
    gap: 10px;
}

.growth-rate-options label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: #5f6368;
    user-select: none;
}

.growth-rate-options input[type="checkbox"] {
    cursor: pointer;
}
/* ==================== 估值模型樣式 ==================== */

/* 估值參數表格 */
.valuation-params-table {
    background: white;
    margin-bottom: 20px;
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.valuation-params-table table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

/* 保持前兩欄寬度一致，並設最小寬度防止跑版 */
.valuation-params-table table th:first-child,
.valuation-params-table table td:first-child,
.valuation-result-table table th:first-child,
.valuation-result-table table td:first-child {
    width: 250px;
    min-width: 250px;
}

.valuation-params-table table th:nth-child(2),
.valuation-params-table table td:nth-child(2) {
    width: 140px;
    min-width: 140px;
}

/* 結果表格的第二欄（起始年）與其他年度等分寬度 */
.valuation-result-table table th:nth-child(2),
.valuation-result-table table td:nth-child(2) {
    width: auto;
}

.valuation-params-table thead th {
    background: #007ACC;
    color: #ffffff;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #007ACC;
}

/* 公司名稱欄位的特殊樣式 */
.valuation-params-table thead th#companyName {
    color: #1e293b;  /* 深色文字 */
}

.valuation-params-table thead th:first-child {
    border-top-left-radius: 8px;
}

.valuation-params-table tbody td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.valuation-params-table .param-label {
    font-weight: 600;
    color: #1e293b;
    background: #f1f5f9;
    white-space: nowrap;
    width: 250px;
    min-width: 250px;
}

.valuation-params-table .param-value {
    background: #fef9c3;
    text-align: center;
    font-weight: 600;
    color: #713f12;
    white-space: nowrap;
}

.valuation-params-table .param-note {
    color: #475569;
    font-size: 13px;
    padding-left: 20px;
    text-align: left;
}

.valuation-params-table input[type="number"],
.valuation-params-table input[type="text"] {
    border: 1px solid #dadce0;
    padding: 8px 12px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    border-radius: 2px;
}

.valuation-params-table input[type="number"]:focus,
.valuation-params-table input[type="text"]:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 1px #1a73e8;
}

.valuation-params-table input[type="number"][data-gray-mode="true"],
.valuation-params-table input[type="text"][data-gray-mode="true"] {
    color: #999;
}

/* 起始年度行上方的虛線分隔 */
.valuation-params-table tbody tr:nth-child(6) td {
    border-top: 2px dashed #cbd5e1;
    padding-top: 16px;
}

/* 移除數字輸入框的上下箭頭 */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* EPS輸入框樣式 */
.eps-input {
    border: 1px solid #dadce0;
    padding: 8px 12px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    border-radius: 2px;
    width: 80px;
    background: #fff;
}

.eps-input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 1px #1a73e8;
}

.eps-input[data-gray-mode="true"] {
    color: #999;
}

/* 估值結果表格 */
.valuation-result-table {
    background: white;
    margin-top: 20px;
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.valuation-result-table table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

.valuation-result-table thead th {
    background: #007ACC;
    color: #ffffff;
    padding: 10px 8px;
    text-align: center;
    font-weight: 600;
    border: 1px solid #007ACC;
    font-size: 13px;
}

/* 年份輸入框樣式 */
.valuation-result-table thead th input[type="number"] {
    border: 1px solid #007ACC;
    padding: 6px 8px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    border-radius: 2px;
    background: #ffe6cc;
    color: #1e293b;
}

.valuation-result-table thead th input[type="number"]:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 1px #1a73e8;
}

.valuation-result-table thead tr:first-child th:first-child {
    border-top-left-radius: 8px;
}

.valuation-result-table thead tr:first-child th:last-child {
    border-top-right-radius: 8px;
}

.valuation-result-table tbody td {
    padding: 10px 8px;
    border: 1px solid #e2e8f0;
    text-align: center;
    font-size: 14px;
    color: #0f172a;
}

.valuation-result-table .row-label {
    background: #f1f5f9;
    font-weight: 600;
    text-align: left;
    padding-left: 12px;
    white-space: nowrap;
    color: #1e293b;
}

/* 最終結果表格 */
.valuation-final-result {
    background: white;
    margin-top: 20px;
    border: 1px solid #e8eaed;
    overflow-x: auto;
}

.valuation-final-result table {
    width: 100%;
    border-collapse: collapse;
}

.valuation-final-result tbody td {
    padding: 12px;
    border-bottom: 1px solid #e8eaed;
}

.valuation-final-result .result-label {
    font-weight: 500;
    color: #202124;
    background: #f8f9fa;
    width: 300px;
    padding-left: 16px;
}

.valuation-final-result .result-value {
    font-weight: 600;
    color: #1a73e8;
    text-align: right;
    font-size: 16px;
    padding-right: 16px;
}

.valuation-final-result input[type="number"] {
    border: 1px solid #dadce0;
    padding: 8px 12px;
    font-size: 15px;
    text-align: center;
    border-radius: 2px;
    width: 100px;
}

/* EPS趨勢圖容器 */
.chart-container {
    background: white;
    margin-top: 20px;
    padding: 20px;
    border: 1px solid #e8eaed;
    min-height: 400px;
}

#epsChart {
    max-width: 100%;
    height: 400px;
}