/*!
 * chatbot.css — 广奇官网在线客服浮窗样式（全站注入）
 * 前缀 gk-，避免与页面既有样式冲突。主题色跟随站点蓝色系。
 */

/* ---------------- 根容器 ---------------- */
.gk-root {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 2147483000;
    font-family: 'Inter', 'Microsoft YaHei', -apple-system, sans-serif;
}

/* ---------------- 悬浮按钮 ---------------- */
.gk-fab {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    cursor: pointer;
    padding: 14px 18px;
    border-radius: 999px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
    transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
    font-size: 15px;
    font-weight: 600;
}
.gk-fab svg {
    width: 24px;
    height: 24px;
    flex: none;
}
.gk-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.45);
}
.gk-fab.gk-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(.6);
}
.gk-fab-label {
    white-space: nowrap;
}

/* ---------------- 面板 ---------------- */
.gk-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    width: min(390px, calc(100vw - 24px));
    height: min(620px, calc(100vh - 48px));
    /* 优先用动态视口高度：移动端 100vh 取的是地址栏隐藏时的大视口，
       比真实可视高度大，贴底面板会顶出屏幕。不支持的浏览器自动忽略本行。 */
    height: min(620px, calc(100dvh - 48px));
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.28);
    border: 1px solid rgba(148, 163, 184, 0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(.96);
    transform-origin: bottom right;
    transition: opacity .22s ease, transform .22s ease, visibility .22s;
}
.gk-panel.gk-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* 头部 */
.gk-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 16px 18px;
    color: #fff;
    background: linear-gradient(135deg, #2563eb 0%, #1e3a8a 100%);
    flex: none;
}
.gk-head-txt {
    min-width: 0;
}
.gk-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .2px;
}
.gk-sub {
    font-size: 12px;
    opacity: .82;
    margin-top: 2px;
}
.gk-icon-btn {
    border: 0;
    background: rgba(255, 255, 255, .18);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    flex: none;
    transition: background .2s ease;
}
.gk-icon-btn:hover {
    background: rgba(255, 255, 255, .32);
}
.gk-icon-btn svg {
    width: 15px;
    height: 15px;
    display: block;
    margin: 0 auto;
}

/* 消息滚动区 */
.gk-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #f8fafc;
    padding: 16px 14px 4px;
}
.gk-msgs {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.gk-msg {
    display: flex;
}
.gk-user {
    justify-content: flex-end;
}
.gk-assistant {
    justify-content: flex-start;
}
.gk-bubble {
    max-width: 86%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    color: #0f172a;
    background: #fff;
    border: 1px solid rgba(148, 163, 184, .22);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.gk-user .gk-bubble {
    color: #fff;
    background: #2563eb;
    border-color: #2563eb;
    border-bottom-right-radius: 4px;
}
.gk-assistant .gk-bubble {
    border-bottom-left-radius: 4px;
}
.gk-error .gk-bubble {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fecaca;
}
.gk-bubble p {
    margin: 0 0 6px;
}
.gk-bubble p:last-child {
    margin-bottom: 0;
}
.gk-list {
    margin: 4px 0;
    padding-left: 18px;
}
.gk-list li {
    margin: 3px 0;
}
.gk-bubble a {
    color: #2563eb;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
    cursor: pointer;
}
.gk-bubble a:hover {
    color: #1d4ed8;
}

/* 正在输入 */
.gk-typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 13px 15px;
}
.gk-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: gk-blink 1.2s infinite;
}
.gk-dot:nth-child(2) { animation-delay: .2s; }
.gk-dot:nth-child(3) { animation-delay: .4s; }
@keyframes gk-blink {
    0%, 60%, 100% { opacity: .35; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

/* 输入区 */
.gk-inputbar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px 8px;
    border-top: 1px solid rgba(148, 163, 184, .25);
    background: #fff;
    flex: none;
}
.gk-input {
    flex: 1;
    resize: none;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 9px 12px;
    font-size: 14px;
    line-height: 1.5;
    max-height: 120px;
    outline: none;
    font-family: inherit;
    color: #0f172a;
    transition: border-color .15s ease, box-shadow .15s ease;
    background: #f8fafc;
}
.gk-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
    background: #fff;
}
.gk-send {
    flex: none;
    border: 0;
    background: #2563eb;
    color: #fff;
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease;
}
.gk-send:hover {
    background: #1d4ed8;
}
.gk-send:disabled {
    opacity: .55;
    cursor: not-allowed;
}

/* 底部提示 */
.gk-foot {
    padding: 6px 14px 10px;
    font-size: 11px;
    color: #94a3b8;
    background: #fff;
    text-align: center;
    flex: none;
}

/* ---------------- 移动端 ---------------- */
/* 手机端面板直接铺满可视区：
   1) 用 position: fixed + top/right/bottom/left 定位，不再用 100vh / 100vw。
      移动端 100vh 是「地址栏收起」时的大视口高度，比真实可视区高，面板又贴底，
      多出的高度会把顶栏标题和右上角按钮顶到屏幕外，看起来就是「显示不全」；
      100vw 同理（含滚动条宽度），可能比可视宽度宽。
   2) 加上刘海屏 / 全面屏的安全区适配，避免底部提示被系统手势条压住。
   3) 输入框 16px 字号，防止 iOS 聚焦时自动放大页面。 */
@media (max-width: 480px) {
    .gk-root {
        right: 14px;
        bottom: 14px;
    }
    .gk-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        height: auto;
        max-height: none;
        border: 0;
        border-radius: 0;
        transform-origin: center bottom;
    }
    .gk-head {
        padding-top: calc(16px + env(safe-area-inset-top, 0px));
    }
    .gk-inputbar {
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }
    .gk-input {
        font-size: 16px;
    }
    .gk-fab {
        padding: 12px 14px;
    }
}
