/**
 * ChatGPT Input Style
 * ChatGPT 風格輸入框樣式
 *
 * @author iShowPlay Team
 * @version 1.0.0
 * @date 2025-09-29
 */

/* ===== ChatGPT 輸入容器 ===== */
.chatgpt-input-container {
    position: absolute;
    width: 100%;
    max-width: 100%; /* 移除最大寬度限制，讓它填滿 nlp-container */
    padding: 0; /* 移除 padding，讓內部元素可以完全填滿 */
    z-index: 100;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 中央位置（無對話時） - 相對於 main-content 置中 */
.chatgpt-input-container.centered {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 100%; /* 填滿父容器高度 */
    display: flex;
    align-items: center; /* 垂直置中內容 */
}

/* 底部位置（有對話時） - 固定在視窗底部 */
.chatgpt-input-container.bottom {
    position: fixed;
    bottom: 0;
    left: calc(50% + (var(--sidebar-width, 280px) / 2)); /* 與側邊欄寬度連動 */
    transform: translateX(-50%);
}

/* ===== 主輸入框容器 ===== */
.chatgpt-input-box {
    position: relative; /* 為絕對定位的子元素提供參考點 */
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
                0 2px 4px -1px rgba(0, 0, 0, 0.06),
                0 0 0 1px rgba(0, 0, 0, 0.02);
    padding: 0; /* 移除 padding 以讓內部元素填滿全寬 */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%; /* 填滿容器寬度 */
    box-sizing: border-box; /* 包含 padding 在寬度內 */
}

.chatgpt-input-box:focus-within {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
                0 4px 6px -2px rgba(0, 0, 0, 0.05),
                0 0 0 2px rgba(79, 195, 247, 0.2);
    border-color: #4FC3F7;
}

/* ===== Input Card Flex 佈局 ===== */
.chatgpt-input-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px; /* 將 padding 從 .chatgpt-input-box 移到這裡以保持間距 */
}

.chatgpt-input-field {
    order: 1;
    flex: 1; /* 讓 textarea 區域可擴展 */
}

/* ===== 文字輸入區域 ===== */
.chatgpt-textarea-wrapper {
    position: relative;
    margin-bottom: 12px;
}

body .chatgpt-textarea,
body:not([data-theme="dark"]) .chatgpt-textarea {
    width: 100%;
    min-height: 120px !important; /* 縮短高度，讓整體布局更緊湊 */
    max-height: 240px !important; /* 對應縮短最大高度 */
    padding: 12px 16px;
    background: white !important; /* 白色背景 */
    border: 1px solid #d1d5db !important; /* 明顯的灰色邊框 */
    border-radius: 12px; /* 圓角邊框 */
    font-size: 16px;
    line-height: 1.5;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    overflow-y: auto;
}

body .chatgpt-textarea:focus,
body:not([data-theme="dark"]) .chatgpt-textarea:focus {
    background: white !important;
    border-color: #4FC3F7 !important; /* Focus 時藍色邊框 */
    box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.1) !important; /* 外框光暈 */
}

.chatgpt-textarea::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

/* 自動調整高度 */
.chatgpt-textarea::-webkit-scrollbar {
    width: 8px;
}

.chatgpt-textarea::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.chatgpt-textarea::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.chatgpt-textarea::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ===== 功能按鈕區域 ===== */
.chatgpt-input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

/* 左側按鈕組 */
.chatgpt-left-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* 右側按鈕組 */
.chatgpt-right-actions {
    display: flex;
    align-items: center;
}

/* ===== 通用按鈕樣式 ===== */
.chatgpt-action-btn {
    width: 49px;
    height: 49px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: white;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.chatgpt-action-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #374151;
}

.chatgpt-action-btn svg {
    width: 20px;
    height: 20px;
}

/* ===== 送出按鈕 - 品牌藍色 ===== */
.chatgpt-send-btn {
    width: 49px;
    height: 49px;
    border-radius: 10px;
    border: none;
    background: #4FC3F7;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(79, 195, 247, 0.2);
}

.chatgpt-send-btn:hover {
    background: #29B6F6;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(79, 195, 247, 0.3);
}

.chatgpt-send-btn:active {
    transform: scale(0.98);
}

.chatgpt-send-btn svg {
    width: 22px;
    height: 22px;
}

/* 禁用狀態 */
.chatgpt-send-btn:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
}

.chatgpt-send-btn:disabled:hover {
    transform: none;
}

/* ===== 商品縮圖 ===== */
.selected-product-thumbnails {
    order: 3; /* 在按鈕和提示之間 */
}

/* ===== 提示文字 ===== */
.chatgpt-input-hints {
    order: 4; /* 移到最後 */
    margin-top: auto; /* 推到底部 */
    margin-bottom: 12px; /* 保留底部空格 */
    padding: 8px 12px;
    background: #f9fafb;
    border-radius: 8px;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.4;
    text-align: center;
}

/* ===== 深色模式支援 ===== */
[data-theme="dark"] .chatgpt-input-box {
    background: #1f2937;
    border-color: #374151;
}

[data-theme="dark"] .chatgpt-input-box:focus-within {
    border-color: #ff6b00;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3),
                0 4px 6px -2px rgba(0, 0, 0, 0.2),
                0 0 0 2px rgba(255, 107, 0, 0.3);
}

