/* =================================================================== */
/* === [IntelligentIV] 5.0 終極整合版：全站寬度解鎖與卡片優化 === */
/* =================================================================== */

/* --- 1. 頁首導覽列：品牌化與貼頂 --- */
#masthead .hgroup { display: none !important; }
#masthead {
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    height: auto !important;
    min-height: 0 !important;
}
.main-navigation {
    background: linear-gradient(180deg, #1a202c 0%, #11141d 100%) !important;
    border-bottom: 2px solid #2d3748 !important;
    margin: 0 !important;
}
.main-navigation ul { margin: 0 !important; padding-left: 15px !important; }
.main-navigation ul li a { 
    color: #e2e8f0 !important; 
    font-weight: 600 !important;
    padding: 18px 25px !important; 
}

/* --- 2. 容器寬度極限解鎖 --- */
body.page-template-template-vip_analysis #page-wrapper,
body.page-template-template-vip_analysis .full-container,
body.page-template-template-vip_home #page-wrapper,
body.page-template-template-vip_home .full-container,
body.page-template-template-ai_analysis_page #page-wrapper,
body.page-template-template-ai_analysis_page .full-container {
    width: 100% !important;
    max-width: none !important;     
    margin: 0 !important;           
    padding-top: 0 !important;
}

body.page-template-template-vip_analysis #main,
body.page-template-template-vip_home #main,
body.page-template-template-ai_analysis_page #main {
    padding-top: 5px !important;
    padding-bottom: 10px !important;
    padding-left: 15px !important;  
    padding-right: 15px !important;
}

body.page-template-template-vip_analysis #primary,
body.page-template-template-vip_home #primary,
body.page-template-template-ai_analysis_page #primary {
    width: 100% !important;
    float: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* --- 3. 強化卡片化設計 (AI 摘要區域同步) --- */
#left-column, #right-column,
body.page-template-template-vip_analysis .entry-content > div:first-child,
#ai_content_area {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;    
    padding: 12px 15px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
    box-sizing: border-box !important;
}

#ai_content_area {
    font-size: 16px !important;
    line-height: 1.6 !important;
    color: #2d3748 !important;
    max-width: 1600px !important; 
    margin: 10px auto !important;
}

.entry-header, .entry-content > *:first-child {
    margin-top: 5px !important;
}


/* =================================================================== */
/* === [IntelligentIV] 鈴鐺選單穩定修復：防止文字截斷與右側對齊 === */
/* =================================================================== */

.sub-dropdown {
    position: relative !important;
    display: inline-block !important;
}
.sub-dropdown-content {
    display: none !important;
    position: absolute !important;
    top: 100% !important;
    right: 0 !important;          /* 靠右對齊，往左展開 */
    left: auto !important;
    background-color: #ffffff !important;
    min-width: 160px !important;  
    box-shadow: 0px 8px 16px rgba(0,0,0,0.2) !important;
    z-index: 9999 !important;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    text-align: left !important;
}
.sub-dropdown-content a {
    white-space: nowrap !important; /* 防止文字換行 */
    padding: 10px 15px !important;
    display: block !important;
    text-decoration: none !important;
    color: #333 !important;
    border-bottom: 1px solid #eee !important;
}
.signal-table td {
    overflow: visible !important; /* 允許選單超出表格 */
}
.sub-dropdown:hover .sub-dropdown-content {
    display: block !important;
}


/* =================================================================== */
/* === [VIP 戰情中心 - 首頁] 完美復刻與緊緻化 === */
/* =================================================================== */

/* 1. 左右區塊距離壓縮 */
body.page-template-template-vip_home .entry-content {
    display: flex !important;
    gap: 15px !important; 
    justify-content: center;
    align-items: flex-start;
}

/* 2. VIP 首頁頁籤 (Tabs) 完美復刻 (帶底線、透明背景) */
body.page-template-template-vip_home .vip-home-tabs {
    display: flex !important;
    border-bottom: 2px solid #ddd !important; 
    margin-bottom: 12px !important;
}
body.page-template-template-vip_home .vip-home-tab-btn {
    padding: 6px 14px !important;     
    background: transparent !important; 
    border: none !important;
    border-bottom: 3px solid transparent !important; 
    font-size: 14px !important;       
    color: #666 !important;
    cursor: pointer !important;
    outline: none !important;
    margin-right: 5px !important;     
    border-radius: 5px 5px 0 0 !important;
    height: auto !important;          
}
body.page-template-template-vip_home .vip-home-tab-btn:hover {
    color: #3182CE !important;
    background-color: #f9f9f9 !important;
}
body.page-template-template-vip_home .vip-home-tab-btn.active {
    color: #3182CE !important;
    border-bottom: 3px solid #3182CE !important; 
    background-color: #ffffff !important;
    font-weight: bold !important;
}

/* 3. 左側：表格間距與標籤縮小 */
body.page-template-template-vip_home table th,
body.page-template-template-vip_home table td {
    padding: 12px 6px !important;
    vertical-align: middle !important;
    font-size: 14px !important;
}
body.page-template-template-vip_home .signal-tag,
body.page-template-template-vip_home .tag-pos,
body.page-template-template-vip_home .tag-neg {
    padding: 6px 12px !important;
    font-size: 13px !important; 
    line-height: 1.2 !important;
    border-radius: 4px !important;
}
body.page-template-template-vip_home .sub-btn {
    padding: 4px 10px !important;
    font-size: 14px !important;
    height: auto !important;
}

