/**
 * NLP Chat Interface Styles - Apple Design System Integration
 * 自然語言對話介面樣式 - Apple 設計系統整合版
 *
 * @author iShowPlay Team
 * @version 2.0.0
 * @date 2025-09-26
 */

/* ===== 主容器 - Apple Design ===== */
.nlp-interface {
    display: flex;
    flex-direction: column;
    height: 700px;
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.16),
                0 0 0 1px rgba(0, 0, 0, 0.04),
                inset 0 1px 0 rgba(255, 255, 255, 0.8);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: relative;
}

/* ===== 對話歷史區 - iMessage Style ===== */
.nlp-chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: linear-gradient(180deg, #F2F2F7 0%, #FFFFFF 100%);
    scroll-behavior: smooth;
    position: relative;
}

/* macOS 風格滾動條 */
.nlp-chat-history::-webkit-scrollbar {
    width: 8px;
    background: transparent;
}

.nlp-chat-history::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px 0;
}

.nlp-chat-history::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.nlp-chat-history::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
    background-clip: padding-box;
}

/* ===== ChatGPT 風格對話容器 ===== */
.chat-messages {
    width: 100%;
    max-width: 768px; /* 與 chatgpt-input-box 同寬 */
    margin: 0 auto;
    padding: 0;
    padding-bottom: 300px !important; /* 確保最後的訊息不被輸入框遮擋（輸入框高度 332px + 安全邊距） */
    box-sizing: border-box;
}

/* ===== 訊息樣式 - Apple Animation ===== */
.message {
    display: flex;
    flex-direction: row;
    margin-bottom: 20px;
    animation: messageSlideIn 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    width: 100%;
    position: relative;
    z-index: 2;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message-content {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 400;
    letter-spacing: -0.01em;
    word-wrap: break-word;
    position: relative;
    z-index: 2;
    background-clip: padding-box;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.message.user .message-content {
    background: #f7f7f8;
    color: #2d2d30;
    border-radius: 12px;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.16),
                0 8px 20px rgba(15, 23, 42, 0.12),
                0 1px 0 rgba(255, 255, 255, 0.8);
}

.message.user .message-content:hover {
    background: #f3f3f4;
}

.message.assistant .message-content {
    background: #ffffff;
    color: #2d2d30;
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12),
                0 6px 18px rgba(15, 23, 42, 0.08),
                0 1px 0 rgba(255, 255, 255, 0.7);
}

.message.assistant .message-content:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.message.error .message-content {
    background: #fee;
    color: #c00;
    border: 1px solid #fcc;
}

.message-time {
    font-size: 11px;
    color: rgba(60, 60, 67, 0.3);
    margin-top: 6px;
    padding: 0 12px;
    font-weight: 500;
    letter-spacing: -0.02em;
}

/* ===== 輸入指示器 - Apple Style ===== */
.message.typing .message-content {
    padding: 18px 24px;
    background: #E5E5EA;
    min-width: 80px;
}

.message.typing .dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #8E8E93;
    margin: 0 3px;
    animation: typingDot 1.4s infinite;
}

.message.typing .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.message.typing .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-12px);
        opacity: 1;
    }
}

/* ===== 解析結果卡片 - Apple Card Style ===== */
.parsed-result-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08),
                inset 0 1px 0 rgba(255, 255, 255, 0.8);
    margin: 12px 0;
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}

.parsed-result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.result-header {
    font-size: 16px;
    font-weight: 600;
    color: #000000;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-content {
    margin-bottom: 12px;
}

