/* ==========================================================================
   易出图智能助手 —— 聊天界面样式
   独立于 style.css（后台管理页仍在用后者），改这里不会影响 zskgl/login。
   ========================================================================== */

:root {
    /* 品牌色：比原来的 #4A6CF7 / #6366F1 混用更深一档，白字对比度更稳 */
    --brand-50: #eef4ff;
    --brand-100: #dbe6ff;
    --brand-200: #c2d4ff;
    --brand-500: #3b6ef6;
    --brand-600: #2f5ce0;
    --brand-700: #2549b8;

    --ink-900: #0f172a;
    --ink-700: #334155;
    --ink-500: #64748b;
    --ink-400: #94a3b8;
    --ink-200: #e2e8f0;
    --ink-100: #f1f5f9;
    --ink-50: #f8fafc;

    --surface: #ffffff;
    --canvas: #f5f7fb;
    --line: #e6ebf2;

    --ok: #0e9f6e;
    --warn: #d97706;
    --danger: #dc2626;

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 18px;
    --r-xl: 24px;

    --shadow-1: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-2: 0 6px 24px -8px rgba(15, 23, 42, .14);
    --shadow-3: 0 18px 48px -16px rgba(15, 23, 42, .22);

    --sidebar-w: 248px;
    --ease: cubic-bezier(.4, 0, .2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
                 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.65;
    color: var(--ink-900);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor;
        stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ==========================================================================
   布局
   ========================================================================== */

.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}
/* 移动端地址栏会挤压视口，dvh 更准；用 @supports 兜住不支持的内核 */
@supports (height: 100dvh) {
    .app { height: 100dvh; }
}

/* ---------- 左侧栏 ---------- */

.sidebar {
    width: var(--sidebar-w);
    flex: none;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 22px 20px 20px;
}

.brand-mark {
    width: 40px; height: 40px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    color: #fff;
    box-shadow: 0 6px 16px -6px rgba(59, 110, 246, .7);
}
.brand-mark .icon { width: 21px; height: 21px; stroke-width: 2; }

.brand-text h1 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.brand-text p { font-size: 11.5px; color: var(--ink-400); letter-spacing: .02em; }

.side-nav {
    flex: 1;
    padding: 6px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-group-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--ink-400);
    padding: 14px 10px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border-radius: var(--r-sm);
    color: var(--ink-700);
    font-size: 14px;
    transition: background .16s var(--ease), color .16s var(--ease);
}
.nav-item .icon { width: 17px; height: 17px; color: var(--ink-400);
                  transition: color .16s var(--ease); }
.nav-item:hover { background: var(--ink-100); color: var(--ink-900); }
.nav-item:hover .icon { color: var(--brand-500); }

/* QQ 号 / 群号：静态展示，不做成链接免得误以为能点 */
.nav-item .nav-value {
    margin-left: auto;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    color: var(--ink-500);
    background: var(--ink-100);
    padding: 2px 7px;
    border-radius: 6px;
}

.side-qr {
    margin: 10px 16px 0;
    padding: 16px 14px;
    text-align: center;
    background: var(--ink-50);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}
.side-qr img {
    width: 118px; height: 118px;
    border-radius: var(--r-sm);
    background: #fff;
    padding: 5px;
    box-shadow: var(--shadow-1);
}
.side-qr p { font-size: 12px; color: var(--ink-500); margin-top: 9px; }

.side-footer {
    padding: 14px 20px 18px;
    font-size: 11.5px;
    color: var(--ink-400);
    line-height: 1.5;
}

/* ---------- 右侧聊天区 ---------- */

.chat {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

.chat-top {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 26px;
    justify-content: center;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(8px);
    z-index: 5;
}

.chat-top h2 { font-size: 15.5px; font-weight: 620; letter-spacing: -.01em; }

/* 标题跟随正文列宽，避免和居中内容错位 */
.chat-top-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 820px;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--ok);
    background: #ecfdf5;
    padding: 3px 9px 3px 7px;
    border-radius: 99px;
    font-weight: 500;
}
.status::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 3px rgba(14, 159, 110, .16);
}

/* ---------- 消息滚动区 ---------- */

.messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 26px 0 8px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

.messages::-webkit-scrollbar { width: 10px; }
.messages::-webkit-scrollbar-thumb {
    background: var(--ink-200);
    border-radius: 99px;
    border: 3px solid var(--surface);
}
.messages::-webkit-scrollbar-thumb:hover { background: var(--ink-400); }

.inner { max-width: 820px; margin: 0 auto; padding: 0 26px; }

/* ---------- 欢迎屏 ---------- */

.welcome { animation: rise .45s var(--ease) both; }

.welcome-hero { padding: 26px 0 22px; }

.welcome-hero h2 {
    font-size: 27px;
    font-weight: 680;
    letter-spacing: -.025em;
    line-height: 1.3;
}
.welcome-hero h2 em {
    font-style: normal;
    background: linear-gradient(120deg, var(--brand-500), #7c4dff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.welcome-hero p { color: var(--ink-500); margin-top: 9px; font-size: 14.5px; }

.section-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-400);
    margin: 22px 0 11px;
}

