/* ============================================
   科凯咨询 - AI 智能体客服（美化版）
   ============================================ */

#kk-chat-root {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 999999;
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1f2937;
}

/* === 触发按钮 === */
.kk-chat-trigger {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e4d7b 0%, #2563a0 50%, #c9953c 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(30, 77, 123, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}
.kk-chat-trigger:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 12px 32px rgba(30, 77, 123, 0.5);
}
.kk-chat-trigger:active { transform: scale(0.95); }
.kk-chat-trigger::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(201, 149, 60, 0.5);
    animation: kk-pulse 2s ease-out infinite;
    pointer-events: none;
}
@keyframes kk-pulse {
    0% { transform: scale(0.9); opacity: 1; }
    100% { transform: scale(1.4); opacity: 0; }
}
.kk-chat-trigger-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

/* === 聊天面板 === */
.kk-chat-panel {
    position: absolute;
    right: 0;
    bottom: 80px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 680px;
    max-height: calc(100vh - 100px);
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.kk-chat-panel.kk-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* === 头部 === */
.kk-chat-header {
    background: linear-gradient(135deg, #1e4d7b 0%, #2563a0 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.kk-chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c9953c 0%, #b8860b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(201, 149, 60, 0.4);
}
.kk-chat-info { flex: 1; min-width: 0; }
.kk-chat-name {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.3px;
}
.kk-chat-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}
.kk-pulse {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 8px #4ade80;
    animation: kk-status-pulse 1.5s ease-in-out infinite;
}
@keyframes kk-status-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.85); }
}
.kk-chat-close, .kk-chat-clear {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.15s ease;
}
.kk-chat-close:hover { background: rgba(255, 255, 255, 0.22); }
.kk-chat-clear:hover { background: rgba(255, 99, 99, 0.4); }

