/* ============================================================
   ggb.css —— AI 几何绘图工作台 · 视觉层
   基础组件（modal/btn 等）复用主站 style.css；
   本文件只负责 ggb 页面的工作台外观。
   ============================================================ */

/* ---------- 全局底色：柔和渐变网格 ---------- */
body {
    background:
        radial-gradient(900px 420px at 8% -6%, rgba(102, 126, 234, .10), transparent 60%),
        radial-gradient(800px 400px at 96% 4%, rgba(118, 75, 162, .08), transparent 55%),
        var(--bg);
    min-height: 100vh;
}

.ggb-container { max-width: 1380px; padding: 26px 22px 48px; }

/* ---------- 入场动画 ---------- */
@keyframes ggbUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.anim-up { animation: ggbUp .45s cubic-bezier(.22,.8,.36,1) both; animation-delay: calc(var(--d, 0) * 80ms); }
@media (prefers-reduced-motion: reduce) { .anim-up { animation: none; } }

/* ============================================================
   一、顶栏
   ============================================================ */
.ggb-header {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; gap: 18px;
    padding: 12px 26px;
    background: linear-gradient(120deg, #5b6cd6 0%, #667eea 45%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 4px 24px rgba(77, 70, 180, .28);
    overflow: hidden;
}
.ggb-header-glow {
    position: absolute; inset: 0; pointer-events: none;
    background:
        radial-gradient(340px 120px at 18% 130%, rgba(255,255,255,.14), transparent 60%),
        radial-gradient(280px 110px at 88% -40%, rgba(255,255,255,.12), transparent 60%);
}
.ggb-back {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 8px 15px 8px 11px;
    font-size: .84rem; font-weight: 600; color: #fff;
    background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.28);
    border-radius: 999px; cursor: pointer;
    transition: background .18s, transform .18s;
    flex-shrink: 0;
}
.ggb-back:hover { background: rgba(255,255,255,.26); transform: translateX(-2px); }
.ggb-home:hover { background: rgba(255,255,255,.26); transform: translateY(-2px); }

.ggb-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ggb-brand-logo {
    width: 42px; height: 42px; flex-shrink: 0;
    display: grid; place-items: center;
    background: rgba(255,255,255,.16);
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 13px;
    backdrop-filter: blur(4px);
}
.ggb-brand-text h1 { font-size: 1.12rem; font-weight: 700; letter-spacing: .3px; line-height: 1.3; }
.ggb-brand-text p { font-size: .72rem; color: rgba(255,255,255,.72); letter-spacing: .4px; }

/* --- 顶栏右侧：AI 通道（复用主站 .api-key-wrapper 结构，紧凑化） --- */
.ggb-channel {
    margin-left: auto;
    max-width: 470px; flex: 0 1 470px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.16);
    padding: 7px 10px;
}
.ggb-channel .ai-tabs { gap: 6px; margin-bottom: 7px; }
.ggb-channel .ai-tab { padding: 5px 0; font-size: .76rem; border-radius: 7px; }
.ggb-channel .ai-row { gap: 8px; }
.ggb-route {
    font-size: .74rem !important; padding: 5px 10px !important;
    border-radius: 999px !important;
}
.ggb-test-btn {
    padding: 5px 12px; font-size: .74rem; font-weight: 600;
    background: #ff9800; color: #fff; border: none; border-radius: 999px;
    cursor: pointer; white-space: nowrap; transition: filter .15s, transform .15s;
}
.ggb-test-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.ggb-mini-btn {
    padding: 5px 12px; font-size: .74rem; font-weight: 600;
    background: rgba(255,255,255,.16); color: #fff;
    border: 1px solid rgba(255,255,255,.35); border-radius: 999px;
    cursor: pointer; white-space: nowrap;
}
.ggb-mini-btn:hover { background: rgba(255,255,255,.28); }

/* ============================================================
   二、卡片骨架（输入区 / 画布 / 命令 / 历史共用）
   ============================================================ */
.ggb-card, .ggb-hero, .ggb-canvas-card {
    background: #fff;
    border: 1px solid rgba(226, 232, 240, .9);
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 32px -18px rgba(79, 70, 229, .18);
}