.result-item {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

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

.result-item .label {
    font-weight: 500;
    color: #666;
    min-width: 100px;
    font-size: 13px;
}

.result-item .value {
    color: #333333; /* Fixed: Ensure dark text on light background */
    flex: 1;
    font-size: 13px;
}

.result-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.btn-modify,
.btn-accept {
    flex: 1;
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-modify {
    background: #f1f3f5;
    color: #333333; /* Fixed: Ensure dark text on light background */
}

.btn-modify:hover {
    background: #e9ecef;
}

.btn-accept {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-accept:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* ===== 建議區域 ===== */
.suggestions {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
}

.suggestions-header {
    font-weight: 500;
    color: #666;
    margin-bottom: 8px;
    font-size: 13px;
}

.suggestion-item {
    padding: 6px 0;
    color: #333333; /* Fixed: Ensure dark text on light background */
    font-size: 13px;
    line-height: 1.5;
}

/* ===== 輸入區域 - Apple Input Style ===== */
.nlp-input-area {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-top: 1px solid rgba(60, 60, 67, 0.12);
    padding: 16px 20px 20px;
    position: relative;
}

.nlp-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    position: relative;
}

.nlp-input {
    flex: 1;
    padding: 14px 20px;
    background: #F2F2F7;
    border: 1.5px solid transparent;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 400;
    letter-spacing: -0.01em;
    resize: none;
    outline: none;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    font-family: inherit;
    line-height: 1.5;
    min-height: 52px;
}

.nlp-input:focus {
    background: white;
    border-color: #007AFF;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1), 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: scale(1.02);
}

.nlp-input::placeholder {
    color: rgba(60, 60, 67, 0.3);
    font-weight: 400;
}

.nlp-input-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ===== 操作按鈕組 - Apple Style ===== */
.nlp-action-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-right: 12px;
}

/* NLP Connector Dropdown (與傳統模式相同風格) */
.nlp-connector-dropdown {
    position: relative;
}

.nlp-connector-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    width: 280px;
    background: var(--bg-secondary, #f8f9fa);
    border: 1px solid var(--border-color, #e4e6eb);
    border-radius: 12px;
    padding: 8px;
    box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.12));
    display: none;
    z-index: 9999;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

/* Dark mode support for dropdown */
[data-theme="dark"] .nlp-connector-menu {
    background: #252525;
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
}

.nlp-connector-menu.active {
    display: block;
    animation: slideUp 0.2s ease-out forwards;
}

/* slideUp animation - 與傳統模式完全一致 */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nlp-connector-menu .connector-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.nlp-connector-menu .connector-item:hover {
    background-color: rgba(102, 126, 234, 0.08);
    transform: translateX(2px);
}

/* Dark mode hover effect */
[data-theme="dark"] .nlp-connector-menu .connector-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.nlp-connector-menu .connector-item:last-child {
    margin-bottom: 0;
}

.nlp-connector-menu .connector-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nlp-connector-menu .connector-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nlp-connector-menu .connector-icon svg {
    width: 20px;
    height: 20px;
}

.nlp-connector-menu .connector-label {
    font-size: 14px;
    color: var(--text-primary, #1a1d23);
    font-weight: 500;
}

[data-theme="dark"] .nlp-connector-menu .connector-label {
    color: var(--text-primary, #ffffff);
}

/* Toggle Switch - Enhanced with smooth animations */
.nlp-connector-menu .toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: #ccc;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nlp-connector-menu .toggle-switch.active {
    background-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.nlp-connector-menu .toggle-switch:hover {
    transform: scale(1.05);
}

.nlp-connector-menu .toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.nlp-connector-menu .toggle-switch.active .toggle-slider {
    transform: translateX(20px);
}

/* Pulse animation when toggled */
.nlp-connector-menu .toggle-switch.active .toggle-slider {
    animation: togglePulse 0.4s ease;
}

@keyframes togglePulse {
    0%, 100% {
        transform: translateX(20px) scale(1);
    }
    50% {
        transform: translateX(20px) scale(1.1);
    }
}

/* 調整 input-wrapper 以容納按鈕組 */
.chat-input-area .input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

/* NLP 輔助按鈕 - 膠囊風格 */
.nlp-attach-btn,
.nlp-connector-btn {
    height: 44px;
    min-width: 44px;
    padding: 0 16px;
    background: white;
    border: 1.5px solid #C7C7CC;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.19, 1, 0.22, 1);
    color: #636366;
    position: relative;
    overflow: hidden;
}

.nlp-attach-btn:before,
.nlp-connector-btn:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(0, 122, 255, 0.1) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

.nlp-attach-btn:hover,
.nlp-connector-btn:hover {
    transform: scale(1.05);
    border-color: #007AFF;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2);
}

.nlp-attach-btn:hover:before,
.nlp-connector-btn:hover:before {
    transform: translate(-50%, -50%) scale(2);
}

.nlp-attach-btn:active,
.nlp-connector-btn:active {
    transform: scale(0.95);
}

/* NLP 發送按鈕 - 主要操作按鈕 */
.nlp-send-btn {
    height: 44px;
    min-width: 80px;
    padding: 0 24px;
    background: linear-gradient(135deg, #007AFF 0%, #0051D5 100%);
    color: white;
    border: none;
    border-radius: 22px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.02em;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    position: relative;
    overflow: hidden;
}

.nlp-send-btn:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 100%);
    transform: translate(-50%, -50%) rotate(45deg) translateY(100%);
    transition: transform 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}

.nlp-send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 122, 255, 0.4);
}

