/**
 * AequiLex 首頁移動端修復
 * 專門修復首頁在移動端的顯示問題
 * Version: v3.5.0.2
 * Date: 2026-01-09
 */

/* ========== 首頁移動端全面修復 ========== */

@media only screen and (max-width: 768px) {
    
    /* ========== 容器優化 ========== */
    .container.centered-container {
        padding: 60px 16px 80px 16px !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* ========== Logo 區域 ========== */
    .logo-section {
        margin-bottom: 24px !important;
    }
    
    .logo-text {
        font-size: 32px !important;
        margin-bottom: 4px !important;
    }
    
    .logo-subtitle {
        font-size: 13px !important;
    }
    
    /* ========== 標題區域 ========== */
    .hero-title,
    .homepage-title {
        font-size: 28px !important;
        line-height: 1.3 !important;
        margin-bottom: 12px !important;
        padding: 0 8px !important;
    }
    
    .hero-subtitle,
    .homepage-subtitle {
        font-size: 14px !important;
        line-height: 1.5 !important;
        margin-bottom: 24px !important;
        padding: 0 8px !important;
    }
    
    /* ========== 輸入容器 ========== */
    .input-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto 20px auto !important;
        padding: 0 !important;
    }
    
    .input-box {
        width: 100% !important;
        max-width: 100% !important;
        padding: 12px !important;
        border-radius: 16px !important;
        box-shadow: 0 2px 8px rgba(1, 50, 32, 0.1) !important;
    }
    
    /* ========== 主輸入框 ========== */
    .main-input {
        width: 100% !important;
        min-height: 80px !important;
        max-height: 150px !important;
        font-size: 15px !important;
        line-height: 1.5 !important;
        padding: 10px 12px !important;
        border: none !important;
        resize: none !important;
        overflow-y: auto !important;
    }
    
    .main-input::placeholder {
        font-size: 14px !important;
    }
    
    /* ========== 工具欄 ========== */
    .input-toolbar {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        margin-top: 10px !important;
        padding-top: 10px !important;
        border-top: 1px solid var(--border, #e0e0e0) !important;
    }
    
    .toolbar-left {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        width: 100% !important;
    }
    
    .toolbar-right {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        gap: 12px !important;
    }
    
    /* ========== 工具欄按鈕 ========== */
    .toolbar-btn {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 10px !important;
        border-radius: 10px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .toolbar-btn svg {
        width: 20px !important;
        height: 20px !important;
    }
    
    /* ========== AI 模型選擇器 - 關鍵修復 ========== */
    .model-select {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 44px !important;
        padding: 10px 12px !important;
        font-size: 13px !important;
        border-radius: 10px !important;
        border: 1px solid var(--border, #e0e0e0) !important;
        background: var(--bg-card, white) !important;
        color: var(--text-primary, #1a1a1a) !important;
        
        /* 確保文字不溢出 */
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        
        /* 移動端優化 */
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
    }
    
    /* 簡化選項文字 */
    .model-select option {
        font-size: 13px !important;
        padding: 8px !important;
    }
    
    /* ========== 提交按鈕 ========== */
    .submit-btn {
        min-width: 48px !important;
        min-height: 48px !important;
        padding: 12px !important;
        border-radius: 12px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
    }
    
    .submit-btn svg {
        width: 22px !important;
        height: 22px !important;
    }
    
    /* ========== 字數統計 ========== */
    .char-count {
        font-size: 13px !important;
        font-weight: 600 !important;
    }
    
    .char-limit {
        font-size: 13px !important;
        color: var(--text-muted, #6a6a6a) !important;
    }
    
    /* ========== 鍵盤提示 ========== */
    .keyboard-hint,
    .enhanced-hint {
        display: none !important; /* 移動端隱藏鍵盤提示 */
    }
    
    /* ========== 底部操作按鈕 ========== */
    .bottom-actions {
        display: flex !important;
        gap: 12px !important;
        justify-content: center !important;
        margin-top: 20px !important;
        padding: 0 16px !important;
        flex-wrap: wrap !important;
    }
    
    .action-btn {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 10px 16px !important;
        font-size: 14px !important;
        border-radius: 12px !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 8px !important;
        flex: 1 1 auto !important;
        max-width: 160px !important;
        justify-content: center !important;
    }
    
    .action-btn svg {
        width: 18px !important;
        height: 18px !important;
        flex-shrink: 0 !important;
    }
    
    .action-btn span {
        font-size: 14px !important;
        white-space: nowrap !important;
    }
    
    /* ========== 漢堡菜單按鈕 ========== */
    .hamburger-btn {
        position: fixed !important;
        top: 16px !important;
        left: 16px !important;
        z-index: 1000 !important;
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 10px !important;
        border-radius: 12px !important;
        background: var(--bg-card, white) !important;
        border: 1px solid var(--border, #e0e0e0) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }
    
    .hamburger-btn svg {
        width: 24px !important;
        height: 24px !important;
    }
    
    /* ========== 語言切換器 ========== */
    .language-switcher {
        position: fixed !important;
        top: 16px !important;
        right: 16px !important;
        z-index: 1000 !important;
        padding: 8px 12px !important;
        min-height: 44px !important;
        font-size: 13px !important;
        border-radius: 12px !important;
        background: var(--bg-card, white) !important;
        border: 1px solid var(--border, #e0e0e0) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* ========== 社交分享彈窗 ========== */
    .social-share-popup {
        position: fixed !important;
        bottom: 80px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: calc(100% - 32px) !important;
        max-width: 360px !important;
        padding: 16px !important;
        border-radius: 16px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    }
    
    .social-btn {
        min-height: 44px !important;
        padding: 10px 16px !important;
        font-size: 14px !important;
        border-radius: 12px !important;
    }
    
    /* ========== 確保不會橫向滾動 ========== */
    body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }
    
    * {
        max-width: 100% !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    /* ========== 防止元素超出屏幕 ========== */
    select,
    button,
    input,
    textarea {
        max-width: 100% !important;
    }
}

/* ========== 超小屏幕優化 (480px 以下) ========== */

@media only screen and (max-width: 480px) {
    
    .container.centered-container {
        padding: 50px 12px 70px 12px !important;
    }
    
    .logo-text {
        font-size: 28px !important;
    }
    
    .hero-title,
    .homepage-title {
        font-size: 24px !important;
    }
    
    .hero-subtitle,
    .homepage-subtitle {
        font-size: 13px !important;
    }
    
    .input-box {
        padding: 10px !important;
    }
    
    .main-input {
        min-height: 70px !important;
        font-size: 14px !important;
    }
    
    .model-select {
        font-size: 12px !important;
        padding: 8px 10px !important;
    }
    
    .submit-btn {
        min-width: 44px !important;
        min-height: 44px !important;
    }
    
    .action-btn {
        padding: 8px 12px !important;
        font-size: 13px !important;
        max-width: 140px !important;
    }
    
    .action-btn span {
        font-size: 13px !important;
    }
}

/* ========== 橫屏模式優化 ========== */

@media only screen and (max-height: 500px) and (orientation: landscape) {
    
    .container.centered-container {
        padding: 40px 16px 60px 16px !important;
    }
    
    .logo-section {
        margin-bottom: 16px !important;
    }
    
    .hero-title,
    .homepage-title {
        font-size: 24px !important;
        margin-bottom: 8px !important;
    }
    
    .hero-subtitle,
    .homepage-subtitle {
        font-size: 13px !important;
        margin-bottom: 16px !important;
    }
    
    .main-input {
        min-height: 60px !important;
        max-height: 100px !important;
    }
    
    .bottom-actions {
        margin-top: 12px !important;
    }
}

/* ========== 確保觸控友好 ========== */

@media only screen and (max-width: 768px) {
    
    /* 所有可點擊元素最小尺寸 */
    button,
    a,
    select,
    input[type="submit"],
    .btn,
    .action-btn,
    .toolbar-btn,
    .submit-btn {
        min-width: 44px !important;
        min-height: 44px !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    /* 防止雙擊縮放 */
    * {
        touch-action: manipulation !important;
        -ms-touch-action: manipulation !important;
    }
    
    /* 平滑滾動 */
    * {
        -webkit-overflow-scrolling: touch !important;
    }
}
