/* ==========================================
   AI Chat Assistant - 浮動對話視窗
   ========================================== */

:root {
    --ai-chat-primary: #5ab74f;
    --ai-chat-primary-dark: #4da344;
    --ai-chat-primary-soft: #E8F5E9;
    --ai-chat-white: #fff;
    --ai-chat-text: #626262;
    --ai-chat-text-secondary: #666;
    --ai-chat-border: #e0e0e0;
}

/* 導覽列 AI 按鈕 */
.ai-chat-nav-item {
    display: flex;
    align-items: center;
}

.ai-chat-nav-btn {
    background: var(--ai-chat-primary);
    border: none;
    margin: 0 1rem;
    padding: 6px;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.navbar .navbar-right .navbar-nav .user-menu .dropdown-toggle {
    border-left: 1px solid #dee2e6;
}

.ai-chat-fab-icon {
    width: 27px;
    height: 27px;
    display: block;
    border-radius: 50%;
    box-shadow: none;
    transition: transform 0.2s ease;
}

.ai-chat-nav-btn:hover {
    background: var(--ai-chat-primary-dark);
    transform: none;
    box-shadow: 0 2px 8px rgba(90, 183, 79, 0.28);
}

.ai-chat-nav-btn:focus,
.ai-chat-nav-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(90, 183, 79, 0.35);
}

.ai-chat-nav-btn:active .ai-chat-fab-icon,
.ai-chat-nav-btn.active .ai-chat-fab-icon {
    transform: scale(0.94);
}

.ai-chat-nav-btn.active {
    filter: brightness(0.95);
    transform: none;
}

/* 浮動對話視窗 */
.ai-chat-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    height: 520px;
    z-index: 9998;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    display: none;
    flex-direction: column;
    font-family: 'Segoe UI', 'Microsoft JhengHei', sans-serif;
    overflow: hidden;
    transition: height 0.3s ease, width 0.3s ease, bottom 0.3s ease, right 0.3s ease;
}

.ai-chat-panel.open {
    display: flex;
}

/* 最小化狀態 */
.ai-chat-panel.minimized {
    height: auto !important;
    width: 220px;
}

.ai-chat-panel.minimized .ai-chat-messages,
.ai-chat-panel.minimized .ai-chat-input-area,
.ai-chat-panel.minimized .ai-chat-categories,
.ai-chat-panel.minimized .ai-chat-bottom-area {
    display: none;
}

/* 最大化狀態 */
.ai-chat-panel.maximized {
    width: 520px;
    height: 80vh;
    bottom: 10px;
    right: 10px;
}

/* 面板遮罩（保留但隱藏，不再需要遮罩） */
.ai-chat-overlay {
    display: none;
}

/* 面板標題 */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #fff;
    color: #333;
    flex-shrink: 0;
    border-bottom: 1px solid #eee;
    cursor: move;
    user-select: none;
}

.ai-chat-header-left {
    display: flex;
    align-items: center;
}

.ai-chat-header-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-header-btn:hover {
    color: #333;
    background: #f0f0f0;
}

.ai-chat-header-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 600;
    flex: 1;
    justify-content: center;
    color: #333;
}

.ai-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* 偵錯模式開關 */
.ai-chat-debug-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.2s;
    color: #aaa;
    font-size: 13px;
    margin: 0;
}

.ai-chat-debug-toggle:hover {
    background: #f0f0f0;
    color: #888;
}

.ai-chat-debug-toggle input[type="checkbox"] {
    display: none;
}

.ai-chat-debug-toggle.active,
.ai-chat-debug-toggle input:checked + i {
    color: #f0ad4e;
}

/* 功能分類按鈕（移至底部輸入區上方） */
.ai-chat-categories {
    display: flex;
    gap: 6px;
    padding: 10px 0 0;
    background: transparent;
    flex-shrink: 0;
    margin-top: auto;
}

.ai-chat-category-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border: 1px solid var(--ai-chat-border);
    border-radius: 8px;
    background: var(--ai-chat-white);
    color: var(--ai-chat-text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    white-space: nowrap;
}

.ai-chat-category-btn:hover {
    border-color: var(--ai-chat-primary);
    color: var(--ai-chat-primary);
    background: var(--ai-chat-primary-soft);
}

.ai-chat-category-btn:active {
    border-color: var(--ai-chat-primary);
    color: var(--ai-chat-primary);
    background: var(--ai-chat-primary-soft);
}

.ai-chat-category-btn.active {
    border-color: var(--ai-chat-primary);
    color: var(--ai-chat-primary);
    background: var(--ai-chat-primary-soft);
}

