/**
 * 快账 AI 助手 — Gemini 风格样式
 */

/* ==================== 面板主容器 ==================== */
.kz-ai-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #fff;
    overflow: hidden;
}

.kz-ai-panel-toolbar {
    display: none;
}

/* ==================== 统一顶栏（历史/新对话/形态切换/关闭） ==================== */
.kz-ai-shell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 10px 16px;
    background: #fff;
    border-bottom: 1px solid #f1f3f4;
    flex-shrink: 0;
    user-select: none;
}

.kz-ai-floating .kz-ai-shell-header {
    cursor: grab;
    touch-action: none;
}

.kz-ai-dock-header {
    display: none;
}

.kz-ai-toolbar-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    color: #5f6368;
    line-height: 28px;
    text-align: center;
    transition: background 0.15s;
}

.kz-ai-toolbar-btn:hover {
    background: #f1f3f4;
}

.kz-ai-panel-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ==================== Gemini 欢迎区 ==================== */
.kz-ai-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px 20px;
}

.kz-ai-welcome-greeting {
    margin-bottom: 20px;
}

.kz-ai-welcome-name {
    display: block;
    font-size: 22px;
    font-weight: 400;
    color: #1f1f1f;
    line-height: 1.4;
}

.kz-ai-welcome-sub {
    display: block;
    font-size: 22px;
    font-weight: 400;
    color: #1f1f1f;
    line-height: 1.4;
}

.kz-ai-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kz-ai-suggestion-pill {
    display: inline-block;
    align-self: flex-start;
    padding: 10px 16px;
    background: #f1f3f4;
    border-radius: 20px;
    font-size: 13px;
    color: #3c4043;
    cursor: pointer;
    transition: background 0.15s;
    max-width: 100%;
    word-break: break-word;
}

.kz-ai-suggestion-pill:hover {
    background: #e8eaed;
}

.kz-ai-suggestion-pill.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==================== 当前标签页上下文条（Gemini 核心） ==================== */
.kz-ai-tab-context {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin: 0 12px 8px;
    background: #e8f0fe;
    border-radius: 20px;
    font-size: 12px;
    color: #3c4043;
    line-height: 1.4;
    min-height: 36px;
}

.kz-ai-tab-context-off {
    background: #f8f9fa;
    color: #80868b;
}

.kz-ai-tab-context-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: #1a73e8;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kz-ai-tab-context-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kz-ai-tab-context-title {
    font-weight: 500;
    color: #1a73e8;
}

.kz-ai-tab-context-close,
.kz-ai-tab-context-action {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    color: #5f6368;
    font-size: 12px;
    transition: background 0.15s;
}

.kz-ai-tab-context-action {
    width: auto;
    padding: 0 8px;
    font-size: 12px;
    color: #1a73e8;
}

.kz-ai-tab-context-close:hover,
.kz-ai-tab-context-action:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* ==================== Gemini 输入区 ==================== */
.kz-ai-input-wrap {
    position: relative;
    flex-shrink: 0;
    padding-bottom: 12px;
}

.kz-ai-input-box {
    margin: 0 12px;
    border: 1px solid #dadce0;
    border-radius: 24px;
    background: #fff;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.kz-ai-input-box:focus-within {
    border-color: #1a73e8;
    box-shadow: 0 1px 6px rgba(26, 115, 232, 0.2);
}

/* @指令 chip 标签 */
.kz-ai-input-editor {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 14px 2px;
}

.kz-ai-input-editor.has-cmd {
    padding-top: 8px;
}

.kz-ai-at-chip {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    height: 26px;
    margin-top: 2px;
    padding: 0 10px;
    background: #e8f0fe;
    color: #1a73e8;
    font-size: 13px;
    font-weight: 500;
    border-radius: 13px;
    line-height: 26px;
    white-space: nowrap;
    user-select: none;
}

.kz-ai-input-field {
    flex: 1;
    min-width: 80px;
    padding: 2px 0 2px !important;
    font-size: 14px !important;
    resize: none !important;
}

.kz-ai-input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px 8px 12px;
}

.kz-ai-input-tools {
    display: flex;
    gap: 4px;
}

.kz-ai-send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #e8eaed;
    color: #9aa0a6;
    cursor: not-allowed;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.kz-ai-send-btn.is-active {
    background: #1a73e8;
    color: #fff;
    cursor: pointer;
}

.kz-ai-send-btn.is-active:hover {
    background: #1557b0;
}

.kz-ai-send-stop {
    width: auto;
    padding: 0 14px;
    border-radius: 18px;
    background: #fce8e6;
    color: #d93025;
    cursor: pointer;
    font-size: 13px;
}

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