.nlp-send-btn:hover:not(:disabled):before {
    transform: translate(-50%, -50%) rotate(45deg) translateY(0);
}

.nlp-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.nlp-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== 平台選擇下拉選單 - Apple Dropdown ===== */
#nlpConnectorMenu {
    position: absolute;
    bottom: 54px;
    left: 0;
    width: 320px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(60, 60, 67, 0.12);
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12),
                0 0 0 1px rgba(0, 0, 0, 0.05);
    display: none;
    z-index: 9999;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
}

[data-theme="dark"] #nlpConnectorMenu {
    background: #252525;
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
}

#nlpConnectorMenu.active {
    display: block;
    animation: menuReveal 0.3s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

@keyframes menuReveal {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===== Toggle Switch - iOS Style ===== */
.nlp-platform-toggle {
    position: relative;
    width: 51px;
    height: 31px;
    background: #C7C7CC;
    border-radius: 31px;
    cursor: pointer;
    transition: background-color 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.nlp-platform-toggle.active {
    background: #34C759;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04),
                0 3px 12px rgba(52, 199, 89, 0.3);
}

.nlp-platform-toggle .toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 27px;
    height: 27px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15),
                0 3px 1px rgba(0, 0, 0, 0.06);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nlp-platform-toggle.active .toggle-slider {
    transform: translateX(20px);
}

/* 平台選擇區域高亮效果 */
.nlp-platform-toggles.highlight {
    animation: highlightPulse 0.5s ease-in-out 3;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
}

@keyframes highlightPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
    }
}

