/* =========================================================
   JuAI 主题样式 —— 深蓝 + 紫 + 青 渐变科技感 / 暗色
   ========================================================= */
:root {
  --juai-bg: #0a0e1a;
  --juai-bg-2: #0f1424;
  --juai-panel: rgba(22, 28, 46, 0.72);
  --juai-panel-solid: #161c2e;
  --juai-border: rgba(120, 140, 200, 0.16);
  --juai-blue: #2f6bff;
  --juai-purple: #7c4dff;
  --juai-cyan: #22d3ee;
  --juai-text: #e6ebff;
  --juai-muted: #8b95b5;
  --juai-grad: linear-gradient(120deg, #2f6bff 0%, #7c4dff 50%, #22d3ee 100%);
}

* { scrollbar-width: thin; scrollbar-color: #33406b transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #2a3557; border-radius: 6px; }

body.juai-body {
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(47,107,255,0.18), transparent 60%),
    radial-gradient(1000px 500px at 90% 0%, rgba(124,77,255,0.16), transparent 55%),
    radial-gradient(900px 600px at 50% 120%, rgba(34,211,238,0.10), transparent 60%),
    var(--juai-bg);
  color: var(--juai-text);
  min-height: 100vh;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.grad-text {
  background: var(--juai-grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

/* -------- 导航 -------- */
.juai-navbar {
  background: rgba(10, 14, 26, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--juai-border);
}
.juai-brand { display: inline-flex; align-items: center; gap: .5rem; }
.juai-brand .juai-logo-img { width: 30px; height: 30px; display: block; border-radius: 8px; }
.juai-brand .juai-logo { font-weight: 800; font-size: 1.4rem; letter-spacing: .5px; color: var(--juai-text); }
.juai-navbar .nav-link { color: var(--juai-muted); border-radius: 8px; padding: .35rem .75rem; }
.juai-navbar .nav-link:hover { color: var(--juai-text); }
.juai-navbar .nav-link.active { color: #fff; background: rgba(124,77,255,0.18); }

/* -------- 按钮 -------- */
.juai-btn-grad {
  background: var(--juai-grad); border: none; color: #fff !important;
  box-shadow: 0 4px 18px rgba(80, 90, 220, 0.35); transition: transform .12s ease, box-shadow .2s;
}
.juai-btn-grad:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(80,90,220,0.5); color:#fff; }
.juai-btn-grad:active { transform: translateY(0); }

/* -------- 卡片 / 面板 -------- */
.juai-panel {
  background: var(--juai-panel); border: 1px solid var(--juai-border);
  border-radius: 16px; padding: 1.25rem; backdrop-filter: blur(8px);
}
.min-h-100 { min-height: 70vh; }

.juai-card {
  background: var(--juai-panel); border: 1px solid var(--juai-border);
  border-radius: 16px; padding: 1.4rem; transition: transform .15s ease, border-color .2s, box-shadow .2s;
  position: relative; overflow: hidden;
}
.juai-card:hover { transform: translateY(-4px); border-color: rgba(124,77,255,0.5); box-shadow: 0 12px 30px rgba(30,40,90,0.45); }
.juai-card-icon {
  width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center;
  font-size: 1.6rem; color: #fff; background: var(--juai-grad);
}
.icon-claude { background: linear-gradient(120deg,#7c4dff,#b06ab3); }
.icon-gemini { background: linear-gradient(120deg,#2f6bff,#22d3ee); }
.icon-image  { background: linear-gradient(120deg,#22d3ee,#4ade80); }
.icon-video  { background: linear-gradient(120deg,#f472b6,#7c4dff); }

/* -------- Hero -------- */
.juai-hero { padding-top: 2rem; }
.juai-hero-badge {
  display: inline-block; padding: .35rem .9rem; border-radius: 999px;
  border: 1px solid var(--juai-border); color: var(--juai-cyan);
  background: rgba(34,211,238,0.08); font-size: .85rem;
}
.juai-step { padding: 1rem; }
.juai-step-no {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--juai-grad); color: #fff; font-weight: 700;
}

/* -------- 表单控件 -------- */
.juai-input, .juai-select, .juai-textarea, .form-control, .form-select {
  background: rgba(12,16,30,0.8) !important; border: 1px solid var(--juai-border) !important;
  color: var(--juai-text) !important;
}
.form-control:focus, .form-select:focus {
  border-color: var(--juai-purple) !important; box-shadow: 0 0 0 .2rem rgba(124,77,255,0.2) !important;
}
.juai-textarea { resize: none; }

/* -------- 弹窗 / 提示 -------- */
.juai-modal { background: var(--juai-panel-solid); border: 1px solid var(--juai-border); border-radius: 16px; }
.juai-alert { background: rgba(47,107,255,0.10); border: 1px solid var(--juai-border); color: var(--juai-text); border-radius: 12px; }
.juai-badge { background: var(--juai-grad); color:#fff; }
.juai-table th { color: var(--juai-muted); font-weight: 600; }
.juai-pills .nav-link { color: var(--juai-muted); }
.juai-pills .nav-link.active { background: var(--juai-grad); color:#fff; }
.juai-accordion .accordion-button { background: transparent; color: var(--juai-text); }
.juai-accordion .accordion-button:not(.collapsed) { background: rgba(124,77,255,0.12); color:#fff; }
.juai-accordion .accordion-item { background: transparent; border-color: var(--juai-border); }
.juai-footer { border-top: 1px solid var(--juai-border); margin-top: 2rem; }

/* =========================================================
   聊天工作台布局
   ========================================================= */
.chat-shell { display: flex; height: calc(100vh - 56px); overflow: hidden; }
.chat-sidebar {
  width: 280px; flex-shrink: 0; background: rgba(12,16,30,0.6);
  border-right: 1px solid var(--juai-border); display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.chat-session-list { overflow-y: auto; padding: .5rem; }
.session-item {
  padding: .6rem .75rem; border-radius: 10px; cursor: pointer; margin-bottom: .35rem;
  color: var(--juai-muted); display: flex; align-items: center; gap: .5rem;
  border: 1px solid transparent; word-break: break-all;
}
.session-item:hover { background: rgba(124,77,255,0.10); color: var(--juai-text); }
.session-item.active { background: rgba(124,77,255,0.18); color: #fff; border-color: rgba(124,77,255,0.4); }
.session-item .s-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .s-del { opacity: .5; }
.session-item .s-del:hover { opacity: 1; color: #ff6b6b; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-topbar {
  display: flex; align-items: center; gap: .5rem; padding: .6rem 1rem;
  border-bottom: 1px solid var(--juai-border); background: rgba(10,14,26,0.5);
}
.chat-messages { flex: 1; overflow-y: auto; padding: 1.5rem; scroll-behavior: smooth; }
.chat-empty { height: 100%; display: grid; place-items: center; }

.msg { display: flex; gap: .8rem; margin-bottom: 1.4rem; max-width: 900px; }
.msg-avatar {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; display: grid; place-items: center;
  font-size: .95rem; color: #fff;
}
.msg-user .msg-avatar { background: linear-gradient(120deg,#2f6bff,#22d3ee); }
.msg-assistant .msg-avatar { background: var(--juai-grad); }
.msg-body { flex: 1; min-width: 0; }
.msg-role { font-size: .78rem; color: var(--juai-muted); margin-bottom: .25rem; }
.msg-content {
  background: rgba(22,28,46,0.7); border: 1px solid var(--juai-border);
  border-radius: 12px; padding: .8rem 1rem; line-height: 1.7; overflow-wrap: anywhere;
}
.msg-user .msg-content { background: rgba(47,107,255,0.12); }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content pre {
  background: #0b0f1c !important; border: 1px solid var(--juai-border);
  border-radius: 10px; padding: .85rem; overflow-x: auto; position: relative;
}
.msg-content code:not(pre code) {
  background: rgba(124,77,255,0.15); padding: .1rem .35rem; border-radius: 5px; font-size: .9em;
}
.msg-content table { width: 100%; border-collapse: collapse; margin: .5rem 0; }
.msg-content th, .msg-content td { border: 1px solid var(--juai-border); padding: .4rem .6rem; }
.copy-code-btn {
  position: absolute; top: 6px; right: 6px; font-size: .72rem; padding: .1rem .5rem;
  background: rgba(124,77,255,0.25); color:#fff; border:none; border-radius:6px; cursor:pointer; opacity:.7;
}
.copy-code-btn:hover { opacity: 1; }
.msg-actions { margin-top: .4rem; display: flex; gap: .5rem; }
.msg-actions button { font-size: .78rem; color: var(--juai-muted); background: none; border: none; cursor: pointer; }
.msg-actions button:hover { color: var(--juai-cyan); }
.typing-cursor::after { content: '▋'; animation: blink 1s steps(2) infinite; color: var(--juai-cyan); }
@keyframes blink { 0%,50%{opacity:1} 51%,100%{opacity:0} }

.chat-inputbar { border-top: 1px solid var(--juai-border); padding: .85rem 1rem 1rem; background: rgba(10,14,26,0.5); }
.chat-input-wrap { display: flex; gap: .6rem; align-items: flex-end; max-width: 900px; margin: 0 auto; }
.chat-input-wrap .juai-textarea { max-height: 180px; overflow-y: auto; }
.chat-input-actions { display: flex; gap: .4rem; }
.chat-input-hint { max-width: 900px; margin: .4rem auto 0; }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1040; }

/* -------- 提示卡片（未设Key / 无模型权限） -------- */
.juai-notice {
  max-width: 460px; margin: 0 auto; text-align: center; padding: 2rem 1.5rem;
  background: var(--juai-panel); border: 1px solid var(--juai-border); border-radius: 16px;
}
.juai-notice-icon {
  width: 60px; height: 60px; margin: 0 auto 1rem; border-radius: 16px; display: grid; place-items: center;
  font-size: 1.8rem; color: #fff; background: var(--juai-grad);
}
.juai-notice-title { font-size: 1.1rem; font-weight: 600; color: var(--juai-text); margin-bottom: .5rem; }
.juai-notice-desc { color: var(--juai-muted); font-size: .9rem; line-height: 1.7; margin-bottom: 1.2rem; }
.juai-notice-actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
/* 面板内提示（生图/视频页） */
.juai-inline-notice {
  text-align: center; padding: 2.5rem 1rem; color: var(--juai-muted);
}
.juai-inline-notice .bi { font-size: 2.4rem; }
.juai-inline-notice .n-title { color: var(--juai-text); font-weight: 600; margin: .6rem 0 .3rem; }

/* -------- 图片上传缩略图 -------- */
.juai-thumb {
  position: relative; display: inline-block; width: 64px; height: 64px; margin: 0 .4rem .4rem 0;
  border-radius: 10px; overflow: hidden; border: 1px solid var(--juai-border); vertical-align: top;
}
.juai-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.juai-thumb-del {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; line-height: 1;
  border: none; border-radius: 50%; background: rgba(10,14,26,.85); color: #fff;
  font-size: .7rem; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.juai-thumb-del:hover { background: #ff5c5c; }

/* 聊天待发送图片条 */
.chat-attach-bar {
  max-width: 900px; margin: 0 auto .5rem; padding: .5rem; display: flex; flex-wrap: wrap;
  background: rgba(12,16,30,.5); border: 1px solid var(--juai-border); border-radius: 12px;
}
.chat-attach-btn { flex-shrink: 0; align-self: flex-end; }

/* 上传文件卡片（缩略图 + 文件名 + 类型/大小） */
.juai-filecard {
  display: inline-flex; align-items: center; gap: .6rem; position: relative;
  background: rgba(22,28,46,.85); border: 1px solid var(--juai-border); border-radius: 12px;
  padding: .45rem .7rem .45rem .5rem; margin: 0 .5rem .35rem 0; max-width: 280px;
}
.juai-filecard .fc-thumb {
  width: 40px; height: 40px; border-radius: 8px; overflow: hidden; flex-shrink: 0;
  background: #0b0f1c; border: 1px solid var(--juai-border);
}
.juai-filecard .fc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.juai-filecard .fc-meta { min-width: 0; padding-right: 1rem; }
.juai-filecard .fc-name {
  font-size: .84rem; color: var(--juai-text); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px;
}
.juai-filecard .fc-sub { font-size: .72rem; color: var(--juai-muted); margin-top: 1px; }
.juai-filecard .fc-del {
  position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; line-height: 1; padding: 0;
  border: none; border-radius: 50%; background: rgba(10,14,26,.85); color: #fff;
  font-size: .6rem; cursor: pointer; display: grid; place-items: center;
}
.juai-filecard .fc-del:hover { background: #ff5c5c; }

/* 聊天消息内的图片 */
.msg-images { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.msg-images img {
  max-width: 220px; max-height: 220px; border-radius: 10px; border: 1px solid var(--juai-border); cursor: zoom-in;
}
/* 对话内生图 */
.chat-img-gen { display: flex; align-items: center; gap: .5rem; color: var(--juai-cyan); }
.chat-img-caption { margin-bottom: .5rem; }
/* 推理模型"思考中"占位 */
.think-hint { color: var(--juai-muted); font-style: italic; display: inline-flex; align-items: center; gap: .35rem; }
.think-hint .bi { color: var(--juai-cyan); }

/* =========================================================
   灵感作品库
   ========================================================= */
.juai-gallery .gallery-head { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.gallery-title { font-weight: 600; color: var(--juai-text); }
.gallery-count {
  font-size: .78rem; color: var(--juai-cyan); background: rgba(34,211,238,.1);
  border: 1px solid var(--juai-border); border-radius: 999px; padding: .05rem .55rem;
}
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.gallery-empty { grid-column: 1/-1; text-align: center; padding: 2rem 1rem; }
.gallery-empty .bi { font-size: 2rem; display: block; margin-bottom: .4rem; }

.gallery-card {
  background: rgba(12,16,30,.5); border: 1px solid var(--juai-border); border-radius: 12px;
  overflow: hidden; display: flex; flex-direction: column; transition: border-color .2s, transform .12s;
}
.gallery-card:hover { border-color: rgba(124,77,255,.5); transform: translateY(-2px); }
.gallery-thumb {
  position: relative; aspect-ratio: 1/1; background: #0b0f1c; cursor: zoom-in; overflow: hidden;
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-thumb-ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--juai-muted); font-size: 1.8rem; }
.gallery-play {
  position: absolute; inset: 0; margin: auto; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(10,14,26,.6); color: #fff; display: grid; place-items: center; font-size: 1.4rem;
}
.gallery-badge {
  position: absolute; top: 6px; right: 6px; font-size: .7rem; color: #fff;
  background: rgba(10,14,26,.75); border-radius: 6px; padding: .05rem .4rem;
}
.gallery-meta { padding: .6rem .7rem; flex: 1; }
.gallery-prompt {
  font-size: .82rem; color: var(--juai-text); line-height: 1.4; margin-bottom: .35rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.gallery-sub { display: flex; justify-content: space-between; gap: .4rem; font-size: .72rem; color: var(--juai-muted); }
.gallery-time { font-size: .7rem; color: var(--juai-muted); margin-top: .2rem; }
.gallery-actions {
  display: flex; border-top: 1px solid var(--juai-border);
}
.gallery-actions button {
  flex: 1; background: none; border: none; color: var(--juai-muted); padding: .45rem 0; cursor: pointer;
  font-size: .85rem; transition: background .15s, color .15s;
}
.gallery-actions button:hover { background: rgba(124,77,255,.14); color: #fff; }
.gallery-actions button + button { border-left: 1px solid var(--juai-border); }

/* 查看 modal */
.gallery-modal { position: fixed; inset: 0; z-index: 1085; display: grid; place-items: center; padding: 1rem; }
.gm-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.75); backdrop-filter: blur(2px); }
.gm-body {
  position: relative; z-index: 1; max-width: 90vw; max-height: 90vh; overflow: auto;
  background: var(--juai-panel-solid); border: 1px solid var(--juai-border); border-radius: 16px; padding: 1rem;
}
.gm-close {
  position: absolute; top: 8px; right: 8px; z-index: 2; width: 34px; height: 34px; border-radius: 50%;
  border: none; background: rgba(10,14,26,.8); color: #fff; cursor: pointer;
}
.gm-images { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }
.gm-images img { max-width: 100%; max-height: 70vh; border-radius: 10px; }
.gm-body video { max-width: 100%; max-height: 70vh; border-radius: 10px; display: block; }
.gm-caption { margin-top: .8rem; }
.gm-prompt { color: var(--juai-text); line-height: 1.6; margin-bottom: .3rem; }

/* =========================================================
   任务中心（抽屉 + 任务行）
   ========================================================= */
.juai-offcanvas {
  background: var(--juai-panel-solid); color: var(--juai-text);
  border-left: 1px solid var(--juai-border); width: 420px;
}
.juai-offcanvas .offcanvas-header { border-bottom: 1px solid var(--juai-border); }
.task-row {
  display: flex; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid var(--juai-border);
}
.task-thumb {
  width: 56px; height: 56px; flex-shrink: 0; border-radius: 10px; overflow: hidden;
  background: #0b0f1c; border: 1px solid var(--juai-border);
}
.task-thumb img { width: 100%; height: 100%; object-fit: cover; }
.task-thumb .tk-ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--juai-muted); }
.task-info { flex: 1; min-width: 0; }
.task-kind { display: flex; align-items: center; gap: .5rem; margin-bottom: .2rem; }
.task-prompt {
  font-size: .85rem; color: var(--juai-text); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.task-ops { display: flex; flex-direction: column; gap: .3rem; }
.task-ops button {
  background: none; border: 1px solid var(--juai-border); border-radius: 8px; color: var(--juai-muted);
  width: 30px; height: 30px; cursor: pointer;
}
.task-ops button:hover { color: #fff; border-color: rgba(124,77,255,.5); }
[data-task-badge] { font-size: .65rem; }

/* 会话列表"生成中"指示 */
.session-item .s-busy { width: .9rem; height: .9rem; color: var(--juai-cyan); flex-shrink: 0; }

@media (max-width: 575.98px) { .juai-offcanvas { width: 100%; } }

/* -------- 生图 -------- */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 1rem; }
.img-item { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--juai-border); }
.img-item img { width: 100%; display: block; }
.img-item .img-dl {
  position: absolute; bottom: 8px; right: 8px; background: rgba(10,14,26,0.8); color: #fff;
  border: none; border-radius: 8px; padding: .3rem .6rem; font-size: .8rem; cursor: pointer;
}

/* -------- 视频 -------- */
.video-result video { width: 100%; border-radius: 12px; border: 1px solid var(--juai-border); }
.spinner-dot { display:inline-block; width:8px; height:8px; border-radius:50%; background:var(--juai-cyan); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:.3} 50%{opacity:1} }

/* -------- 移动端 -------- */
@media (max-width: 991.98px) {
  .chat-sidebar {
    position: fixed; top: 56px; left: 0; height: calc(100vh - 56px); z-index: 1050;
    transform: translateX(-100%); box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  .chat-shell.sidebar-open .chat-sidebar { transform: translateX(0); }
  .chat-shell.sidebar-open .sidebar-backdrop { display: block; }
  .chat-messages { padding: 1rem; }
}