/* ==================== 消息列表 ==================== */
.kz-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.kz-ai-msg {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.kz-ai-msg-user {
    flex-direction: row-reverse;
}

.kz-ai-msg-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
}

.kz-ai-msg-user .kz-ai-msg-avatar {
    background: #1a73e8;
}

.kz-ai-msg-ai .kz-ai-msg-avatar {
    background: linear-gradient(135deg, #4285f4 0%, #9b72cb 100%);
}

.kz-ai-msg-body {
    max-width: 82%;
}

.kz-ai-msg-content {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
}

.kz-ai-msg-user .kz-ai-msg-content {
    background: #e8f0fe;
    color: #1f1f1f;
    border-bottom-right-radius: 4px;
}

.kz-ai-msg-user-text {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kz-ai-msg-skill {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    background: #d2e3fc;
    color: #1a73e8;
    font-size: 12px;
    font-weight: 500;
    border-radius: 11px;
    line-height: 22px;
    white-space: nowrap;
}

.kz-ai-msg-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.kz-ai-msg-ai .kz-ai-msg-content {
    background: #f8f9fa;
    color: #3c4043;
    border-bottom-left-radius: 4px;
}

.kz-ai-msg-ai .kz-ai-msg-content strong {
    color: #1a73e8;
}

.kz-ai-msg-ai .kz-ai-msg-content code {
    background: #e8eaed;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
}

.kz-ai-msg-ai .kz-ai-msg-content pre {
    background: #282c34;
    color: #abb2bf;
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.kz-ai-msg-actions {
    display: flex;
    gap: 12px;
    margin-top: 4px;
    padding-left: 4px;
}

.kz-ai-msg-action {
    font-size: 11px;
    color: #80868b;
    cursor: pointer;
}

.kz-ai-msg-action:hover {
    color: #1a73e8;
}

.kz-ai-cursor {
    display: inline-block;
    animation: kz-ai-cursor-blink 0.8s step-end infinite;
    color: #1a73e8;
    font-weight: 700;
}

.kz-ai-thinking {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #80868b;
    font-size: 13px;
}

@keyframes kz-ai-cursor-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ==================== 历史对话 ==================== */
.kz-ai-history-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.kz-ai-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #e8eaed;
    font-size: 15px;
    font-weight: 500;
}

.kz-ai-history-list {
    flex: 1;
    overflow-y: auto;
}

.kz-ai-history-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f4;
}

.kz-ai-history-item:hover {
    background: #f8f9fa;
}

.kz-ai-history-title {
    font-size: 13px;
    color: #3c4043;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kz-ai-history-meta {
    margin-top: 4px;
    font-size: 11px;
    color: #80868b;
    display: flex;
    gap: 12px;
}

/* ==================== 浮窗模式（Gemini 小窗） ==================== */
.kz-ai-floating {
    position: fixed;
    z-index: 1050;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 0 1px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e8eaed;
}

.kz-ai-floating-header {
    display: none;
}

.kz-ai-floating-logo {
    font-size: 14px;
    font-weight: 500;
    color: #1a73e8;
}

.kz-ai-header-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    color: #5f6368;
    line-height: 32px;
    text-align: center;
}

.kz-ai-header-btn:hover {
    background: #f1f3f4;
}

.kz-ai-floating .kz-ai-panel {
    flex: 1;
    min-height: 0;
}

.kz-ai-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 16px;
    height: 16px;
    cursor: se-resize;
    touch-action: none;
    background: linear-gradient(135deg, transparent 50%, #dadce0 50%, #dadce0 60%, transparent 60%, transparent 70%, #dadce0 70%, #dadce0 80%, transparent 80%);
    border-radius: 0 0 16px 0;
}

.kz-ai-resize-handle:hover {
    background: linear-gradient(135deg, transparent 50%, #1a73e8 50%, #1a73e8 60%, transparent 60%, transparent 70%, #1a73e8 70%, #1a73e8 80%, transparent 80%);
}

/* ==================== 侧栏模式（fixed 独立面板，不覆盖主内容） ==================== */
.kz-ai-dock-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    background: #fff;
    border-left: 1px solid #e8eaed;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.kz-ai-dock-sidebar.is-open {
    transform: translateX(0);
}

.kz-ai-dock-sidebar .kz-ai-panel {
    flex: 1;
    min-height: 0;
}

/* 侧栏宽度拖拽手柄 */
.kz-ai-dock-resize-handle {
    position: absolute;
    left: -3px;
    top: 0;
    width: 6px;
    height: 100%;
    cursor: ew-resize;
    z-index: 10;
}

.kz-ai-dock-resize-handle:hover,
.kz-ai-dock-resize-handle:active {
    background: rgba(24, 144, 255, 0.3);
}

