/*!
 * 雾寻图片工坊 · AI 作图（对齐离线单文件版）
 * 公共骨架（顶栏 / 页头 / 按钮 / 容器 / 表单件）来自 shared/page.css
 * 这里只负责：通道徽标、创作面板、风格标签、参考图上传、蒙版涂抹、结果网格
 */

/* ============ 创作面板 ============ */
.ai-panel {
    margin-top: 18px;
    border: 1px solid var(--fx-line);
    border-radius: var(--fx-r-lg);
    background: var(--fx-surface);
    box-shadow: var(--fx-sh);
    overflow: hidden;
}

/* 页头右侧：当前通道（单行胶囊） */
.ai-provider {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border: 1px solid var(--fx-line);
    border-radius: 20px;
    background: var(--fx-surface);
    flex: 0 0 auto;
    white-space: nowrap;
}

.ai-provider span {
    color: var(--fx-mute);
    font-size: 11px;
    letter-spacing: .2px;
}

.ai-provider b {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -.1px;
    color: var(--fx-ink);
}

.ai-provider.is-mock b {
    color: #b57600;
}

/* 面板头：模式切换 + 额度 */
.ai-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 20px;
    border-bottom: 1px solid var(--fx-line);
}

.ai-quota {
    padding: 5px 12px;
    border-radius: 50px;
    background: var(--fx-brand-soft);
    color: var(--fx-brand-strong);
    font-size: 11.5px;
    font-weight: 800;
    white-space: nowrap;
}

.ai-panel-body {
    padding: 20px;
}

.ai-row {
    margin-bottom: 17px;
}

.ai-row:last-child {
    margin-bottom: 0;
}

.ai-label {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 9px;
    color: var(--fx-ink-2);
    font-size: 12.5px;
    font-weight: 700;
}

.ai-label .hint {
    color: var(--fx-faint);
    font-size: 11px;
    font-weight: 400;
    line-height: 1.5;
}

.ai-label > .hint {
    /* 空间不足时整段换到下一行，别把标签文字挤成两行 */
    flex: 1 1 150px;
    min-width: 0;
}

/* ============ 提示词助手按钮（优化描述 / 图生文） ============ */
.ai-label.has-tools {
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    row-gap: 8px;
}

.ai-label-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 30px;
}

.ai-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.ai-tools .fxp-btn.sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ============ 参考图上传 ============ */
.ai-upload {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1.5px dashed var(--fx-brand-soft-2);
    border-radius: var(--fx-r-sm);
    background: var(--fx-brand-soft);
    flex-wrap: wrap;
}

.ai-upload img {
    max-width: 92px;
    max-height: 92px;
    border: 1px solid var(--fx-line-2);
    border-radius: 10px;
}

.ai-upload .ph {
    min-width: 0;
    color: var(--fx-sub);
    font-size: 12px;
    word-break: break-all;
}

.ai-mask-wrap {
    margin-top: 12px;
}

.ai-mask-wrap canvas {
    display: block;
    max-width: 100%;
    border: 1px solid var(--fx-line-2);
    border-radius: 10px;
    cursor: crosshair;
    touch-action: none;
}

.ai-mask-tip {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
    color: var(--fx-mute);
    font-size: 11.5px;
}

/* ============ 参数行 ============ */
.ai-inline {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.ai-inline>div {
    min-width: 132px;
    flex: 0 1 auto;
}

/* ============ 生成按钮区 ============ */
.ai-go {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 4px;
}

/* 主按钮与次级按钮等高，避免同一行里一高一低 */
.ai-go .fxp-btn {
    padding: 14px 22px;
}

/* 图生文 / 图生图都要先有图：把各自的参考图行提到描述框之前 */
.ai-panel-body #aiBody.is-vision,
.ai-panel-body #aiBody.is-img {
    display: flex;
    flex-direction: column;
}

.ai-panel-body #aiBody.is-vision #rowVision,
.ai-panel-body #aiBody.is-img #rowImg {
    order: -1;
}

.ai-btn {
    padding: 13px 30px;
    border: 0;
    border-radius: var(--fx-r-sm);
    background: var(--fx-grad);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 22px -8px rgba(79, 107, 255, .6);
    transition: .18s var(--fx-ease);
}

.ai-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px -10px rgba(79, 107, 255, .7);
}