body[data-theme="dark"] .chatgpt-textarea {
    background: transparent !important;
    color: #f3f4f6;
}

body[data-theme="dark"] .chatgpt-textarea:focus {
    background: transparent !important;
    border-color: transparent;
}

[data-theme="dark"] .chatgpt-textarea::placeholder {
    color: #6b7280;
}

[data-theme="dark"] .chatgpt-action-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #9ca3af;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

[data-theme="dark"] .chatgpt-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
    color: #d1d5db;
}

[data-theme="dark"] .chatgpt-input-hints {
    background: #111827;
    color: #9ca3af;
}

/* ===== 響應式設計 ===== */
@media (max-width: 768px) {
    .chatgpt-input-container {
        padding: 12px;
        max-width: 100%;
    }

    /* 移動裝置上無側邊欄，恢復正常置中 */
    .chatgpt-input-container.bottom {
        left: 50%;
    }

    .chatgpt-input-box {
        border-radius: 12px;
        padding: 12px;
    }

    .chatgpt-textarea {
        min-height: 80px;
        font-size: 15px;
        padding: 10px 12px;
    }

    .chatgpt-action-btn {
        width: 34px;
        height: 34px;
    }

    .chatgpt-send-btn {
        width: 36px;
        height: 36px;
    }

    .chatgpt-input-hints {
        font-size: 12px;
        padding: 6px 10px;
    }

    /* ========== 手機版按鈕 icon-only 設計 (2025-10-31 優化) ========== */
    /* 開始直播按鈕：轉為圓形 icon-only */
    .chatgpt-secondary-btn {
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    /* 隱藏文字，只顯示 icon */
    .chatgpt-secondary-btn .btn-text {
        display: none;
    }

    .chatgpt-secondary-btn .btn-icon {
        font-size: 18px;
    }

    /* 調整左側按鈕間距 */
    .chatgpt-left-actions {
        gap: 6px;
    }

    /* 調整右側按鈕間距 */
    .chatgpt-right-actions {
        gap: 6px;
    }
}

@media (max-width: 480px) {
    .chatgpt-action-btn {
        width: 32px;
        height: 32px;
    }

    .chatgpt-send-btn {
        width: 34px;
        height: 34px;
    }

    .chatgpt-secondary-btn {
        width: 36px;
        height: 36px;
    }

    /* 只調整 icon 大小，不影響文字隱藏 */
    .chatgpt-secondary-btn .btn-icon {
        font-size: 16px;
    }
}

/* ===== 動畫效果 ===== */
@keyframes pulse-orange {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 107, 0, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 107, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 107, 0, 0);
    }
}

.chatgpt-send-btn.pulse {
    animation: pulse-orange 1.5s infinite;
}

/* ===== 載入狀態 ===== */
.chatgpt-input-box.loading .chatgpt-textarea {
    opacity: 0.6;
    pointer-events: none;
}

.chatgpt-input-box.loading .chatgpt-send-btn {
    position: relative;
}

.chatgpt-input-box.loading .chatgpt-send-btn::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid white;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== 兼容現有 dropdown 樣式 ===== */
.chatgpt-input-box .nlp-connector-dropdown {
    position: relative;
}

.chatgpt-input-box .nlp-connector-menu {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    min-width: 280px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1),
                0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 1000;
}

[data-theme="dark"] .chatgpt-input-box .nlp-connector-menu {
    background: #1f2937;
    border-color: #374151;
}

/* ===== 按鈕行對齊樣式 (2025-10-13 新增) ===== */
.chatgpt-actions-row {
    display: flex;
    justify-content: space-between !important; /* 強制左右對齊 */
    align-items: center;
    width: 100%;
    gap: 12px;
    margin-top: 16px !important; /* 增加與 textarea 的間距，讓按鈕向下移動 */
    order: 2; /* 設定順序為第二 */
}

/* 左側按鈕組 - 明確靠左 */
.chatgpt-left-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
}

/* 右側按鈕組 - 明確靠右 */
.chatgpt-right-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

/* 開始直播按鈕樣式 */
.chatgpt-secondary-btn {
    padding: 8px 16px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background: white;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chatgpt-secondary-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

/* 確保送出按鈕樣式 */
.chatgpt-send-btn {
    width: 49px;
    height: 49px;
    border-radius: 12px;
    flex-shrink: 0;
}

/* ===== 產品縮圖定位 (2025-10-13 修改) ===== */
/* ❌ 已移除：原本定位在右下角，現改為在 chatgpt-input-field 內左對齊 */
/* 新位置由 JS inline styles 控制 */

/* ===== 社群平台圖示定位 (2025-10-13 已停用) ===== */
/* ❌ 已停用：platform-badge 功能已移除 */
/* 現使用 selected-platform-avatars 在 chatgpt-input-card 最上方右對齊 */
/*
.social-connect-icons,
.selected-platforms-display,
.social-platform-badges {
    position: absolute;
    right: 16px;
    top: 16px;
    width: auto !important;
    z-index: 10;
    display: flex;
    gap: 6px;
    align-items: center;
}

.social-connect-icons .platform-icon,
.selected-platforms-display .platform-badge,
.social-platform-badges .badge {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: white;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
}

.social-connect-icons .platform-icon:hover,
.selected-platforms-display .platform-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}
*/