.ggb-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.ggb-sec-icon {
    width: 30px; height: 30px; border-radius: 9px;
    display: grid; place-items: center; flex-shrink: 0;
}
.ggb-sec-icon--purple { background: #eef1fe; color: #5b6cd6; }
.ggb-sec-icon--green  { background: #edf9e7; color: #43a522; }
.ggb-sec-icon--orange { background: #fef4e2; color: #d48806; }
.ggb-sec-name { font-size: .95rem; font-weight: 700; color: #1f2937; letter-spacing: .2px; }
.ggb-sec-tag {
    font-size: .66rem; font-weight: 600; color: #43a522;
    background: #edf9e7; border-radius: 999px; padding: 2px 9px;
}

/* ============================================================
   三、输入区（Hero）
   ============================================================ */
.ggb-hero { margin-bottom: 18px; }
.ggb-hero-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ggb-kbd-hint {
    margin-left: auto; font-size: .72rem; color: #94a3b8;
    display: inline-flex; align-items: center; gap: 4px;
}
.ggb-kbd-hint kbd {
    font-family: inherit; font-size: .68rem; font-weight: 600;
    background: #f1f5f9; border: 1px solid #e2e8f0; border-bottom-width: 2px;
    border-radius: 5px; padding: 1px 6px; color: #64748b;
}

.ggb-input {
    width: 100%; min-height: 92px;
    padding: 14px 16px;
    border: 1.5px solid #e2e8f0; border-radius: 12px;
    background: #fbfcfe;
    font-size: .95rem; font-family: inherit; line-height: 1.65; color: #1f2937;
    resize: vertical; outline: none;
    transition: border-color .18s, box-shadow .18s, background .18s;
}
.ggb-input::placeholder { color: #a8b3c5; }
.ggb-input:hover { border-color: #cbd5e1; }
.ggb-input:focus {
    border-color: var(--primary); background: #fff;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, .13);
}

.ggb-hero-foot { display: flex; align-items: center; gap: 14px; margin-top: 13px; flex-wrap: wrap; }

/* --- 生成按钮 --- */
.ggb-gen {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 26px;
    font-size: .95rem; font-weight: 700; letter-spacing: 1px; color: #fff;
    background: linear-gradient(120deg, #667eea 0%, #7c5fc9 100%);
    border: none; border-radius: 999px; cursor: pointer;
    box-shadow: 0 6px 18px -6px rgba(102, 126, 234, .55);
    transition: transform .18s, box-shadow .18s, filter .18s;
}
.ggb-gen:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -6px rgba(102, 126, 234, .6); filter: brightness(1.04); }
.ggb-gen:active { transform: translateY(0); }
.ggb-gen:disabled { opacity: .62; cursor: not-allowed; transform: none; box-shadow: none; }
.ggb-gen.is-busy svg { animation: ggbSpin 1s linear infinite; }
@keyframes ggbSpin { to { transform: rotate(360deg); } }

/* --- 状态胶囊 --- */
.ggb-status {
    display: inline-flex; align-items: center; gap: 8px;
    min-width: 0; flex: 1;
    font-size: .8rem; color: #64748b;
    background: #f1f5f9; border-radius: 999px;
    padding: 7px 15px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: color .2s, background .2s;
}
.ggb-status::before {
    content: ''; width: 7px; height: 7px; border-radius: 50%;
    background: #94a3b8; flex-shrink: 0;
}
.ggb-status.busy { color: #5b6cd6; background: #eef1fe; }
.ggb-status.busy::before { background: var(--primary); animation: ggbPulse 1s ease-in-out infinite; }
@keyframes ggbPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(102,126,234,.45); } 50% { box-shadow: 0 0 0 5px rgba(102,126,234,0); } }

/* --- 示例胶囊 --- */
.ggb-examples { display: flex; align-items: center; gap: 8px; margin-top: 13px; flex-wrap: wrap; }
.ggb-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 14px; font-size: .78rem; font-weight: 600;
    border-radius: 999px; cursor: pointer;
    border: 1px solid transparent;
    transition: transform .16s, box-shadow .16s, background .16s;
}
.ggb-chip:hover { transform: translateY(-2px); box-shadow: 0 6px 14px -6px rgba(31, 41, 55, .25); }
.ggb-chip:active { transform: translateY(0); }
.ggb-chip--blue   { background: #eef4ff; color: #3b6fd4; border-color: #d7e5ff; }
.ggb-chip--blue:hover   { background: #e2edff; }
.ggb-chip--green  { background: #edf9e7; color: #3f9c1e; border-color: #d9f2cd; }
.ggb-chip--green:hover  { background: #e3f4da; }
.ggb-chip--purple { background: #f4f0fd; color: #7452c4; border-color: #e6ddfa; }
.ggb-chip--purple:hover { background: #ece5fb; }
.ggb-chip--orange { background: #fff5e8; color: #d1740d; border-color: #ffe7c4; }
.ggb-chip--orange:hover { background: #ffedd6; }

/* ============================================================
   四、主体两栏
   ============================================================ */
.ggb-main { display: flex; gap: 18px; align-items: stretch; }
.ggb-canvas-card { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.ggb-side { width: 350px; flex: 0 0 350px; display: flex; flex-direction: column; gap: 18px; }

/* --- 画布卡片 --- */
.ggb-canvas-card .ggb-card-head { margin-bottom: 12px; }
.ggb-canvas-ops { margin-left: auto; display: flex; gap: 7px; }
.ggb-tool {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 13px; font-size: .76rem; font-weight: 600; color: #475569;
    background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 999px;
    cursor: pointer; transition: all .16s;
}
.ggb-tool:hover { background: #eef1fe; color: #5b6cd6; border-color: #d7defc; transform: translateY(-1px); }

.ggb-mode-badge {
    background: linear-gradient(120deg, #faad14, #f08c00); color: #fff;
    font-size: .66rem; font-weight: 800; letter-spacing: 1px;
    border-radius: 999px; padding: 2px 10px;
    box-shadow: 0 3px 8px -2px rgba(250, 173, 20, .5);
}

.ggb-player-wrap {
    position: relative; width: 100%;
    height: clamp(440px, calc(100vh - 420px), 660px);
    border-radius: 12px; overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.6), 0 2px 10px rgba(16,24,40,.05);
}
.ggb-player-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }

/* --- 导出栏 --- */
.ggb-export-bar {
    display: flex; align-items: center; gap: 8px;
    margin-top: 13px; flex-wrap: wrap;
    padding-top: 13px; border-top: 1px dashed #e8ecf3;
}
.ggb-xbtn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; font-size: .8rem; font-weight: 600; color: #475569;
    background: #fff; border: 1px solid #dbe2ea; border-radius: 10px;
    cursor: pointer; transition: all .16s;
}
.ggb-xbtn:hover {
    color: #5b6cd6; border-color: #c3cdfa; background: #f6f8ff;
    transform: translateY(-1px); box-shadow: 0 5px 12px -6px rgba(79,70,229,.3);
}
.ggb-export-hint { font-size: .72rem; color: #94a3b8; margin-left: auto; }

/* ============================================================
   五、命令编辑器（深色代码风格）
   ============================================================ */
.ggb-cmd {
    width: 100%; height: 235px;
    padding: 13px 15px;
    border: 1.5px solid #1e293b; border-radius: 12px;
    background: #0f172a;
    font-family: 'Cascadia Code', Consolas, Monaco, 'Courier New', monospace;
    font-size: .8rem; line-height: 1.7; color: #d8e2f0;
    caret-color: #8fb4ff;
    resize: vertical; outline: none;
    transition: border-color .18s, box-shadow .18s;
}
.ggb-cmd::placeholder { color: #4b5c74; }
.ggb-cmd:focus { border-color: #667eea; box-shadow: 0 0 0 4px rgba(102, 126, 234, .22); }

.ggb-apply {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    width: 100%; margin-top: 11px; padding: 10px 0;
    font-size: .86rem; font-weight: 700; letter-spacing: .5px; color: #fff;
    background: linear-gradient(120deg, #43a522, #5bc233);
    border: none; border-radius: 10px; cursor: pointer;
    box-shadow: 0 6px 16px -6px rgba(82, 196, 26, .55);
    transition: transform .16s, box-shadow .16s, filter .16s;
}
.ggb-apply:hover { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 8px 20px -6px rgba(82, 196, 26, .6); }

/* ============================================================
   六、历史
   ============================================================ */
.ggb-clear {
    margin-left: auto; padding: 4px 13px;
    font-size: .72rem; font-weight: 600; color: #e5484d;
    background: #fdf0f0; border: 1px solid #f8d7d8; border-radius: 999px;
    cursor: pointer; transition: all .16s;
}
.ggb-clear:hover { background: #fbe3e4; }

.ggb-hist-list {
    max-height: 378px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 9px;
    padding: 2px 4px 2px 2px;
}
.ggb-hist-list::-webkit-scrollbar, .ggb-cmd::-webkit-scrollbar { width: 8px; }
.ggb-hist-list::-webkit-scrollbar-thumb { background: #dbe2ea; border-radius: 99px; }
.ggb-cmd::-webkit-scrollbar-thumb { background: #2c3b52; border-radius: 99px; }
.ggb-hist-list::-webkit-scrollbar-track, .ggb-cmd::-webkit-scrollbar-track { background: transparent; }

.ggb-hist-empty {
    color: #94a3b8; font-size: .8rem; text-align: center;
    padding: 26px 0; border: 1.5px dashed #e2e8f0; border-radius: 12px;
    background: #fbfcfe;
}

.ggb-hist-item {
    position: relative;
    border: 1px solid #e8ecf3; border-radius: 12px;
    padding: 10px 12px 10px 14px;
    background: #fdfdff;
    transition: border-color .16s, box-shadow .16s, transform .16s;
}
.ggb-hist-item::before {
    content: ''; position: absolute; left: 0; top: 12px; bottom: 12px;
    width: 3px; border-radius: 3px;
    background: linear-gradient(180deg, #667eea, #764ba2);
    opacity: 0; transition: opacity .16s;
}
.ggb-hist-item:hover {
    border-color: #ccd6f6; transform: translateX(2px);
    box-shadow: 0 5px 14px -8px rgba(79, 70, 229, .35);
}
.ggb-hist-item:hover::before { opacity: 1; }

.ggb-hist-title {
    font-size: .84rem; font-weight: 600; color: #1f2937;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ggb-hist-meta { font-size: .7rem; color: #94a3b8; margin: 3px 0 8px; }
.ggb-hist-ops { display: flex; gap: 7px; }
.ggb-hist-ops .btn-sm {
    padding: 4px 13px; font-size: .72rem; font-weight: 600;
    border-radius: 999px; border: 1px solid #dbe2ea;
    background: #f8fafc; color: #475569; cursor: pointer;
    transition: all .15s;
}
.ggb-hist-ops .btn-sm:hover { background: #eef1fe; color: #5b6cd6; border-color: #ccd6f6; }
.ggb-hist-ops .ggb-del { color: #e5484d; background: #fdf4f4; border-color: #f6d9da; }
.ggb-hist-ops .ggb-del:hover { background: #fbe7e8; color: #c53035; border-color: #f2c1c3; }

/* ============================================================
   七、贴图出图（截图识别题干 → 自动生成图形）
   ============================================================ */
.ggb-ocr-drop {
    display: flex; align-items: center;
    margin-top: 10px; padding: 13px 16px;
    border: 2px dashed #b9c6f7; border-radius: 12px;
    background: linear-gradient(120deg, #f6f8ff, #fbf9ff);
    cursor: pointer; transition: border-color .16s, background .16s, box-shadow .16s, transform .16s;
}
.ggb-ocr-drop:hover {
    border-color: #667eea; background: #f0f3ff;
    box-shadow: 0 5px 16px -8px rgba(102, 126, 234, .5);
    transform: translateY(-1px);
}
.ggb-ocr-drop.dragover { border-color: #52c41a; border-style: solid; background: #f6ffed; }
.ggb-ocr-empty { display: flex; align-items: center; gap: 13px; }
.ggb-ocr-icon {
    display: flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; flex-shrink: 0; font-size: 1.3rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 12px;
    box-shadow: 0 5px 12px -4px rgba(102, 126, 234, .55);
}
.ggb-ocr-texts { display: flex; flex-direction: column; gap: 3px; }
.ggb-ocr-title { font-size: .9rem; font-weight: 700; color: #3b3f63; letter-spacing: .3px; }
.ggb-ocr-sub { font-size: .74rem; color: #8a90a8; line-height: 1.55; }
.ggb-ocr-sub kbd {
    padding: 1px 5px; font-size: .68rem; color: #5b6cd6;
    background: #e7ecff; border: 1px solid #d0d9fb; border-bottom-width: 2px; border-radius: 5px;
}
.ggb-ocr-has { display: flex; align-items: center; gap: 11px; width: 100%; min-width: 0; }
.ggb-ocr-thumb {
    width: 64px; height: 46px; flex-shrink: 0; object-fit: cover;
    border: 1px solid #dbe2ea; border-radius: 8px; background: #fff;
    box-shadow: 0 2px 6px -2px rgba(80, 100, 180, .25);
}
.ggb-ocr-status { font-size: .78rem; font-weight: 600; color: #5b6cd6; flex: 1; min-width: 0; }
.ggb-ocr-clear {
    flex-shrink: 0; padding: 4px 13px;
    font-size: .72rem; font-weight: 600; color: #e5484d;
    background: #fdf4f4; border: 1px solid #f6d9da; border-radius: 999px;
    cursor: pointer; transition: all .15s;
}
.ggb-ocr-clear:hover { background: #fbe7e8; color: #c53035; }

/* ============================================================
   八、响应式
   ============================================================ */
@media (max-width: 1180px) {
    .ggb-channel { max-width: 380px; }
}
@media (max-width: 1020px) {
    .ggb-header { flex-wrap: wrap; padding: 12px 18px; }
    .ggb-brand { order: 1; }
    .ggb-back { order: 0; }
    .ggb-home { order: 0; }
    .ggb-channel { order: 2; margin-left: 0; flex: 1 1 100%; max-width: none; }
    .ggb-main { flex-direction: column; }
    .ggb-side { width: 100%; flex: 1 1 auto; }
    .ggb-player-wrap { height: clamp(380px, 58vh, 520px); }
    .ggb-export-hint { margin-left: 0; width: 100%; }
}
@media (max-width: 560px) {
    .ggb-container { padding: 16px 12px 40px; }
    .ggb-brand-text p { display: none; }
    .ggb-kbd-hint { display: none; }
    .ggb-hero-foot .ggb-status { flex-basis: 100%; }
}