.capabilities {
    display: grid;
    /* 4 张卡片按 2x2 排列；auto-fit 在 820px 下会排成 3+1，很难看 */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
}

.cap-card {
    text-align: left;
    padding: 15px 16px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    transition: border-color .18s var(--ease), box-shadow .18s var(--ease),
                transform .18s var(--ease);
}
.cap-card:hover {
    border-color: var(--brand-200);
    box-shadow: var(--shadow-2);
    transform: translateY(-2px);
}
.cap-card .cap-icon {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: 9px;
    background: var(--brand-50);
    color: var(--brand-600);
    margin-bottom: 10px;
}
.cap-card .cap-icon .icon { width: 17px; height: 17px; }
.cap-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.cap-card p { font-size: 12.5px; color: var(--ink-500); line-height: 1.55; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
    padding: 8px 14px;
    font-size: 13.5px;
    color: var(--ink-700);
    background: var(--ink-50);
    border: 1px solid var(--line);
    border-radius: 99px;
    transition: all .16s var(--ease);
}
.chip:hover {
    color: var(--brand-700);
    background: var(--brand-50);
    border-color: var(--brand-200);
}

/* ---------- 消息 ---------- */

.msg {
    display: flex;
    gap: 13px;
    padding: 15px 0;
    animation: rise .32s var(--ease) both;
}

.msg-avatar {
    width: 32px; height: 32px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 9px;
    margin-top: 1px;
}
.msg-avatar .icon { width: 17px; height: 17px; }

.msg-ai .msg-avatar {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    color: #fff;
}
.msg-user { flex-direction: row-reverse; }
.msg-user .msg-avatar { background: var(--ink-100); color: var(--ink-500); }

.msg-body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.msg-user .msg-body { align-items: flex-end; }

.bubble {
    max-width: 100%;
    padding: 12px 16px;
    border-radius: var(--r-lg);
    font-size: 14.5px;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.msg-ai .bubble {
    background: var(--ink-50);
    border: 1px solid var(--line);
    border-top-left-radius: var(--r-sm);
}
.msg-user .bubble {
    background: var(--brand-500);
    color: #fff;
    border-top-right-radius: var(--r-sm);
    box-shadow: 0 4px 14px -6px rgba(59, 110, 246, .55);
    max-width: min(560px, 88%);
}

/* ---------- 富文本（AI 回复的 markdown 渲染结果） ---------- */

.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }

.bubble p { margin: 0 0 9px; }
.bubble ul, .bubble ol { margin: 8px 0 10px; padding-left: 21px; }
.bubble li { margin: 4px 0; }
.bubble li::marker { color: var(--ink-400); }
.bubble ol { counter-reset: none; }
.bubble strong { font-weight: 650; color: var(--ink-900); }
.msg-user .bubble strong { color: #fff; }

.bubble h3, .bubble h4 {
    font-size: 14.5px;
    font-weight: 650;
    margin: 14px 0 7px;
}

.bubble code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .89em;
    background: rgba(15, 23, 42, .06);
    padding: 1.5px 5px;
    border-radius: 5px;
}
.msg-user .bubble code { background: rgba(255, 255, 255, .2); }

.bubble pre {
    background: var(--ink-900);
    color: #e2e8f0;
    padding: 12px 14px;
    border-radius: var(--r-sm);
    overflow-x: auto;
    margin: 10px 0;
    font-size: 13px;
    line-height: 1.6;
}
.bubble pre code { background: none; padding: 0; color: inherit; }

.bubble a { color: var(--brand-600); text-decoration: underline;
            text-underline-offset: 2px; }
