/**
 * AI Chat Bubble V2 - 樣式表（雙欄式介面版本）
 * 新北市無紙化 AI 系統管理後台
 * 
 * @version 2.0.0
 * @date 2026-02-03
 */

/* 2026.02.03 建立雙欄式介面版本樣式：左側對話區、右側快速問題集 */
/* 2025.11.17 建立獨立的 AI 對話氣泡 CSS 檔案 */
/* 2025.11.21 新增五星評等機制樣式 */
/* 2025.12.18 新增參考來源區塊樣式、Tooltip 與 Modal 展示 */
/* 2025.12.31 新增使用者姓名輸入遮罩樣式 */

/* ==================== 觸發按鈕 ==================== */
.ai-chat-trigger {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 120px;
    height: 120px;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 9997;
}

.ai-chat-trigger:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.ai-chat-trigger svg,
.ai-chat-trigger img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: transparent;
}

.ai-chat-trigger:hover::before {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(107, 174, 214, 0.25);
    animation: pulse 2s infinite;
    pointer-events: none;
}

@keyframes pulse {
    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0;
    }
}

/* ==================== 對話視窗（雙欄式佈局） ==================== */
/* 2026.02.03 雙欄式佈局：預設寬度擴大至 800px，高度 650px */
.ai-chat-window-v2 {
    position: fixed;
    right: 24px;
    bottom: 100px;
    width: 800px;
    height: 650px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    animation: slideUp 0.3s ease-out;
    transform-origin: right bottom;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chat-window-v2.open {
    display: flex;
}

/* 2026.02.03 單欄模式：隱藏快速問題面板時恢復 v1 寬度 */
.ai-chat-window-v2.single-column {
    width: 380px;
    height: 600px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== 標題列 ==================== */
.ai-chat-header-v2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    padding: 0 20px;
    background: linear-gradient(135deg, #6baed6 0%, #4a90c8 100%);
    color: #ffffff;
    border-radius: 12px 12px 0 0;
}

.ai-chat-title-v2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
}

.ai-chat-actions-v2 {
    display: flex;
    gap: 8px;
}

.ai-chat-action-btn-v2 {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-chat-action-btn-v2:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ai-chat-action-btn-v2 svg {
    width: 18px;
    height: 18px;
    stroke: #ffffff;
    fill: none;
}

/* ==================== 主體區域（雙欄佈局） ==================== */
/* 2026.02.03 雙欄式佈局：左側對話區 60%、右側快速問題集 40% */
.ai-chat-body-v2 {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: #f8f9fa;
}

/* 左側：對話區域 */
.ai-chat-conversation-panel {
    flex: 6;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e8e8e8;
    background: #f8f9fa;
}

/* 右側：快速問題集 */
.ai-chat-quick-panel {
    flex: 4;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    overflow: hidden;
}

/* ==================== 左側對話區域樣式 ==================== */
.ai-chat-messages-v2 {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 自訂捲軸 */
.ai-chat-messages-v2::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages-v2::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages-v2::-webkit-scrollbar-thumb {
    background: #d9d9d9;
    border-radius: 3px;
}

.ai-chat-messages-v2::-webkit-scrollbar-thumb:hover {
    background: #bfbfbf;
}

/* ==================== 訊息氣泡 ==================== */
.message-v2 {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-v2.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-v2.ai {
    align-self: flex-start;
}

.message-avatar-v2 {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.message-avatar-v2 svg {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.message-avatar-v2 .robot-avatar-v2 {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
    transform: scaleX(-1);
}

.message-v2.user .message-avatar-v2 {
    background: #667eea;
    color: #ffffff;
}

.message-v2.ai .message-avatar-v2 {
    background: #ffffff;
    color: #667eea;
}

.message-bubble-v2 {
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.message-v2.ai .message-bubble-v2 {
    white-space: normal;
}

.message-v2.user .message-bubble-v2 {
    white-space: pre-wrap;
}

/* Markdown 元素樣式 */
.message-bubble-v2 h2,
.message-bubble-v2 h3,
.message-bubble-v2 h4 {
    margin: 8px 0 4px 0;
    font-weight: 600;
    line-height: 1.4;
}

.message-bubble-v2 h2 {
    font-size: 16px;
    color: #262626;
}

.message-bubble-v2 h3 {
    font-size: 15px;
    color: #262626;
}

.message-bubble-v2 h4 {
    font-size: 14px;
    color: #595959;
}

.message-bubble-v2 p {
    margin: 4px 0;
    line-height: 1.6;
}

.message-bubble-v2 p:first-child {
    margin-top: 0;
}

.message-bubble-v2 p:last-child {
    margin-bottom: 0;
}

.message-bubble-v2 strong {
    font-weight: 600;
    color: #262626;
}

.message-bubble-v2 em {
    font-style: italic;
}

.message-bubble-v2 code {
    background: #f5f5f5;
    color: #d73a49;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
}

.message-bubble-v2 a {
    color: #667eea;
    text-decoration: underline;
}

.message-bubble-v2 a:hover {
    color: #764ba2;
}

.message-bubble-v2 ul,
.message-bubble-v2 ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-bubble-v2 ul {
    list-style-type: disc;
}

.message-bubble-v2 ol {
    list-style-type: decimal;
}

.message-bubble-v2 li {
    margin: 4px 0;
    line-height: 1.6;
}

.message-bubble-v2 br {
    display: block;
    content: "";
    margin: 4px 0;
}

/* Markdown 表格樣式 */
.message-bubble-v2 .markdown-table-v2 {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    background: white;
    font-size: 13px;
    line-height: 1.5;
    overflow-x: auto;
    display: block;
}

.message-bubble-v2 .markdown-table-v2 th,
.message-bubble-v2 .markdown-table-v2 td {
    border: 1px solid #e0e0e0;
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
    word-wrap: break-word;
    word-break: break-word;
}

.message-bubble-v2 .markdown-table-v2 th {
    background: #f5f5f5;
    font-weight: 600;
    color: #262626;
    font-size: 13px;
}

.message-bubble-v2 .markdown-table-v2 td {
    background: white;
    color: #262626;
}

.message-bubble-v2 .markdown-table-v2 tr:nth-child(even) td {
    background: #fafafa;
}

.message-bubble-v2 .markdown-table-v2 tr:hover td {
    background: #f0f0f0;
}

.message-bubble-v2 .markdown-table-v2 strong {
    font-weight: 600;
    color: #667eea;
}

.message-v2.user .message-bubble-v2 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.message-v2.user .message-bubble-v2 strong,
.message-v2.user .message-bubble-v2 h2,
.message-v2.user .message-bubble-v2 h3,
.message-v2.user .message-bubble-v2 h4 {
    color: #ffffff;
}

.message-v2.user .message-bubble-v2 code {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.message-v2.user .message-bubble-v2 a {
    color: #ffffff;
    text-decoration: underline;
}

.message-v2.ai .message-bubble-v2 {
    background: #ffffff;
    color: #262626;
    border: 1px solid #e8e8e8;
    border-bottom-left-radius: 4px;
}

.message-time-v2 {
    font-size: 11px;
    color: #8c8c8c;
    margin-top: 4px;
    text-align: right;
}

/* ==================== 打字指示器 ==================== */
.typing-indicator-v2 {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e8e8e8;
    border-bottom-left-radius: 4px;
}

.typing-indicator-v2 span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #8c8c8c;
    animation: typing 1.4s infinite;
}

.typing-indicator-v2 span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator-v2 span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ==================== 輸入區域 ==================== */
.ai-chat-input-area-v2 {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #ffffff;
    border-top: 1px solid #e8e8e8;
}

.ai-chat-input-v2 {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC",
        "Microsoft JhengHei", sans-serif;
    transition: border-color 0.2s;
    max-height: 100px;
    height: var(--input-height, auto);
}

.ai-chat-input-v2:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.ai-chat-input-v2::placeholder {
    color: #bfbfbf;
}

.ai-chat-input-v2::-webkit-scrollbar {
    width: 4px;
}

.ai-chat-input-v2::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-input-v2::-webkit-scrollbar-thumb {
    background: #d9d9d9;
    border-radius: 2px;
}

.ai-chat-send-btn-v2 {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-chat-send-btn-v2:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.ai-chat-send-btn-v2:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-chat-send-btn-v2 svg {
    width: 20px;
    height: 20px;
    stroke: #ffffff;
    fill: none;
}

/* ==================== 右側快速問題集 ==================== */
/* 2026.03.25 右側快速問題集改版：五頁籤 Toggle + 分組題目 */
.ai-chat-quick-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e8e8e8;
    background: #ffffff;
}

.ai-chat-quick-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #262626;
    margin-bottom: 10px;
}

.ai-chat-quick-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.ai-chat-quick-tab {
    /* 2026.03.25 微調：縮小字級並維持單行，避免五字頁籤換行 */
    min-height: 42px;
    border: 2px solid #2d6f8f;
    background: #48a9c5;
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
    text-align: center;
    padding: 6px 8px;
    cursor: pointer;
    transition:
        filter 0.2s ease,
        transform 0.2s ease;
}

.ai-chat-quick-tab:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

.ai-chat-quick-tab:active {
    transform: translateY(0);
}

.ai-chat-quick-tab.active {
    background: #f49a41;
}

.ai-chat-quick-tab.tab-span-2 {
    grid-column: span 2;
}

.ai-chat-quick-tab.external-tab {
    /* 2026.03.30 外連箭頭與文字同列，避免箭頭覆蓋文字 */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.ai-chat-quick-tab.external-tab::after {
    content: "↗";
    font-size: 11px;
    line-height: 1;
    transform: translateY(-1px);
}

.ai-chat-quick-list {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ai-chat-quick-list::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-quick-list::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-quick-list::-webkit-scrollbar-thumb {
    background: #d9d9d9;
    border-radius: 3px;
}

.ai-chat-quick-list::-webkit-scrollbar-thumb:hover {
    background: #bfbfbf;
}

.ai-chat-quick-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    padding: 2px 0;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: color 0.2s;
    text-align: left;
    font-size: 13px;
    color: #262626;
    font-family: inherit;
    box-shadow: none;
}

.ai-chat-quick-item:hover {
    color: #005fa3;
}

.ai-chat-quick-item:active {
    color: #004a80;
}

.quick-item-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.quick-item-text {
    flex: 1;
    line-height: 1.4;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

.ai-chat-quick-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-chat-quick-group-title {
    margin: 0;
    font-size: 15px;
    line-height: 1.35;
    color: #0077c8;
    font-weight: 700;
}

.ai-chat-quick-empty {
    padding: 14px;
    border: 1px dashed #bfbfbf;
    border-radius: 8px;
    color: #8c8c8c;
    text-align: center;
    font-size: 13px;
}

/* ==================== 全畫面模式 ==================== */
.ai-chat-window-v2.fullscreen {
    top: 20px;
    right: 20px;
    bottom: 20px;
    left: 20px;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    border-radius: 12px;
    z-index: 9999;
}

.ai-chat-window-v2.fullscreen .ai-chat-messages-v2 {
    padding: 24px;
    gap: 16px;
}

.ai-chat-window-v2.fullscreen .message-v2 {
    max-width: 70%;
}

.ai-chat-window-v2.fullscreen .ai-chat-input-area-v2 {
    padding: 20px 24px;
}

/* ==================== 評價系統 ==================== */
.message-rating-v2 {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
}

.message-rating-label-v2 {
    font-size: 11px;
    color: #8c8c8c;
    margin-right: 4px;
}

.rating-star-v2 {
    width: 18px;
    height: 18px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.rating-star-v2:hover:not(.rated) {
    transform: scale(1.15);
}

.rating-star-v2.rated {
    cursor: default;
}

.rating-star-v2 svg {
    width: 16px;
    height: 16px;
    transition: all 0.2s ease;
}

.rating-star-v2:not(.active):not(.rated) svg {
    fill: none;
    stroke: #d9d9d9;
    stroke-width: 1.5;
}

.rating-star-v2:hover:not(.rated) svg,
.rating-star-v2.hover-preview:not(.rated) svg {
    fill: none;
    stroke: #faad14;
    stroke-width: 1.5;
}

.rating-star-v2.active svg,
.rating-star-v2.rated svg {
    fill: #faad14;
    stroke: #faad14;
    stroke-width: 1;
}

.message-rating-v2.rated {
    opacity: 0.8;
}

.rating-feedback-v2 {
    font-size: 11px;
    color: #52c41a;
    margin-left: 8px;
    animation: fadeIn 0.3s ease;
}

.rating-error-v2 {
    font-size: 11px;
    color: #f5222d;
    margin-left: 8px;
    animation: fadeIn 0.3s ease;
}

.rating-star-v2:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    border-radius: 4px;
}

/* ==================== 參考來源區塊 ==================== */
.ai-chat-reference-section-v2 {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.ai-chat-reference-title-v2 {
    font-size: 12px;
    color: #8c8c8c;
    margin-bottom: 8px;
    font-weight: 500;
}

.ai-chat-reference-links-v2 {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-chat-reference-link-v2 {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    line-height: 1.5;
}

.ai-chat-reference-link-v2.qa-type {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #90caf9;
}

.ai-chat-reference-link-v2.qa-type:hover {
    background: #bbdefb;
    box-shadow: 0 2px 4px rgba(25, 118, 210, 0.2);
}

.ai-chat-reference-link-v2.law-type {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.ai-chat-reference-link-v2.law-type:hover {
    background: #ffcdd2;
    box-shadow: 0 2px 4px rgba(198, 40, 40, 0.2);
}

/* Tooltip 樣式 */
.ai-chat-reference-tooltip-v2 {
    position: fixed;
    max-width: 320px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 16px;
    z-index: 10000;
    display: none;
    animation: tooltipFadeIn 0.2s ease-out;
    pointer-events: none;
}

.ai-chat-reference-tooltip-v2.show {
    display: block;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tooltip-header-v2 {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.tooltip-icon-v2 {
    font-size: 16px;
}

.tooltip-type-v2 {
    font-size: 13px;
    font-weight: 600;
    color: #262626;
}

.tooltip-content-v2 {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tooltip-field-v2 {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tooltip-label-v2 {
    font-size: 11px;
    color: #8c8c8c;
    font-weight: 500;
}

.tooltip-value-v2 {
    font-size: 12px;
    color: #262626;
    line-height: 1.5;
    word-break: break-word;
}

.tooltip-field-v2.similarity .tooltip-value-v2 {
    font-weight: 600;
    color: #52c41a;
}

/* Modal 詳情展示 */
.ai-chat-reference-modal-v2 {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: fadeIn 0.2s ease;
}

.ai-chat-reference-modal-v2.show {
    display: flex;
}

.ai-chat-reference-modal-content-v2 {
    background: #ffffff;
    border-radius: 12px;
    max-width: 600px;
    max-height: 80vh;
    width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.ai-chat-reference-modal-header-v2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e8e8e8;
}

.ai-chat-reference-modal-title-v2 {
    font-size: 18px;
    font-weight: 600;
    color: #262626;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chat-reference-modal-close-v2 {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #8c8c8c;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 20px;
}

.ai-chat-reference-modal-close-v2:hover {
    background: #f5f5f5;
    color: #262626;
}

.ai-chat-reference-modal-body-v2 {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-detail-section-v2 {
    margin-bottom: 20px;
}

.modal-detail-section-v2:last-child {
    margin-bottom: 0;
}

.modal-detail-label-v2 {
    font-size: 12px;
    color: #8c8c8c;
    font-weight: 500;
    margin-bottom: 8px;
}

.modal-detail-value-v2 {
    font-size: 14px;
    color: #262626;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.modal-detail-similarity-v2 {
    display: inline-block;
    background: #f0f9ff;
    color: #0369a1;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
}

/* ==================== 使用者姓名輸入遮罩 ==================== */
.ai-chat-username-overlay-v2 {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.ai-chat-username-prompt-v2 {
    background: #ffffff;
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 360px;
    width: 90%;
    animation: slideUp 0.3s ease;
}

.ai-chat-username-prompt-v2 h3 {
    margin: 0 0 12px 0;
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
    text-align: center;
}

.ai-chat-username-prompt-v2 p {
    margin: 0 0 24px 0;
    font-size: 14px;
    color: #666666;
    text-align: center;
}

.ai-chat-username-input-group-v2 {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.ai-chat-username-input-v2 {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.ai-chat-username-input-v2:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.ai-chat-username-submit-v2 {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ai-chat-username-submit-v2:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-chat-username-submit-v2:active {
    transform: translateY(0);
}

.ai-chat-username-error-v2 {
    color: #dc3545;
    font-size: 13px;
    text-align: center;
    margin-top: 8px;
    animation: shake 0.3s ease;
}

.ai-chat-window-v2.fullscreen .ai-chat-username-overlay-v2 {
    position: fixed;
    border-radius: 0;
}

.ai-chat-window-v2.fullscreen .ai-chat-username-prompt-v2 {
    max-width: 400px;
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

/* ==================== 響應式設計 ==================== */
/* 2026.02.03 平板版：垂直堆疊兩欄 */
@media (max-width: 1024px) {
    .ai-chat-window-v2 {
        width: 90vw;
        max-width: 700px;
    }

    .ai-chat-body-v2 {
        flex-direction: column;
    }

    .ai-chat-conversation-panel {
        flex: 7;
        border-right: none;
        border-bottom: 1px solid #e8e8e8;
    }

    .ai-chat-quick-panel {
        flex: 3;
        max-height: 250px;
    }
}

/* 手機版：單欄全螢幕，隱藏快速問題集 */
@media (max-width: 768px) {
    .ai-chat-window-v2 {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        right: 0;
        bottom: 0;
        border-radius: 0;
    }

    .ai-chat-header-v2 {
        height: 56px;
        border-radius: 0;
    }

    .ai-chat-body-v2 {
        flex-direction: column;
    }

    .ai-chat-conversation-panel {
        flex: 1;
    }

    /* 手機版隱藏快速問題集 */
    .ai-chat-quick-panel {
        display: none;
    }

    .ai-chat-input-area-v2 {
        border-radius: 0;
    }

    .ai-chat-trigger {
        width: 56px;
        height: 56px;
        right: 16px;
        bottom: 16px;
    }

    .message-v2 {
        max-width: 90%;
    }

    .ai-chat-messages-v2 {
        padding: 12px;
    }

    .ai-chat-window-v2.fullscreen {
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        height: auto;
        border-radius: 0;
    }

    .ai-chat-window-v2.fullscreen .ai-chat-messages-v2 {
        padding: 16px;
    }

    .ai-chat-window-v2.fullscreen .message-v2 {
        max-width: 85%;
    }

    .ai-chat-username-prompt-v2 {
        padding: 24px 20px;
        max-width: 320px;
    }

    .ai-chat-username-prompt-v2 h3 {
        font-size: 18px;
    }

    .ai-chat-username-input-group-v2 {
        flex-direction: column;
    }

    .ai-chat-username-submit-v2 {
        width: 100%;
    }
}

/* ==================== 無障礙優化 ==================== */
.ai-chat-trigger:focus,
.ai-chat-action-btn-v2:focus,
.ai-chat-send-btn-v2:focus,
.ai-chat-quick-tab:focus,
.ai-chat-quick-item:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.ai-chat-input-v2:focus {
    outline: none;
}

/* 高對比度模式 */
@media (prefers-contrast: high) {
    .ai-chat-window-v2 {
        border: 2px solid #000000;
    }

    .message-bubble-v2 {
        border-width: 2px;
    }

    .ai-chat-quick-item {
        border-width: 2px;
    }
}

/* 減少動畫 */
@media (prefers-reduced-motion: reduce) {
    .ai-chat-trigger.pulse::before {
        animation: none;
    }

    .ai-chat-window-v2 {
        animation: none;
    }

    .message-v2 {
        animation: none;
    }

    .typing-indicator-v2 span {
        animation: none;
    }

    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ==================== 通用工具類別 ==================== */
.hidden {
    display: none !important;
}

.fade-out {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-chat-reference-tooltip-v2 {
    top: var(--tooltip-top-v2, 0);
    left: var(--tooltip-left-v2, 0);
}