/* 主内容区域过渡动画 */
.main-index .main-content {
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-index .kz-header.content {
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0s;
}

/* ==================== 技能横向选择栏 ==================== */
.kz-ai-skill-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 12px 10px;
    padding: 8px 0 0;
}

.kz-ai-skill-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid #e8eaed;
    border-radius: 14px;
    font-size: 12px;
    color: #5f6368;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    white-space: nowrap;
}

.kz-ai-skill-pill:hover {
    background: #f1f3f4;
    border-color: #dadce0;
}

.kz-ai-skill-pill.is-active {
    background: #e8f0fe;
    border-color: #1a73e8;
    color: #1a73e8;
    font-weight: 500;
}

.kz-ai-skill-pill.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.kz-ai-skill-pill-icon {
    font-size: 13px;
}

/* 拖拽上传视觉反馈 */
.kz-ai-input-box.is-drag-over {
    border-color: #1a73e8 !important;
    background: #e8f0fe !important;
}

/* ==================== 凭证操作按钮 ==================== */
.kz-ai-voucher-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-left: 4px;
}

.kz-ai-voucher-fill-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 16px;
    background: #1a73e8;
    color: #fff;
    border: none;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.kz-ai-voucher-fill-btn:hover {
    background: #1557b0;
}

.kz-ai-voucher-fill-btn.is-filling {
    background: #e8eaed;
    color: #5f6368;
    cursor: not-allowed;
}

/* ==================== 文件附件列表 ==================== */
.kz-ai-file-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 12px 4px;
}

.kz-ai-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 12px;
    color: #3c4043;
    transition: background 0.15s;
}

.kz-ai-file-item.is-uploading {
    background: #e8f0fe;
}

.kz-ai-file-item.is-error {
    background: #fce8e6;
}

.kz-ai-file-icon {
    flex-shrink: 0;
    font-size: 16px;
}

.kz-ai-file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kz-ai-file-status {
    flex-shrink: 0;
    font-size: 11px;
    color: #1a73e8;
}

.kz-ai-file-error {
    color: #d93025;
}

.kz-ai-file-remove {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    color: #80868b;
    font-size: 11px;
    transition: background 0.15s, color 0.15s;
}

.kz-ai-file-remove:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #d93025;
}

/* 附件按钮 */
.kz-ai-tool-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #5f6368;
    font-size: 18px;
    transition: background 0.15s;
}

.kz-ai-tool-btn:hover {
    background: #f1f3f4;
}

.kz-ai-tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==================== 凭证卡片展示 ==================== */
.kz-ai-voucher-cards {
    margin-top: 10px;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.kz-ai-voucher-cards-header {
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
}

.kz-ai-voucher-cards-list {
    max-height: 360px;
    overflow-y: auto;
}

.kz-ai-voucher-card {
    padding: 10px 14px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background 0.15s;
}

.kz-ai-voucher-card:hover {
    background: #f9f9f9;
}

.kz-ai-voucher-card:last-child {
    border-bottom: none;
}

.kz-ai-voucher-card-head {
    display: flex;
    align-items: center;
}

.kz-ai-voucher-card-title {
    font-weight: 600;
    font-size: 13px;
    color: #333;
}

.kz-ai-voucher-card-amount {
    margin-left: auto;
    font-weight: 600;
    font-size: 14px;
    color: #1890ff;
}

.kz-ai-voucher-card-entries {
    margin-top: 8px;
    padding-left: 4px;
}

.kz-ai-voucher-card-entry {
    display: flex;
    flex-direction: column;
    padding: 3px 0;
    font-size: 12px;
    color: #666;
}

.kz-ai-voucher-entry-label {
    color: #999;
    font-size: 11px;
    margin-bottom: 2px;
}

.kz-ai-voucher-entry-detail {
    display: flex;
    align-items: center;
    gap: 6px;
}

.kz-ai-voucher-entry-dir {
    display: inline-block;
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 2px;
    font-size: 10px;
    font-weight: 600;
}

.kz-ai-voucher-entry-dir.debit {
    background: #e6f7ff;
    color: #1890ff;
}

.kz-ai-voucher-entry-dir.credit {
    background: #fff7e6;
    color: #fa8c16;
}

.kz-ai-voucher-cards-footer {
    padding: 10px 14px;
    border-top: 1px solid #f0f0f0;
    text-align: right;
}

.kz-ai-voucher-generate-btn {
    display: inline-block;
    padding: 6px 20px;
    background: #1890ff;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.kz-ai-voucher-generate-btn:hover {
    background: #40a9ff;
}

/* ==================== 顶栏入口 ==================== */
.kz-ai-assistant-btn {
    display: inline-block;
    margin-right: 10px;
    transition: opacity 0.2s;
}

.kz-ai-assistant-btn:hover {
    opacity: 0.8;
}