.ai-btn:disabled {
    opacity: .55;
    transform: none;
    cursor: not-allowed;
    box-shadow: none;
}

.ai-msg {
    min-width: 0;
    color: #d6304a;
    font-size: 12.5px;
    line-height: 1.6;
}

/* ============ 结果网格 ============ */
.ai-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.ai-card {
    border: 1px solid var(--fx-line);
    border-radius: var(--fx-r-lg);
    background: var(--fx-surface);
    box-shadow: var(--fx-sh);
    overflow: hidden;
    transition: transform .2s var(--fx-ease), box-shadow .2s var(--fx-ease);
}

.ai-card:hover {
    transform: translateY(-3px);
    border-color: #b8c4ff;
    box-shadow: var(--fx-sh-md);
}

.ai-card img {
    display: block;
    width: 100%;
    background: var(--fx-surface-2);
}

.ai-card .bar {
    display: flex;
    gap: 7px;
    padding: 10px;
    flex-wrap: wrap;
}

.ai-card .bar a,
.ai-card .bar button {
    flex: 1 1 auto;
    min-width: 62px;
    padding: 8px 6px;
    border: 1px solid var(--fx-line-2);
    border-radius: 10px;
    background: var(--fx-surface);
    color: var(--fx-brand-strong);
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: .16s var(--fx-ease);
}

.ai-card .bar a:hover,
.ai-card .bar button:hover {
    border-color: var(--fx-brand);
    background: var(--fx-brand-soft);
}

.ai-card .bar a.dl {
    border-color: transparent;
    background: var(--fx-grad);
    color: #fff;
    box-shadow: 0 12px 22px -16px rgba(79, 107, 255, .95);
}

.ai-empty {
    margin-top: 18px;
    padding: 46px 20px;
    border: 1.5px dashed var(--fx-line-2);
    border-radius: var(--fx-r-lg);
    background: var(--fx-surface);
    color: var(--fx-mute);
    font-size: 13px;
    text-align: center;
}

.ai-login {
    padding: 44px 24px;
    text-align: center;
    color: var(--fx-sub);
    font-size: 14px;
}

.ai-login a {
    color: var(--fx-brand-strong);
    font-weight: 700;
}

/* ============ 响应式 ============ */
@media (max-width: 760px) {
    .fxp-ai .fxp-head-side {
        width: 100%;
    }

    .ai-panel {
        margin-top: 14px;
    }

    .ai-panel-body {
        padding: 15px;
    }

    .ai-row {
        margin-bottom: 15px;
    }

    .ai-upload {
        gap: 11px;
        padding: 12px;
    }

    .ai-upload img {
        max-width: 68px;
        max-height: 68px;
    }

    .ai-inline>div {
        flex: 1 1 130px;
        min-width: 0;
    }

    .ai-go {
        gap: 10px;
    }

    /* 图生文页有两个按钮，主按钮不再独占整行 */
    .ai-btn {
        flex: 1 1 auto;
        width: auto;
        padding: 14px 20px;
    }

    .ai-go .fxp-btn {
        flex: 0 0 auto;
        padding: 13px 16px;
    }

    /* 窄屏放不下「标签 + 说明 + 按钮」三段，收掉说明让标签与按钮同行 */
    .ai-label.has-tools {
        flex-wrap: nowrap;
        align-items: center;
    }

    .ai-label.has-tools .ai-label-main .hint {
        display: none;
    }

    /* 三个标签在窄屏平分整行 */
    .fxp-ai .ai-panel-head .fxp-seg {
        width: 100%;
    }

    .fxp-ai .ai-panel-head .fxp-seg button {
        flex: 1 1 0;
        padding: 8px 6px;
    }

    .ai-msg {
        flex: 1 1 100%;
    }

    .ai-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin-top: 16px;
    }

    .ai-card .bar {
        gap: 6px;
        padding: 8px;
    }

    .ai-card .bar a,
    .ai-card .bar button {
        min-width: 0;
        font-size: 11px;
        padding: 8px 4px;
    }

    .ai-empty {
        margin-top: 16px;
        padding: 34px 16px;
    }

    .ai-login {
        padding: 34px 18px;
    }
}

@media (max-width: 380px) {
    .ai-grid {
        grid-template-columns: 1fr;
    }
}