.ai-chat-category-btn i {
    font-size: 13px;
}

/* 聊天訊息區 */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 3px;
}

/* 訊息泡泡 */
.ai-chat-message {
    display: flex;
    gap: 0;
    max-width: 100%;
    width: 100%;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
    max-width: 85%;
    width: auto;
}

.ai-chat-message.assistant {
    align-self: flex-start;
    width: 100%;
}

.ai-chat-message-avatar {
    display: none;
}

.ai-chat-message.user .ai-chat-message-avatar {
    display: none;
}

.ai-chat-message.assistant .ai-chat-message-avatar {
    display: none;
}

.ai-chat-message-content {
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.ai-chat-message.user .ai-chat-message-content {
    background: #fff0c8;
    color: #333333;
    border-radius: 12px 0 12px 12px;
}

.ai-chat-message.assistant .ai-chat-message-content {
    background: transparent;
    color: #333333;
    border-radius: 0;
    padding: 4px 0;
    width: 100%;
}

.ai-chat-assistant-lead {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #333333;
}

.ai-chat-assistant-lead-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.ai-chat-message-body {
    color: #333333;
}

/* Markdown 表格 */
.ai-chat-message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 12px;
}

.ai-chat-message-content table th,
.ai-chat-message-content table td {
    border: 1px solid #d0d0d0;
    padding: 6px 8px;
    text-align: left;
}

.ai-chat-message-content table th {
    background: #e8e8e8;
    font-weight: 600;
}

.ai-chat-message-content table tr:nth-child(even) {
    background: #f8f8f8;
}

/* 表格容器（橫向捲軸） */
.ai-chat-table-wrapper {
    overflow-x: auto;
    margin: 8px 0;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

/* 卡片式資料顯示 */
.ai-chat-cards-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 10px 0;
}

.ai-chat-card {
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
}

.ai-chat-card-header {
    background: transparent;
    padding: 8px 0 4px;
    font-size: 16px;
    font-weight: 600;
    color: #555;
    line-height: 1.2;
}

.ai-chat-card-body {
    background: #fff;
    border: 0.5px solid #d8d8d8;
    border-radius: 6px;
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ai-chat-card-field {
    display: flex;
    flex-direction: column;
    padding: 0;
    min-width: 0;
}

.ai-chat-card-field.is-wide {
    grid-column: 1 / -1;
}

.ai-chat-card-label {
    font-size: clamp(12px, 1.1vw, 14px);
    color: #8f8f8f;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}

.ai-chat-card-value {
    font-size: clamp(15px, 1.6vw, 18px);
    color: #5b5b5b;
    font-weight: 600;
    line-height: 1.4;
    word-break: break-word;
}

/* 當欄位較少時，單欄顯示 */
@media (max-width: 480px) {
    .ai-chat-card-body {
        grid-template-columns: 1fr;
    }
}

/* 載入動畫 */
.ai-chat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
}

.ai-chat-typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typingBounce 1.2s infinite;
}

.ai-chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* 輸入區 */
.ai-chat-input-area {
    padding: 10px 14px 14px;
    background: #fff;
    flex-shrink: 0;
}

/* 底部區域（分類 + 輸入） */
.ai-chat-bottom-area {
    flex-shrink: 0;
    border-top: 1px solid #eee;
    background: #fff;
}

.ai-chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* + 按鈕 */
.ai-chat-add-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid #d0d0d0;
    background: #fff;
    color: #666;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-chat-add-btn:hover {
    border-color: #f5a623;
    color: #f5a623;
}

.ai-chat-input {
    flex: 1;
    border: 1px solid #d0d0d0;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    resize: none;
    max-height: 80px;
    min-height: 36px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.ai-chat-input:focus {
    border-color: #0078d4;
}

.ai-chat-input::placeholder {
    color: #a0a0a0;
}

.ai-chat-send-btn {
    display: flex;
    padding: 6px 16px;
    border-radius: 20px;
    border: none;
    background: #f5a623;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    flex-shrink: 0;
    white-space: nowrap;
}

.ai-chat-send-btn:hover {
    background: #e09500;
}

.ai-chat-send-btn i {
    font-size: 14px;
}

/* 語音按鈕 */
.ai-chat-voice-btn {
    padding: 6px 16px;
    border-radius: 20px;
    border: none;
    background: #4caf50;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    flex-shrink: 0;
    white-space: nowrap;
}

.ai-chat-voice-btn:hover {
    background: #43a047;
}

.ai-chat-voice-btn i {
    font-size: 14px;
}

/* 語音錄音模式 */
.ai-chat-voice-mode {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 20px 14px;
    gap: 16px;
    flex: 1;
    justify-content: center;
}

.ai-chat-panel.voice-active .ai-chat-voice-mode {
    display: flex;
}

.ai-chat-panel.voice-active .ai-chat-messages {
    display: none;
}

.ai-chat-panel.voice-active .ai-chat-categories {
    display: none;
}

.ai-chat-voice-hint {
    font-size: 13px;
    color: #999;
}

.ai-chat-voice-example {
    font-size: 15px;
    color: #666;
    text-align: center;
    line-height: 1.6;
    padding: 0 20px;
}

.ai-chat-voice-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #4caf50;
    font-size: 14px;
    font-weight: 500;
}

