/* =========================================
   Index Page Specific Styles (Dark Mode Ready)
   Depends on: common.css
   ========================================= */
/* =========================================
   Temporary Fix: Hide File Upload
   ========================================= */
#attachBtn {
    display: none !important;
}
body, html {
    margin: 0;
    padding: 0;
    /* overflow-x: hidden; <--- 建議加上這行防止橫向捲軸 */
}

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    
    /* 修改這裡：取消 center，改為 flex-start，並增加 padding-top */
    justify-content: center; 
    
    
    padding-right: 2rem;
    padding-left: 2rem;
    /* 底部留空間給 Footer (如果你用了絕對定位) */
    padding-bottom: 80px; 
    
    background-color: var(--bg-primary);
    transition: margin-left 0.3s ease;
    position: relative;
}

body.collapsed-mode .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

.content-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 26px;
}


.lang-btn {
    background: none; border: none; cursor: pointer;
    font-size: 14px; font-weight: 600; 
    
    color: var(--text-muted); /* 使用變數 */
    
    padding: 4px 8px; border-radius: 4px; transition: all 0.2s;
}
.lang-btn:hover { color: var(--primary); }

.lang-btn.active { 
    background: var(--primary); 
    color: #fff; /* 保持白字 */
}

.lang-divider { 
    color: var(--border); /* 使用變數 */
    font-size: 12px; 
}

/* =========================================
   ✅ Brand Logo 區域
   ========================================= */
.brand-section { 
    text-align: center; 
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.brand-logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 20px;
}

/* 1. 共用樣式 (兩張 Logo 都適用) */
.brand-logo-img {
    width: 450px;
    max-width: 80vw;
    height: auto;
    object-fit: contain;
    position: relative;
    z-index: 1;
    /* 這裡不需要 display: block，因為下面的 .logo-light / .logo-dark 會控制 */
}

.logo-light { display: block; }
.logo-dark  { display: none; }

[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark  { display: block; }

/* 經典綠色裝飾線 */
.brand-logo-container::after {
    content: '';
    display: block;
    width: 400px;
    height: 3px;
    
    background-color: var(--primary); /* 使用變數 */
    
    border-radius: 2px;
    opacity: 0.9;
    margin-top: -80px;
    position: relative;
    z-index: 0;
}

/* 標題樣式 */
.main-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.2rem;
    font-weight: 700;
    
    color: var(--primary-light); /* 使用變數 */
    
    margin-bottom: 10px;
    letter-spacing: -0.02em;
}

.main-subtitle {
    font-size: 1.1rem;
    
    color: var(--text-secondary); /* 使用變數 */
    
    font-weight: 400;
}

/* =========================================
   Search Box
   ========================================= */
.search-container {
    background: var(--bg-card); /* 使用變數 (深色模式變深灰) */
    border: 1px solid var(--border);
    
    border-radius: 20px;
    padding: 24px 24px 12px 24px;
    box-shadow: 0 4px 20px var(--shadow-color);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
}

.search-container:focus-within {
    border-color: var(--accent);
    box-shadow: 0 8px 30px rgba(45, 95, 63, 0.15); /* 可考慮將 rgba 變數化，目前暫保綠光 */
    transform: translateY(-2px);
}

.search-box {
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    font-size: 1.1rem;
    line-height: 1.6;
    
    color: var(--text-primary); /* 使用變數 */
    
    font-family: 'Inter', sans-serif;
    flex: 1;
    min-height: 100px;
    background: transparent; /* 確保背景透明 */
}
.search-box::placeholder { 
    color: var(--text-muted); /* 使用變數 */
    opacity: 0.6;
}

.search-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    
    border-top: 1px solid var(--border-sub); /* 使用變數 */
    
    padding-top: 12px;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-btn {
    background: none; 
    border: none; 
    cursor: pointer; 
    
    color: var(--text-muted); /* 使用變數 */
    
    padding: 8px; 
    border-radius: 50%; 
    transition: all 0.2s;
    display: flex; 
    align-items: center; 
    justify-content: center;
}
.control-btn:hover { 
    background: var(--bg-hover); /* 使用變數 */
    color: var(--primary); 
}

.footer-right { display: flex; align-items: center; gap: 12px; }
.char-count { font-size: 12px; color: var(--text-muted); }