.btn-send {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-send:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-icon {
    font-size: 16px;
}

/* ===== 快速操作 ===== */
.nlp-quick-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.quick-action {
    padding: 6px 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 12px;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-action:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

/* ===== 商品列表 ===== */
.nlp-products {
    border-top: 1px solid #e9ecef;
    padding: 16px;
    background: #f8f9fa;
}

.nlp-products h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333333; /* Fixed: Ensure dark text on light background */
}

.product-list {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.product-item {
    display: flex;
    flex-direction: column;
    min-width: 120px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

.product-item img {
    width: 120px;
    height: 120px;
    object-fit: cover;
}

.product-info {
    padding: 8px;
}

.product-title {
    font-size: 12px;
    color: #333333; /* Fixed: Ensure dark text on light background */
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-price {
    font-size: 14px;
    font-weight: 600;
    color: #667eea;
}

.btn-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    color: #666;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-remove:hover {
    background: white;
    color: #c00;
    transform: scale(1.1);
}

/* ===== 確認區域 ===== */
.nlp-confirm-area {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.btn-confirm,
.btn-reset {
    flex: 1;
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-confirm {
    background: linear-gradient(135deg, #51cf66 0%, #37b24d 100%);
    color: white;
}

.btn-confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(81, 207, 102, 0.4);
}

.btn-reset {
    background: #f8f9fa;
    color: #666;
}

.btn-reset:hover {
    background: #e9ecef;
}

/* ===== 成功訊息 ===== */
.success-message {
    padding: 16px;
    background: linear-gradient(135deg, #d3f9d8 0%, #b2f2bb 100%);
    border-radius: 8px;
    color: #2b8a3e;
    font-weight: 500;
    text-align: center;
}

.btn-view-stream {
    display: inline-block;
    margin-top: 12px;
    padding: 8px 16px;
    background: #51cf66;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-view-stream:hover {
    background: #40c057;
    transform: translateY(-1px);
}

/* ===== 載入遮罩 ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    background: white;
    padding: 24px 32px;
    border-radius: 12px;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: #333333; /* Fixed: Ensure dark text on light background */
    font-size: 14px;
    font-weight: 500;
}

/* ===== Platform Toggles Integration ===== */
.nlp-platform-toggles {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.platform-title {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
}

.platform-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.platform-toggle-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.platform-toggle-item:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* E-commerce Input Integration */
.ecommerce-input-area {
    padding: 12px 20px;
    background: linear-gradient(to right, #ffecd2 0%, #fcb69f 100%);
    border-top: 1px solid rgba(224, 224, 224, 0.5);
}

.ecommerce-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ecommerce-url-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.95);
    transition: all 0.3s ease;
}

.ecommerce-url-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-add-product {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-add-product:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Auto-activation animation for platform toggles */
.toggle-switch.auto-activated {
    animation: platformGlow 0.6s ease;
}

@keyframes platformGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 20px 10px rgba(102, 126, 234, 0.3);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
        transform: scale(1);
    }
}

/* ===== 響應式設計 ===== */
@media (max-width: 768px) {
    .nlp-interface {
        height: 100vh;
        border-radius: 0;
    }

    .message-content {
        max-width: 85%;
    }

    .nlp-input-wrapper {
        flex-direction: column;
    }

    .nlp-input {
        width: 100%;
    }

    .nlp-input-actions {
        width: 100%;
    }

    .platform-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 8px;
    }

    .ecommerce-input-wrapper {
        flex-direction: column;
        gap: 10px;
    }

    .ecommerce-url-input,
    .btn-add-product {
        width: 100%;
    }
    
    .btn-send {
        width: 100%;
        justify-content: center;
    }
    
    .nlp-confirm-area {
        flex-direction: column;
    }
}

/* ===== 暗色模式支援 ===== */
@media (prefers-color-scheme: dark) {
    .nlp-interface {
        background: #1a1a1a;
        color: #e0e0e0;
    }

    .nlp-chat-history {
        background: linear-gradient(to bottom, #2a2a2a 0%, #1a1a1a 100%);
    }

    .message.assistant .message-content {
        background: #2a2a2a;
        color: #e0e0e0;
    }

    .parsed-result-card {
        background: #2a2a2a;
        color: #e0e0e0;
    }

    .nlp-input-area {
        background: #1a1a1a;
        border-top-color: #333;
    }

    .nlp-input {
        background: #2a2a2a;
        border-color: #333;
        color: #e0e0e0;
    }

    .nlp-input:focus {
        border-color: #667eea;
    }

    .quick-action {
        background: #2a2a2a;
        border-color: #333;
        color: #b0b0b0;
    }

    .quick-action:hover {
        background: #333;
        border-color: #444;
    }
}

/* ===== Glassmorphism Support ===== */
/* Light mode glassmorphism for NLP dropdowns */
body:not([data-theme="dark"]) .nlp-connector-menu {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

body:not([data-theme="dark"]) .nlp-connector-menu .connector-item:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Dark mode glassmorphism for NLP dropdowns */
body[data-theme="dark"] .nlp-connector-menu {
    background: rgba(37, 37, 37, 0.85) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

body[data-theme="dark"] .nlp-connector-menu .connector-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* ===== 當前設定顯示區 ===== */
#currentSettings {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

#currentSettings h4 {
    margin: 0 0 10px 0;
    color: #333333; /* Fixed: Ensure dark text on light background */
    font-size: 1rem;
    font-weight: 600;
}

#settingsContent {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-label {
    font-weight: 500;
    color: #666;
    min-width: 60px;
}

.setting-value {
    color: #333333; /* Fixed: Ensure dark text on light background */
    flex: 1;
}

.platform-tag {
    display: inline-block;
    padding: 2px 8px;
    background: #667eea;
    color: white;
    border-radius: 4px;
    font-size: 0.85rem;
    margin: 0 4px;
}

/* ===== 訊息內圖片顯示樣式 ===== */
.product-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
    padding: 14px;
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 14px;
    align-items: flex-start;
    border: 1px solid rgba(0,0,0,0.06);
    width: 100%;
}

.product-card .product-image {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 12px;
    background: #f5f5f7;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

.product-card .product-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.product-card .product-title {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}

.product-card .product-price {
    color: #0b8457;
    font-weight: 600;
}

.product-card .product-platform {
    color: #6b7280;
    font-size: 12px;
}

.product-card .product-description {
    color: #374151;
    line-height: 1.6;
    white-space: pre-line;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.product-card .product-actions {
    margin-top: 6px;
}

.product-card .product-note {
    font-size: 12px;
    color: #065f46;
}

.message .product-card:hover {
    transform: translateY(-1px);
    transition: transform .2s ease, box-shadow .2s ease;
    box-shadow: 0 10px 24px rgba(0,0,0,0.12);
}

.message-image-container {
    margin: 10px 0;
    text-align: center;
}

.message-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: block;
    margin: 0 auto;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: #f5f5f5;
}

.message-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.message-image-caption {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

.message-image-container.image-error .message-image {
    opacity: 0.5;
    cursor: default;
}

/* 響應式圖片調整 */
@media (max-width: 768px) {
    .message-image {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .message-image {
        max-height: 200px;
    }
}

/* ===== ChatGPT 風格覆蓋 - 最高權重樣式 ===== */
/* 使用多重選擇器確保覆蓋所有其他CSS文件 */
body #nlp-container .chat-messages,
body .chat-wrapper .chat-messages,
body .nlp-interface .chat-messages,
body .chat-history-wrapper .chat-messages {
    max-width: clamp(480px, 92vw, 960px) !important;
    margin: 0 auto !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
    padding-bottom: 300px !important; /* 確保最後的訊息不被輸入框遮擋（輸入框高度 332px + 安全邊距） */
}

body #nlp-container .chat-messages .message.user .message-content,
body .chat-wrapper .chat-messages .message.user .message-content,
body .nlp-interface .chat-messages .message.user .message-content,
body .chat-history-wrapper .chat-messages .message.user .message-content,
.message.user > .message-content {
    background: #f7f7f8 !important;
    color: #2d2d30 !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.16) !important,
                0 8px 20px rgba(15, 23, 42, 0.12) !important,
                0 1px 0 rgba(255, 255, 255, 0.8) !important;
    border: none !important;
    background-image: none !important; /* 防止漸層覆蓋 */
    margin-left: auto !important;
    margin-right: 0 !important;
}

body #nlp-container .chat-messages .message.user .message-content:hover,
body .chat-wrapper .chat-messages .message.user .message-content:hover,
body .nlp-interface .chat-messages .message.user .message-content:hover,
body .chat-history-wrapper .chat-messages .message.user .message-content:hover,
.message.user > .message-content:hover {
    background: #f3f3f4 !important;
    transform: translateY(-1px) !important;
    background-image: none !important;
}

body #nlp-container .chat-messages .message.assistant .message-content,
body .chat-wrapper .chat-messages .message.assistant .message-content,
body .nlp-interface .chat-messages .message.assistant .message-content,
body .chat-history-wrapper .chat-messages .message.assistant .message-content,
.message.assistant > .message-content {
    background: #ffffff !important;
    color: #2d2d30 !important;
    border-radius: 12px !important;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12) !important,
                0 6px 18px rgba(15, 23, 42, 0.08) !important,
                0 1px 0 rgba(255, 255, 255, 0.7) !important;
    border: 1px solid #f0f0f0 !important;
    background-image: none !important;
    margin-left: 0 !important;
    margin-right: auto !important;
}

body #nlp-container .chat-messages .message.assistant .message-content:hover,
body .chat-wrapper .chat-messages .message.assistant .message-content:hover,
body .nlp-interface .chat-messages .message.assistant .message-content:hover,
body .chat-history-wrapper .chat-messages .message.assistant .message-content:hover,
.message.assistant > .message-content:hover {
    box-shadow: 0 24px 55px rgba(15, 23, 42, 0.16) !important,
                0 10px 26px rgba(15, 23, 42, 0.12) !important,
                0 1px 0 rgba(255, 255, 255, 0.8) !important;
    transform: translateY(-1px) !important;
    background-image: none !important;
}