.ai-chat-voice-indicator i {
    font-size: 18px;
    animation: voicePulse 1.5s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.ai-chat-voice-stop-btn {
    padding: 8px 24px;
    border-radius: 20px;
    border: none;
    background: #333;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.ai-chat-voice-stop-btn:hover {
    background: #555;
}

.ai-chat-voice-stop-btn i {
    font-size: 12px;
}

/* 隱藏聊天輸入區（語音模式下） */
.ai-chat-panel.voice-active .ai-chat-input-area .ai-chat-input-wrapper {
    display: none;
}

.ai-chat-panel.voice-active .ai-chat-input-area {
    padding: 10px 14px 14px;
}

/* 浮動範例選擇 */
.ai-chat-category-examples {
    display: none;
    background: #fff;
    margin: 0;
    overflow: hidden;
    animation: fadeInUp 0.2s ease;
}

.ai-chat-category-examples.open {
    display: block;
}

.ai-chat-category-examples-list {
    display: flex;
    flex-direction: column;
}

.ai-chat-example-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
    color: var(--ai-chat-text);
    border-bottom: 1px solid #f0f0f0;
}

.ai-chat-example-item:last-child {
    border-bottom: none;
}

.ai-chat-example-item:hover {
    background: var(--ai-chat-primary-soft);
    color: var(--ai-chat-text);
}

.ai-chat-example-item i:first-child {
    font-size: 14px;
    color: var(--ai-chat-text);
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.ai-chat-example-item span {
    flex: 1;
}

.ai-chat-example-arrow {
    display: none;
}

.ai-chat-panel.open.has-conversation.minimized .ai-chat-header-left {
    display: none;
}

.ai-chat-panel.open.has-conversation.minimized .ai-chat-header-actions {
    display: flex;
}

/* 新增資料按鈕 */
.ai-chat-voice-cmd-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    background: #4caf50;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.ai-chat-voice-cmd-btn:hover {
    background: #43a047;
}

.ai-chat-voice-cmd-btn i {
    font-size: 12px;
}

.ai-chat-voice-bottom-controls {
    display: none;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.ai-chat-panel.voice-active .ai-chat-voice-bottom-controls {
    display: flex;
}

/* 建議查詢按鈕 */
.ai-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    justify-content: center;
}

.ai-chat-suggestion-btn {
    padding: 6px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 16px;
    background: #fff;
    color: #555;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-chat-suggestion-btn:hover {
    border-color: #f5a623;
    color: #f5a623;
    background: #fff9f0;
}

/* 歡迎區塊 */
.ai-chat-welcome {
    text-align: center;
    padding: 60px 20px 20px;
    color: #666;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.ai-chat-welcome h3 {
    font-size: 14px;
    color: #999;
    margin-bottom: 4px;
    font-weight: 400;
}

.ai-chat-welcome h2 {
    font-size: 17px;
    color: #333;
    margin-bottom: 16px;
    font-weight: 600;
}

.ai-chat-welcome p {
    font-size: 13px;
    margin-bottom: 16px;
    color: #888;
}

/* 時間戳記 */
.ai-chat-timestamp {
    font-size: 11px;
    color: #999;
    text-align: center;
    margin: 4px 0;
}

/* 錯誤訊息 */
.ai-chat-message.error .ai-chat-message-content {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* 新增紀錄按鈕區 */
.ai-chat-voice-commands {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 0;
}

.ai-chat-voice-cmd-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    background: #fff;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.ai-chat-voice-cmd-btn:hover {
    border-color: #0078d4;
    background: #f0f8ff;
    box-shadow: 0 2px 8px rgba(0, 120, 212, 0.1);
}

.ai-chat-voice-cmd-btn i {
    font-size: 20px;
    color: #0078d4;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.ai-chat-voice-cmd-btn .cmd-text {
    display: flex;
    flex-direction: column;
}