.submit-btn {
    background: var(--accent); color: white; border: none;
    width: 36px; height: 36px; border-radius: 10px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.submit-btn:hover:not(:disabled) { background: var(--primary); transform: scale(1.05); }
.submit-btn:disabled { 
    background: var(--border); /* Disabled 狀態用邊框色或者 text-muted */
    cursor: not-allowed; 
}

/* 範例查詢 */
.examples-section { margin-top: 20px; }
.examples-header { margin-bottom: 12px; text-align: center; }
.examples-title {
    font-size: 0.9rem; 
    color: var(--text-muted); /* 使用變數 */
    text-transform: uppercase; letter-spacing: 0.05em;
    font-weight: 600;
}

.examples-list {
    display: flex;              
    flex-direction: column;     
    gap: 12px;                  
    width: 100%;                
    max-width: 100%;            
}

/* 範例項目 */
.example-item {
    background: var(--bg-card); /* 使用變數 */
    border: 1px solid var(--border-sub);
    
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.95rem;
    
    color: var(--text-secondary); /* 使用變數 */
    
    box-shadow: 0 2px 4px var(--shadow-color);
}

.example-item:hover {
    border-color: var(--accent);
    
    background: var(--bg-hover); /* 使用變數 */
    color: var(--primary);       /* 使用變數 */
    
    transform: translateX(4px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.example-icon { 
    font-size: 1.2rem;
    flex-shrink: 0;
}

.tips-section { 
    text-align: center; opacity: 0.7; font-size: 0.85rem; 
    color: var(--text-muted); 
    margin-top: 20px; 
}

/* =========================================
   Model Selector Dropdown (Updated for Descriptions & Ticks)
   ========================================= */

/* Dropdown 容器 */
.model-selector-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* Dropdown 本體 */
.model-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    
    background: var(--bg-card); /* 使用變數 */
    border: 1px solid var(--border);
    
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow-color);
    
    /* ★ 加寬寬度以容納描述文字 */
    width: 280px;
    min-width: 280px;
    z-index: 3000;
    overflow: hidden;
    animation: fadeIn 0.2s ease;
}

.model-dropdown.show { display: block; }

/* 選項樣式 */
.model-option {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-sub); /* 分隔線 */
    
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
}
.model-option:last-child { border-bottom: none; }
.model-option:hover { background-color: var(--bg-hover); }

/* ★ 新增：文字群組 (名稱 + 描述) */
.model-text-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    margin-right: 10px;
}

.model-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.model-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.3;
}

/* --- 狀態樣式 --- */

/* Active 狀態 */
.model-option.active {
    background-color: var(--bg-secondary);
    border-left: 3px solid var(--accent); /* 左側高亮條 */
}

/* 選中時名稱變色 */
.model-option.active .model-name {
    color: var(--accent);
    font-weight: 700;
}

/* 勾號圖標 (預設隱藏) */
.model-option .check-icon { 
    display: none; 
    color: #10b981; /* 鮮綠色 */
    width: 20px; 
    height: 20px;
    flex-shrink: 0;
    margin-left: 10px;
}

/* ★ 強制顯示勾號 (覆蓋 HTML inline style) */
.model-option.active .check-icon { 
    display: block !important; 
}

/* Locked (付費) 狀態 */
.model-option.locked {
    background-color: rgba(0,0,0,0.02);
    cursor: not-allowed;
    opacity: 0.8;
}

.model-option.locked .model-name {
    color: var(--text-muted);
}

.model-option.locked:hover {
    background-color: var(--bg-hover);
}

/* 鎖住時強制隱藏勾號 */
.model-option.locked .check-icon {
    display: none !important;
}

.lock-icon {
    color: var(--text-muted);
    margin-left: 10px;
    width: 16px;
    height: 16px;
}

