/**
 * Hybrid Interface Styles
 * 混合介面專用樣式 - 結合傳統控件與NLP對話
 */

/* 對話歷史容器 */
.chat-history-container {
    margin-top: 30px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Dark mode 調整 */
[data-theme="dark"] .chat-history-container {
    background: rgba(30, 30, 40, 0.95);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* 聊天歷史包裝器 */
.chat-history-wrapper {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

/* 自定義滾動條 */
.chat-history-wrapper::-webkit-scrollbar {
    width: 8px;
}

.chat-history-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.chat-history-wrapper::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 4px;
}

.chat-history-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* 訊息樣式 */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 基本訊息樣式 */
.message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: fadeInUp 0.3s ease;
}

/* 用戶訊息 */
.message.user {
    flex-direction: row-reverse;
}

/* 註解掉以避免覆蓋 ChatGPT 風格 */
/*
.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 18px 18px 4px 18px;
    margin-left: auto;
    max-width: 70%;
}
*/

/* AI 助手訊息 - 註解掉背景色 */
/*
.message.assistant .message-content {
    background: rgba(241, 243, 245, 0.95);
    color: #333333;
    border-radius: 18px 18px 18px 4px;
    max-width: 70%;
}
*/

/* 註解掉深色模式樣式以使用 nlp-chat.css 的設定 */
/*
[data-theme="dark"] .message.assistant .message-content {
    background: rgba(50, 50, 60, 0.95);
    color: #e0e0e0;
}
*/

/* 訊息頭像 */
.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* 訊息內容 */
.message-content {
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message-text {
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.message-time {
    font-size: 11px;
    color: rgba(0, 0, 0, 0.4);
    margin-top: 4px;
}

.message.user .message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* 輸入中指示器 */
.typing-indicator .typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* 確認卡片 */
.confirmation-card {
    margin: 16px 0;
    animation: fadeInUp 0.3s ease;
}

.confirmation-card .card-content {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .confirmation-card .card-content {
    background: rgba(40, 40, 50, 0.95);
}

.confirmation-card h4 {
    margin: 0 0 16px 0;
    color: #333333; /* Fixed: Ensure dark text on light background */
    font-size: 16px;
}

[data-theme="dark"] .confirmation-card h4 {
    color: #e0e0e0;
}

.settings-summary {
    margin: 16px 0;
}

.settings-summary p {
    margin: 8px 0;
    font-size: 14px;
    color: #666;
}

[data-theme="dark"] .settings-summary p {
    color: #b0b0b0;
}

.card-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.card-actions button {
    flex: 1;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

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

.btn-modify {
    background: rgba(241, 243, 245, 0.95);
    color: #666;
}

.btn-modify:hover {
    background: rgba(230, 232, 235, 0.95);
}

/* 商品列表 */
.product-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-item {
    display: flex;
    gap: 12px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
}

.product-item img {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
}

.product-info {
    flex: 1;
}

.product-title {
    font-size: 13px;
    font-weight: 500;
    color: #333333; /* Fixed: Ensure dark text on light background */
    margin-bottom: 4px;
}

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

/* 動畫效果 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 平台開關自動啟用動畫 */
.toggle-switch.auto-activated {
    animation: glow 0.5s ease;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.6);
}

@keyframes glow {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* 響應式設計 */
@media (max-width: 768px) {
    .chat-history-wrapper {
        height: 300px;
        padding: 16px;
    }

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

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .message-text {
        font-size: 13px;
    }
}

/* 整合傳統控件樣式調整 */
#traditional-prompt-panel.interface-panel {
    transition: all 0.3s ease;
}

/* 當有對話進行時，調整傳統面板的邊距 */
#traditional-prompt-panel.has-conversation {
    margin-bottom: 0;
}

/* 平滑過渡效果 */
.chat-history-container {
    opacity: 0;
    transform: translateY(20px);
    animation: slideIn 0.5s ease forwards;
    animation-delay: 0.3s;
}

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