/* ============================================================
   ai_assistant.css
   AI 助手悬浮入口（浮动卡片按钮）样式
   —— 从 hevemind_floating_widget.html 中抽离的 "AI 助手" 相关样式。
   按钮图标与样式完全采用 assistant_widget.html / assistant-widget.css
   中 .home-assistant-card 的卡片设计（依赖 Font Awesome 图标）。
   ============================================================ */

/* 卡片本体：固定悬浮在右下角 */
.home-assistant-card {
    position: fixed;
    right: 30px;
    bottom: 170px;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 13px;
    overflow: hidden;
    width: 280px;
    padding: 14px 15px;
    font: inherit;
    text-align: left;
    color: inherit;
    text-decoration: none !important;
    background: linear-gradient(120deg, rgba(255, 250, 240, 0.98) 0%, rgba(255, 255, 255, 0.98) 58%, rgba(240, 250, 245, 0.98) 100%);
    border: 1px solid rgba(245, 158, 11, 0.38);
    border-radius: 22px;
    box-shadow: 0 12px 34px rgba(40, 52, 47, 0.20);
    cursor: grab;
    user-select: none;
    touch-action: manipulation; /* 触屏：禁用双击缩放，保证点击/拖动响应即时 */
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.home-assistant-card:before,
.home-assistant-card:after {
    position: absolute;
    content: "";
    border-radius: 50%;
    pointer-events: none;
}

.home-assistant-card:before {
    top: -55px;
    right: 80px;
    width: 110px;
    height: 110px;
    background: rgba(245, 158, 11, 0.08);
}

.home-assistant-card:after {
    right: -30px;
    bottom: -55px;
    width: 115px;
    height: 115px;
    background: rgba(22, 163, 74, 0.07);
}

.home-assistant-card:hover,
.home-assistant-card:focus {
    color: inherit;
    text-decoration: none;
    border-color: rgba(245, 158, 11, 0.65);
    box-shadow: 0 16px 40px rgba(40, 52, 47, 0.27);
    transform: translateY(-4px) scale(1.01);
}

.home-assistant-card:focus {
    outline: 3px solid rgba(245, 158, 11, 0.20);
    outline-offset: 3px;
}

/* 拖动状态 */
.home-assistant-card.is-dragging {
    cursor: grabbing;
    transform: none;
    transition: none;
}

/* 打开聊天面板时隐藏浮动卡片（与原 .fab.hide 行为一致） */
.home-assistant-card.hide {
    opacity: 0;
    visibility: hidden;
    transform: scale(.6);
    pointer-events: none;
}

/* 图标 */
.home-assistant-card .assistant-icon {
    position: relative;
    z-index: 1;
    display: flex;
    flex: 0 0 56px;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    color: #fff;
    font-size: 25px;
    background: linear-gradient(135deg, #f7b733 0%, #f59e0b 55%, #ef7d00 100%);
    border-radius: 17px;
    box-shadow: 0 8px 18px rgba(245, 158, 11, 0.30);
    transform: rotate(-3deg);
}

.home-assistant-card .assistant-status {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 15px;
    height: 15px;
    background: #22c55e;
    border: 3px solid #fff;
    border-radius: 50%;
}

/* 文案内容 */
.home-assistant-card .assistant-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
}

.home-assistant-card .assistant-label {
    margin-bottom: 2px;
    color: #b56805;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.4px;
}

.home-assistant-card .assistant-label .fa {
    margin-right: 4px;
}

.home-assistant-card .assistant-title {
    color: #263238;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.35;
}

.home-assistant-card .assistant-description {
    overflow: hidden;
    max-width: 205px;
    margin-top: 3px;
    color: #68757d;
    font-size: 12px;
    line-height: 1.45;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* 右侧箭头动作按钮 */
.home-assistant-card .assistant-action {
    position: relative;
    z-index: 1;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    color: #fff;
    font-size: 14px;
    background: #354f45;
    border-radius: 50%;
    box-shadow: 0 5px 14px rgba(53, 79, 69, 0.20);
    transition: background-color 0.25s ease;
}

.home-assistant-card:hover .assistant-action {
    background: #f59e0b;
}

.home-assistant-card .assistant-action .fa {
    transition: transform 0.25s ease;
}

.home-assistant-card:hover .assistant-action .fa {
    transform: translateX(4px);
}

@media (max-width: 480px) {
    .home-assistant-card {
        width: min(350px, calc(100vw - 24px));
    }
}
:root {
    --bg: #0f1115;
    --panel: #171a21;
    --line: #262b36;
    --fg: #e8eaed;
    --dim: #9aa3b2;
    --acc: #4a9eff;
    --ok: #3ecf8e;
    --warn: #e0a33a;
}
/* ===== 聊天面板（点开后展示原页面内容与功能） ===== */
.chat {
    position: fixed;
    right: 22px;
    bottom: 100px;
    z-index: 90;
    width: min(460px, calc(100vw - 28px));
    height: min(660px, calc(100vh - 44px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(.97);
    transition: .2s
}

.chat.open {
    opacity: 1;
    visibility: visible;
    transform: none
}

.chead {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--panel)
}

.chead .hl {
    flex: 1;
    min-width: 0;
    color: var(--fg);
}

.chead h1 {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 600
}

.chead .sub {
    color: var(--dim);
    font-size: 12px;
    line-height: 1.5
}

.chead .tools {
    display: flex;
    gap: 6px;
    align-items: center
}

.lang {
    background: #1d222c;
    border: 1px solid var(--line);
    color: var(--dim);
    border-radius: 8px;
    padding: 5px 11px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: .15s;
    line-height: 1.4
}

.lang:hover {
    border-color: var(--acc);
    color: var(--fg)
}

#chat .close {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #1d222c;
    color: var(--dim);
    font-size: 16px;
    line-height: 1;
    cursor: pointer
}

#chat .close:hover {
    border-color: #ff8a8a;
    color: #ff8a8a
}

.cbody {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 14px 16px
}

.tip {
    color: var(--dim);
    font-size: 12.5px;
    margin: 0 0 14px
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 0 0 16px
}

.chip {
    background: #1d222c;
    border: 1px solid var(--line);
    color: var(--dim);
    padding: 6px 10px;
    border-radius: 14px;
    font-size: 12.5px;
    cursor: pointer;
    transition: .15s;
    user-select: none
}

.chip:hover {
    border-color: var(--acc);
    color: var(--fg)
}

.msg {
    margin: 0 0 16px;
    display: flex;
    gap: 9px
}

.msg .who {
    flex: 0 0 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11.5px;
    font-weight: 600
}

.msg.user .who {
    background: #243044;
    color: #8fbaff
}

.msg.bot .who {
    background: #1f3a2c;
    color: #6ee7a8
}

.body {
    flex: 1;
    min-width: 0
}

.bubble {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 13px;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 14px;
    color: var(--fg);
}

.msg.user .bubble {
    background: #1b2432
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
    font-size: 11.5px;
    color: var(--dim)
}

.tag {
    padding: 1px 7px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: #1a1f28
}

.tag.direct {
    color: var(--ok);
    border-color: #2c5a45;
    background: #152a21
}

.tag.gen {
    color: var(--acc);
    border-color: #26405e;
    background: #152233
}

.srclist {
    margin-top: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #141821;
    overflow: hidden;
    font-size: 12.5px
}

.srchd {
    padding: 7px 11px;
    color: var(--dim);
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center
}

.srchd:hover {
    color: var(--fg)
}

.srchd .arw {
    transition: .15s;
    display: inline-block
}

.srclist.open .srchd .arw {
    transform: rotate(90deg)
}

.srcitems {
    display: none;
    border-top: 1px solid var(--line)
}

.srclist.open .srcitems {
    display: block
}

.srcit {
    padding: 8px 11px;
    border-bottom: 1px solid #1e222b
}

.srcit:last-child {
    border-bottom: 0
}

.s1 {
    display: flex;
    gap: 7px;
    align-items: baseline;
    flex-wrap: wrap
}

.rk {
    color: var(--acc);
    font-weight: 600;
    font-size: 11.5px
}

.lbl {
    color: #8fbaff;
    background: #1b2432;
    border: 1px solid #26405e;
    border-radius: 8px;
    padding: 0 6px;
    font-size: 11px
}

.ttl {
    color: var(--fg);
    flex: 1;
    min-width: 0
}

.sc {
    color: #5d6572;
    font-size: 11px
}

.sn {
    color: var(--dim);
    margin-top: 4px;
    line-height: 1.6;
    font-size: 12px
}

.ex {
    color: #5d6572;
    font-size: 11px;
    margin-top: 3px
}

.cur {
    display: inline-block;
    width: 7px;
    height: 14px;
    background: var(--acc);
    margin-left: 2px;
    vertical-align: -2px;
    animation: bl 1s steps(2) infinite
}

@keyframes bl {
    50% {
        opacity: 0
    }
}

.cfoot {
    border-top: 1px solid var(--line);
    padding: 10px 12px;
    background: var(--panel)
}

.inputbar {
    display: flex;
    gap: 8px
}

textarea {
    flex: 1;
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    resize: none;
    height: 48px;
    font: inherit;
    font-size: 14px;
    outline: none
}

textarea:focus {
    border-color: var(--acc)
}

.send {
    background: var(--acc);
    color: #06101d;
    border: 0;
    border-radius: 10px;
    padding: 0 18px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer
}

.send:disabled {
    opacity: .45;
    cursor: not-allowed
}

.err {
    color: #ff8a8a
}

.cfoot .foot {
    margin-top: 7px;
    color: #5d6572;
    font-size: 11px;
    text-align: center
}

.cbody::-webkit-scrollbar {
    width: 8px
}

.cbody::-webkit-scrollbar-thumb {
    background: #2a3140;
    border-radius: 8px
}

/* ============================================================
   聊天面板全屏功能（fullscreen）新增样式
   —— 配合 #chat 头部 .tools 中的全屏按钮 #fs 使用，
      切换逻辑（.fullscreen 类 / ESC 退出）在主脚本中。
   ============================================================ */

/* 全屏按钮：与 .close 视觉保持一致 */
#chat .tools .fs {
    width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0;
    border-radius: 8px; border: 1px solid var(--line);
    background: #1d222c; color: var(--dim);
    line-height: 1; cursor: pointer; transition: .15s;
}
#chat .tools .fs:hover { border-color: var(--acc); color: var(--fg); }
#chat .tools .fs svg { display: block; }
#chat .tools .fs .fs-out { display: none; }   /* 默认只显示“进入全屏”图标 */

/* 全屏态：铺满整屏、去掉圆角与外边距 */
.chat.fullscreen {
    right: 0; bottom: 0;
    width: 100vw; height: 100vh;
    max-width: none; max-height: none;
    border: 0; border-radius: 0;
    box-shadow: none;
}
.chat.fullscreen .tools .fs .fs-in  { display: none; }        /* 进入全屏后换“退出”图标 */
.chat.fullscreen .tools .fs .fs-out { display: inline-block; }

/* 全屏时把头部 / 正文 / 底栏内容收束到一条居中的阅读列，避免正文被拉得过宽 */
.chat.fullscreen .chead,
.chat.fullscreen .cbody {
    padding-left:  max(16px, calc((100% - 860px) / 2));
    padding-right: max(16px, calc((100% - 860px) / 2));
}
.chat.fullscreen .cfoot {
    padding-left:  max(12px, calc((100% - 860px) / 2));
    padding-right: max(12px, calc((100% - 860px) / 2));
}