/* 4. 右側：監控清單元件壓縮 */
body.page-template-template-vip_home .vip-sidebar h3 {
    margin-top: 0 !important;
    margin-bottom: 12px !important;
    padding-bottom: 8px !important;
    font-size: 18px !important; 
}
body.page-template-template-vip_home .add-stock-fields {
    margin-bottom: 10px !important;
    gap: 5px !important;
}
body.page-template-template-vip_home .add-stock-fields input,
body.page-template-template-vip_home .add-stock-fields select,
body.page-template-template-vip_home .vip-sidebar button {
    padding: 6px 10px !important;
    font-size: 13px !important;
    height: 36px !important; 
    margin-bottom: 0 !important;
}
body.page-template-template-vip_home .vip-sidebar details summary {
    padding: 8px 10px !important;
    font-size: 14px !important;
}
body.page-template-template-vip_home .vip-sidebar details li {
    padding: 6px 10px !important; 
}


/* =================================================================== */
/* === [VIP 分析頁面] 終極緊緻版面優化 (無敵 ID 鎖定版) === */
/* =================================================================== */

/* 1. 壓縮最上方的「輸入框」與「標籤」 */
input[id^="stock_id_"] {
    padding: 4px 8px !important;
    height: 34px !important;
    font-size: 14px !important;
    margin-bottom: 0 !important;
}
label[for^="stock_id_"] {
    font-size: 13px !important;
    margin-bottom: 2px !important;
    line-height: 1.2 !important;
    font-weight: bold !important;
}

/* 2. 壓縮所有的頁籤框框 (績效、風險 等 Tabs) */
#results-container .tabs-nav {
    display: flex !important; 
    list-style: none !important; 
    padding: 0 !important;
    border-bottom: 2px solid #edf2f7 !important; 
    margin-bottom: 15px !important; 
}
#results-container .tab-item {
    padding: 6px 16px !important; 
    font-size: 14px !important;   
    line-height: 1.2 !important;
    cursor: pointer; 
    background: #f7fafc !important;
    margin-right: 5px !important; 
    border: 1px solid #e2e8f0 !important; 
    border-bottom: none !important; 
    border-radius: 6px 6px 0 0 !important; 
    font-weight: bold;
    color: #4A5568;
}
#results-container .tab-item.active { 
    background: #3182CE !important; 
    color: #fff !important; 
    border-color: #3182CE !important; 
}
#results-container .tab-pane { display: none !important; }
#results-container .tab-pane.active { display: block !important; }

/* 3. 區塊標題與說明文字 */
#results-container .vip-section-title {
    margin: 10px 0 8px 0 !important;
    font-size: 16px !important;
    color: #333;
    font-weight: bold;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px !important;
}
#results-container .vip-section-desc p {
    font-size: 13px !important;
    color: #555;
    line-height: 1.4 !important;
    margin-bottom: 8px !important;
}

/* 4. 圖表容器與 Canvas 高度壓扁 (左右側圖表通殺) */
#results-container .vip-chart-area,
#results-container .tab-pane canvas {
    width: 100%;
    height: 350px !important; 
    max-height: 350px !important;
    position: relative;
    margin-bottom: 10px !important;
}
#results-container .vip-chart-area.short-chart {
    height: 250px !important;
}

/* 5. 分隔線留白縮減 */
#results-container hr.vip-divider {
    border-top: 1px dashed #ccc;
    margin: 15px 0 !important; 
    border-bottom: none;
    height: 0;
}


/* =================================================================== */
/* === 共用：按鈕樣式壓縮與 Tooltip 最高層級修正 === */
/* =================================================================== */

#analyze_button,
#ai_report_button,
#add_to_watchlist_btn {
    background: #828f9f !important; 
    color: #ffffff !important;
    border: 0px solid #4e555b !important;
    border-radius: 3px !important;
    box-shadow: none !important;
    text-shadow: none !important;
    height: 34px !important;         
    padding: 0 12px !important;      
    font-size: 13px !important;      
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}
#analyze_button:hover,
#ai_report_button:hover,
#add_to_watchlist_btn:hover {
    background: #5a6268 !important;
}

.tooltip-container {
    position: relative;
    display: inline-block;
    z-index: 30; 
    cursor: help; 
    border-bottom: 1px dotted #666; 
}
.tooltip-container .tooltip-text {
    visibility: hidden;
    width: 220px;
    background-color: #888;
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 10px;
    font-size: 14px;
    line-height: 1.5;
    position: absolute;
    z-index: 9999 !important; 
    bottom: 125%; 
    left: 50%;
    margin-left: -110px; 
    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* --- Debug 專用：保證垂直高度充足，日期不被切斷 --- */
/* --- 確保圖表垂直日期顯示與水平不被截斷 --- */

/* 1. 給圖表容器固定高度 400px (JS畫布360px + 底部日期40px) */
body.page-template-template-vip_home div[id^="chart_"] {    
    width: 100% !important;
    overflow: visible !important; /* 絕對不能是 hidden */
}

/* 2. 給 scan-content 留出底部 Padding，避免切到日期文字 */
body.page-template-template-vip_home .scan-content {
    padding-bottom: 15px !important; 
    overflow: visible !important;
}

/* 3. 解除可能殘留的捲軸與高度限制 */
#macro-charts-container, .scan-item {
    max-height: none !important;
    overflow: visible !important;
}

/* =================================================================== */
/* === 調整 VIP 首頁左右區塊比例 (左側放大，右側縮小) === */
/* =================================================================== */
/*
@media (min-width: 1000px) {
    /* 左側主視窗 (圖表與掃描)：佔據大約 68% 的空間 */
    .vip-dashboard-flex-container > .vip-dashboard-item:nth-child(1) {
        flex: 6.5 !important;
        width: auto !important; 
    }

    /* 右側側邊欄 (監控清單)：佔據大約 32% 的空間 */
    .vip-dashboard-flex-container > .vip-dashboard-item:nth-child(2) {
        flex: 3.5 !important;
        width: auto !important; 
    }