.ai-chat-voice-cmd-btn .cmd-title {
    font-weight: 600;
    font-size: 14px;
}

.ai-chat-voice-cmd-btn .cmd-desc {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

/* 偵錯按鈕（訊息內） */
.ai-chat-debug-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 3px 10px;
    background: #fff8dc;
    border: 1px solid #e0c97f;
    border-radius: 12px;
    color: #8b7500;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    outline: none;
}

.ai-chat-debug-btn:hover {
    background: #fff0a0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

/* 偵錯 Modal 遮罩 */
.ai-chat-debug-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.ai-chat-debug-modal.open {
    display: flex;
}

/* 偵錯 Modal 視窗 */
.ai-chat-debug-modal-dialog {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: aiDebugModalIn 0.2s ease;
}

@keyframes aiDebugModalIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to   { opacity: 1; transform: scale(1)   translateY(0);    }
}

.ai-chat-debug-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #fff8dc;
    border-bottom: 1px solid #e0c97f;
    font-weight: 700;
    color: #8b7500;
    font-size: 14px;
    flex-shrink: 0;
}

.ai-chat-debug-modal-header i {
    margin-right: 6px;
}

.ai-chat-debug-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #8b7500;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s;
}

.ai-chat-debug-modal-close:hover {
    color: #5a4d00;
}

.ai-chat-debug-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 偵錯步驟（在 Modal 內） */
.ai-chat-debug-step {
    border: 1px solid #e8e0c0;
    border-radius: 6px;
    overflow: hidden;
}

.ai-chat-debug-step-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #fffef5;
    font-weight: 600;
    color: #6b5f00;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}

.ai-chat-debug-step-title::after {
    content: '▾';
    font-size: 10px;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.ai-chat-debug-step-title.collapsed::after {
    transform: rotate(-90deg);
}

.ai-chat-debug-step-content {
    background: #1e1e1e;
    color: #50fa7b;
    padding: 10px 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
}

.ai-chat-debug-step-content.collapsed {
    display: none;
}

/* 響應式 */
@media (max-width: 480px) {
    .ai-chat-panel {
        width: calc(100% - 16px);
        right: 8px;
        bottom: 8px;
        height: 85vh;
    }

    .ai-chat-panel.maximized {
        width: calc(100% - 16px);
        right: 8px;
        bottom: 8px;
        height: 90vh;
    }
}

/* 任務清單（工作分類使用） */
.ai-chat-task-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ai-chat-task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: background 0.15s;
}

.ai-chat-task-item:hover {
    background: #fafafa;
}

/* ==========================================
   歷史紀錄面板（側滑覆蓋）
   ========================================== */
.ai-chat-history-panel {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: #fff;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.ai-chat-history-panel.open {
    left: 0;
}

.ai-chat-history-header {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    gap: 8px;
}

.ai-chat-history-back-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.2s, background 0.2s;
}

.ai-chat-history-back-btn:hover {
    color: #333;
    background: #f0f0f0;
}

.ai-chat-history-title {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    text-align: center;
    margin-right: 34px; /* 補齊左側按鈕佔的空間，維持置中 */
}

.ai-chat-history-search {
    padding: 10px 14px;
    flex-shrink: 0;
}

.ai-chat-history-search-input {
    width: 100%;
    border: 1px solid #d0d0d0;
    border-radius: 20px;
    padding: 7px 14px 7px 32px;
    font-size: 13px;
    outline: none;
    background: #f7f7f7;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.ai-chat-history-search-input:focus {
    border-color: #5ab74f;
    background-color: #fff;
}

.ai-chat-history-search-input::placeholder {
    color: #bbb;
}

.ai-chat-history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.ai-chat-history-item {
    padding: 14px 18px;
    font-size: 14px;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s;
}

.ai-chat-history-item:hover {
    background: #f7f7f7;
}

.ai-chat-history-item.is-current {
    background: #f0faf0;
    color: #3a8c34;
    font-weight: 600;
}

.ai-chat-history-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #bbb;
    font-size: 14px;
}

.ai-chat-history-footer {
    flex-shrink: 0;
    padding: 12px 14px;
    border-top: 1px solid #eee;
}

.ai-chat-history-new-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: 20px;
    background: #5ab74f;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.ai-chat-history-new-btn:hover {
    background: #4da344;
}

.ai-chat-task-item:last-child {
    border-bottom: none;
}

.ai-chat-task-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chat-task-item-check {
    color: #4caf50;
    font-size: 14px;
}

.ai-chat-task-item-right {
    color: #ccc;
    font-size: 14px;
}