/* === 消息列表 === */
.kk-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    scroll-behavior: smooth;
}
.kk-chat-body::-webkit-scrollbar { width: 6px; }
.kk-chat-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
.kk-msg {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    align-items: flex-start;
}
.kk-msg-bot { flex-direction: row; }
.kk-msg-user { flex-direction: row-reverse; }
.kk-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}
.kk-msg-bot .kk-msg-avatar {
    background: linear-gradient(135deg, #c9953c 0%, #b8860b 100%);
    color: #fff;
}
.kk-msg-user .kk-msg-avatar {
    background: linear-gradient(135deg, #2563a0 0%, #1e4d7b 100%);
    color: #fff;
}
.kk-msg-bubble {
    max-width: 72%;
    padding: 10px 14px;
    border-radius: 14px;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    font-size: 14px;
    line-height: 1.55;
}
.kk-msg-bot .kk-msg-bubble {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-top-left-radius: 4px;
    color: #1f2937;
}
.kk-msg-user .kk-msg-bubble {
    background: linear-gradient(135deg, #2563a0 0%, #1e4d7b 100%);
    color: #fff;
    border-top-right-radius: 4px;
}
.kk-msg-typing .kk-msg-bubble {
    display: flex;
    gap: 4px;
    padding: 14px 16px;
}
.kk-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: kk-bounce 1.2s infinite;
}
.kk-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.kk-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes kk-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* === 输入区 === */
.kk-quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 16px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
}
.kk-quick-q {
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #ffffff;
    color: #475569;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}
.kk-quick-q:hover {
    border-color: #c9953c;
    color: #c9953c;
    background: #fef9e7;
}

.kk-chat-input {
    padding: 12px 16px 16px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.kk-chat-textarea {
    flex: 1;
    resize: none;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    color: #1f2937;
    background: #f8fafc;
    outline: none;
    min-height: 42px;
    max-height: 100px;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.kk-chat-textarea:focus {
    border-color: #2563a0;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 160, 0.08);
}
.kk-chat-send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563a0 0%, #1e4d7b 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, opacity 0.15s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(37, 99, 160, 0.3);
}
.kk-chat-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(37, 99, 160, 0.4);
}
.kk-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* ============================================
   ask_question 工具：表单卡片（美化）
   ============================================ */
.kk-form-card {
    margin: 8px 0 16px 40px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    border: 1px solid #e2e8f0;
    opacity: 0;
    transform: translateY(8px) scale(0.98);
    animation: kk-form-appear 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes kk-form-appear {
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.kk-form-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #1e4d7b 0%, #2563a0 100%);
    color: #fff;
}
.kk-form-banner-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.kk-form-banner-text { flex: 1; min-width: 0; }
.kk-form-banner-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.kk-form-banner-sub {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
    line-height: 1.4;
}

.kk-form-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.kk-field { display: flex; flex-direction: column; gap: 6px; }
.kk-label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 5px;
    letter-spacing: 0.2px;
}
.kk-label-icon { font-size: 14px; line-height: 1; }
.kk-req { color: #ef4444; font-weight: 700; margin-left: 2px; }

.kk-field input,
.kk-field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    color: #1f2937;
    background: #f8fafc;
    outline: none;
    transition: all 0.15s ease;
    box-sizing: border-box;
    resize: vertical;
}
.kk-field input:focus,
.kk-field textarea:focus {
    border-color: #2563a0;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 160, 0.1);
}
.kk-field input::placeholder,
.kk-field textarea::placeholder { color: #94a3b8; }

/* === 联系方式按钮组 === */
.kk-opt-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.kk-opt-btn {
    padding: 10px 8px;
    border: 1.5px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    line-height: 1.2;
}
.kk-opt-icon { font-size: 18px; line-height: 1; }
.kk-opt-label { font-size: 11px; }
.kk-opt-btn:hover:not(:disabled) {
    border-color: #c9953c;
    background: #fef9e7;
    transform: translateY(-1px);
}
.kk-opt-btn.kk-opt-active {
    border-color: #2563a0;
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #1e4d7b;
    box-shadow: 0 4px 10px rgba(37, 99, 160, 0.18);
    transform: translateY(-1px);
}
.kk-opt-btn.kk-opt-active .kk-opt-icon { transform: scale(1.1); }

/* === 联系值输入框（简洁版，无前缀标签） === */
.kk-contact-value {
    position: relative;
}
.kk-contact-value[data-type="wechat"] .kk-field input { border-color: #d1fae5; }
.kk-contact-value[data-type="wechat"] .kk-field input:focus { border-color: #059669; box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1); }
.kk-contact-value[data-type="email"] .kk-field input { border-color: #fef3c7; }
.kk-contact-value[data-type="email"] .kk-field input:focus { border-color: #c9953c; box-shadow: 0 0 0 3px rgba(201, 149, 60, 0.12); }

.kk-form-foot {
    padding: 8px 16px 0;
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.kk-form-lock { font-size: 12px; }

.kk-form-hint {
    padding: 0 16px 8px;
    font-size: 12px;
    color: #ef4444;
    text-align: center;
    font-weight: 500;
    min-height: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, max-height 0.2s ease, padding 0.2s ease;
}
.kk-form-hint.kk-form-hint-show {
    max-height: 40px;
    padding: 4px 16px 8px;
    opacity: 1;
}

/* === 操作按钮 === */
.kk-form-actions {
    padding: 0 16px 16px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.kk-btn {
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.kk-btn-skip {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}
.kk-btn-skip:hover:not(:disabled) {
    background: #e2e8f0;
    color: #475569;
}
.kk-btn-submit {
    background: linear-gradient(135deg, #c9953c 0%, #b8860b 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(201, 149, 60, 0.35);
    flex: 1;
}
.kk-btn-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(201, 149, 60, 0.45);
}
.kk-btn-submit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}
.kk-btn-done {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3) !important;
}

.kk-form-card.kk-form-done { opacity: 0.85; }
.kk-form-card.kk-form-skipped { opacity: 0.6; }

/* === send_email 内联确认 === */
.kk-email-result {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 14px 40px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border: 1px solid #86efac;
    border-radius: 20px;
    font-size: 12px;
    color: #065f46;
    opacity: 0;
    animation: kk-tool-fade 0.35s ease forwards;
}
.kk-er-icon { font-size: 14px; line-height: 1; }
@keyframes kk-tool-fade {
    to { opacity: 1; }
}

/* === 移动端 === */
@media (max-width: 480px) {
    #kk-chat-root { right: 12px; bottom: 12px; }
    .kk-chat-trigger { width: 56px; height: 56px; font-size: 24px; }
    .kk-chat-panel {
        width: calc(100vw - 24px);
        height: calc(100vh - 100px);
        bottom: 72px;
        right: 0;
        border-radius: 14px;
    }
    .kk-opt-group { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================
   自定义弹窗
   ============================================ */
#kk-modal-root {
    position: fixed;
    inset: 0;
    z-index: 9999999;
    pointer-events: none;
}

.kk-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    animation: kk-overlay-in 0.2s ease;
}
.kk-modal-overlay.kk-modal-closing {
    animation: kk-overlay-out 0.18s ease forwards;
}
@keyframes kk-overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes kk-overlay-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

.kk-modal {
    background: #ffffff;
    border-radius: 16px;
    padding: 28px 24px 20px;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.3);
    text-align: center;
    animation: kk-modal-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.kk-modal-overlay.kk-modal-closing .kk-modal {
    animation: kk-modal-out 0.18s ease forwards;
}
@keyframes kk-modal-in {
    from { opacity: 0; transform: translateY(12px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes kk-modal-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(8px) scale(0.96); }
}

.kk-modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 14px;
}
.kk-modal-icon-danger { background: linear-gradient(135deg, #fee2e2, #fecaca); }
.kk-modal-icon-primary { background: linear-gradient(135deg, #dbeafe, #bfdbfe); }
.kk-modal-icon-warning { background: linear-gradient(135deg, #fef3c7, #fde68a); }

.kk-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}
.kk-modal-message {
    font-size: 14px;
    color: #64748b;
    line-height: 1.55;
    margin-bottom: 22px;
}
.kk-modal-message strong { color: #ef4444; font-weight: 700; }

.kk-modal-actions {
    display: flex;
    gap: 10px;
}
.kk-modal-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}
.kk-modal-btn-cancel {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}
.kk-modal-btn-cancel:hover { background: #e2e8f0; }

.kk-modal-btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.kk-modal-btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

.kk-modal-btn-primary {
    background: linear-gradient(135deg, #2563a0, #1e4d7b);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 160, 0.3);
}
.kk-modal-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 160, 0.4);
}

.kk-modal-btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}
.kk-modal-btn-warning:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
}

/* ============================================
   联系表单弹窗（"发送咨询"按钮）
   ============================================ */
.kk-contact-modal {
    position: relative;
    max-width: 420px;
    padding: 0;
    text-align: left;
}
.kk-contact-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 8px;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
    z-index: 2;
}
.kk-contact-close:hover { background: #e2e8f0; color: #1f2937; }

.kk-contact-header {
    background: linear-gradient(135deg, #1e4d7b 0%, #2563a0 100%);
    color: #fff;
    padding: 28px 24px 22px;
    border-radius: 16px 16px 0 0;
    text-align: center;
}
.kk-contact-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 10px;
}
.kk-contact-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.kk-contact-sub {
    font-size: 13px;
    opacity: 0.85;
    margin-top: 4px;
}

.kk-contact-form {
    padding: 20px 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.kk-contact-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.kk-contact-label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 5px;
}
.kk-contact-label-icon { font-size: 14px; line-height: 1; }
.kk-contact-req { color: #ef4444; font-weight: 700; margin-left: 2px; }

.kk-contact-field input,
.kk-contact-field textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    color: #1f2937;
    background: #f8fafc;
    outline: none;
    transition: all 0.15s ease;
    box-sizing: border-box;
    resize: vertical;
}
.kk-contact-field input:focus,
.kk-contact-field textarea:focus {
    border-color: #2563a0;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 160, 0.1);
}
.kk-contact-field textarea {
    min-height: 80px;
    line-height: 1.5;
}

.kk-contact-foot {
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
    padding: 2px 0;
}

.kk-contact-submit {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #c9953c 0%, #b8860b 100%);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: all 0.15s ease;
    box-shadow: 0 6px 16px rgba(201, 149, 60, 0.35);
    font-family: inherit;
    margin-top: 4px;
}
.kk-contact-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(201, 149, 60, 0.45);
}
.kk-contact-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}