/* Pro Badge */
.pro-badge {
    margin-left: 6px;
    flex-shrink: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   【重要修復】通用滾動與佈局修正
   適用於：手機 (Mobile) 及 矮螢幕電腦 (Short Desktop)
   解決問題：當內容高度超過螢幕時，原本的 Flex 置中會導致內容被切掉且無法滾動。
   ========================================= */

/* 定義觸發條件：螢幕寬度小於 768px (手機) 或 螢幕高度小於 850px (矮螢幕電腦) */
@media (max-width: 768px), (max-height: 850px) {
    
    /* 1. 全局解鎖：允許網頁產生捲軸 */
    html, body {
        height: auto !important;
        min-height: 100% !important;
        overflow-y: auto !important; /* 強制開啟垂直捲動 */
        -webkit-overflow-scrolling: touch; /* 手機滑動優化 */
        position: static !important;
    }

    /* 2. 佈局重置：取消垂直置中，改為自然流動 */
    .main-content {
        height: auto !important;
        min-height: 100vh; /* 保持最小全螢幕，但允許延伸 */
        
        display: block !important; /* ★ 關鍵：取消 flex，防止置中切斷內容 */
        
        padding-top: 40px; /* 頂部留白 */
        padding-bottom: 60px; /* 底部留白，方便滑動到底 */
        overflow: visible !important;
    }

    /* 3. 內容容器：讓它自然排列 */
    .content-container {
        height: auto !important;
        min-height: auto !important;
        
        display: flex;
        flex-direction: column;
        justify-content: flex-start; /* 內容從上往下排 */
        
        margin: 0 auto; /* 水平置中 */
        padding-top: 20px;
    }

    /* 4. Logo 區域間距微調 */
    .brand-section {
        margin-top: 20px;
        margin-bottom: 30px;
    }

    /* 5. 輸入框區域間距 */
    .search-section {
        margin-bottom: 40px;
    }
}

/* --- 手機版專屬微調 (僅針對手機寬度) --- */
@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        padding-left: 20px;
        padding-right: 20px;
    }
    .brand-logo-img { width: 300px; }
    .brand-logo-container::after { 
        width: 250px; 
        margin-top: -60px;
    }
    .main-title { font-size: 1.8rem; }
    .index-lang-switcher { top: 70px; right: 20px; }
}

/* =========================================
   Footer & Legal Section Styles
   ========================================= */

.legal-footer-container {
    /* --- 核心修改：使用絕對定位 --- */
    position: absolute;      /* 脫離文檔流，不佔據空間，所以不會推高內容 */
    bottom: 0;               /* 貼在底部 */
    left: 0;
    right: 0;
   
    
    padding: 30px 0;         /* 上下留點空間 */
    background: transparent; /* 背景透明 */
    
    /* 保持原本的 Flex 排版 */
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 10;             /* 確保在最上層 */
    
    /* 如果你想要分隔線，可以保留；如果覺得浮在底部有線很怪，可以註解掉下面這行 */
    /* border-top: 1px solid var(--border-sub); */ 
}

/* 為了避免內容太長時蓋住 Footer，給主區塊加一點底部內距 */
.main-content {
    position: relative; /* 這一行原本就有，確保 Footer 是參考它來定位 */
    padding-bottom: 80px !important; /* ★ 預留空間給 Footer */
}

/* 連結區域 */
.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 0.8rem; /* 字稍微改小一點，比較精緻 */
    text-decoration: none;
    transition: color 0.2s ease;
    opacity: 0.7; /* 預設半透明，不搶眼 */
}

.footer-links a:hover {
    color: var(--primary);
    text-decoration: underline;
    opacity: 1;
}

.footer-links .separator {
    color: var(--border);
    font-size: 0.75rem;
    opacity: 0.5;
}

/* 版權文字 */
.copyright-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.6;
    text-align: center;
}

/* =========================================
   手機版與矮螢幕適配 (重要)
   ========================================= */
/* 當螢幕變小，或者高度不夠時，我們取消絕對定位，改回原本的流式排版 */
/* 這樣才不會因為畫面太短，導致 Footer 蓋住搜尋框 */
@media (max-width: 768px), (max-height: 700px) {
    .legal-footer-container {
        position: relative;  /* 回復正常排版 */
        bottom: auto;
        left: auto;
        margin-top: 40px;    /* 手機版這時才會有推高的效果 (因為需要滾動) */
        padding-bottom: 30px;
        border-top: 1px solid var(--border-sub); /* 手機版加上線比較好看 */
    }
    
    .main-content {
        padding-bottom: 20px !important; /* 手機版不需要預留那麼多 */
    }
}