.msg-user .bubble a { color: #fff; }

.bubble table {
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 13.5px;
    width: 100%;
}
.bubble th, .bubble td {
    border: 1px solid var(--line);
    padding: 6px 10px;
    text-align: left;
}
.bubble th { background: var(--ink-100); font-weight: 600; }

.bubble hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

/* 流式输出时的光标 */
.caret {
    display: inline-block;
    width: 2px; height: 1.05em;
    background: var(--brand-500);
    vertical-align: text-bottom;
    margin-left: 2px;
    animation: blink 1.05s steps(1) infinite;
}

/* ---------- 消息下方操作条 ---------- */

.msg-tools {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 7px;
    opacity: 0;
    transition: opacity .18s var(--ease);
}
.msg:hover .msg-tools, .msg-tools:focus-within { opacity: 1; }
.msg-user .msg-tools { flex-direction: row-reverse; }

.tool {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    font-size: 12.5px;
    color: var(--ink-500);
    border-radius: 6px;
    transition: background .14s var(--ease), color .14s var(--ease);
}
.tool:hover { background: var(--ink-100); color: var(--ink-900); }
.tool .icon { width: 14px; height: 14px; }
.tool.on { color: var(--brand-600); background: var(--brand-50); }
.tool.on-down { color: var(--danger); background: #fef2f2; }

.msg-time { font-size: 11.5px; color: var(--ink-400); margin-top: 6px; }

/* ---------- 内嵌媒体 ---------- */

.media-list { margin-top: 11px; display: flex; flex-direction: column; gap: 9px; }

.media-video, .media-image {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    overflow: hidden;
    background: #000;
}
.media-video video { display: block; width: 100%; max-height: 340px; background: #000; }

.media-image { background: var(--ink-50); cursor: zoom-in; }
.media-image img { display: block; width: 100%; max-height: 400px; object-fit: contain; }

.media-cap {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 11px;
    font-size: 12.5px;
    background: var(--surface);
    color: var(--ink-500);
    border-top: 1px solid var(--line);
}
.media-cap .icon { width: 14px; height: 14px; color: var(--brand-500); }

/* ---------- 思考中 ---------- */

.thinking { display: flex; align-items: center; gap: 9px; padding: 4px 2px; }
.thinking span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--ink-400);
    animation: bounce 1.3s var(--ease) infinite;
}
.thinking span:nth-child(2) { animation-delay: .16s; }
.thinking span:nth-child(3) { animation-delay: .32s; }
.thinking em {
    font-style: normal;
    font-size: 13.5px;
    color: var(--ink-500);
    margin-left: 3px;
}

/* ==========================================================================
   输入区
   ========================================================================== */

.composer {
    flex: none;
    padding: 12px 26px 18px;
    background: linear-gradient(to top, var(--surface) 62%, rgba(255, 255, 255, 0));
}

.composer-inner {
    max-width: 820px;
    margin: 0 auto;
}

.composer-box {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 9px 9px 9px 16px;
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-1);
    transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.composer-box:focus-within {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 4px rgba(59, 110, 246, .11);
}

#input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font: inherit;
    font-size: 14.5px;
    line-height: 1.6;
    max-height: 168px;
    padding: 8px 0;
    background: transparent;
    color: var(--ink-900);
}
#input::placeholder { color: var(--ink-400); }

.send {
    width: 38px; height: 38px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--brand-500);
    color: #fff;
    transition: all .18s var(--ease);
}
.send .icon { width: 17px; height: 17px; }
.send:hover:not(:disabled) { background: var(--brand-600); transform: scale(1.06); }
.send:disabled { background: var(--ink-200); cursor: not-allowed; }

.send-busy { background: var(--ink-500); }
.send-busy .icon { animation: spin .9s linear infinite; }

.composer-hint {
    text-align: center;
    font-size: 11.5px;
    color: var(--ink-400);
    margin-top: 8px;
}
.composer-hint kbd {
    font-family: inherit;
    font-size: 11px;
    background: var(--ink-100);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0 4px;
}

/* ==========================================================================
   图片查看器
   ========================================================================== */

.viewer {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 5vh 5vw;
    background: rgba(15, 23, 42, .82);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s var(--ease);
}
.viewer.open { opacity: 1; pointer-events: auto; }
.viewer img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--r-md);
    box-shadow: var(--shadow-3);
}
.viewer-close {
    position: absolute;
    top: 22px; right: 26px;
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    transition: background .16s var(--ease);
}
.viewer-close:hover { background: rgba(255, 255, 255, .26); }

/* ==========================================================================
   轻提示
   ========================================================================== */

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(14px);
    z-index: 200;
    padding: 10px 18px;
    border-radius: 99px;
    background: var(--ink-900);
    color: #fff;
    font-size: 13.5px;
    box-shadow: var(--shadow-3);
    opacity: 0;
    animation: toast-in .24s var(--ease) forwards;
}
.toast.error { background: var(--danger); }

/* ==========================================================================
   动画
   ========================================================================== */

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes bounce {
    0%, 62%, 100% { transform: translateY(0); opacity: .45; }
    32% { transform: translateY(-5px); opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ==========================================================================
   响应式
   ========================================================================== */

@media (max-width: 900px) {
    .sidebar { display: none; }
    .inner, .composer-inner { padding-left: 16px; padding-right: 16px; }
    .chat-top { padding: 13px 18px; }
    .composer { padding: 10px 14px 14px; }
    .messages { padding-top: 16px; }
    .welcome-hero h2 { font-size: 22px; }
    .msg-user .bubble { max-width: 92%; }
}

@media (max-width: 560px) {
    body { font-size: 14.5px; }
    .messages .inner { padding-left: 13px; padding-right: 13px; }
    .msg { gap: 10px; padding: 12px 0; }
    .msg-avatar { width: 29px; height: 29px; }
    .bubble { font-size: 14px; padding: 11px 14px; }
    .capabilities { grid-template-columns: 1fr; }
    .msg-tools { opacity: 1; }   /* 触屏没有 hover，操作条常显 */
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
