/* ============================================
   AI Generation Page — 样式
   只在 /ai-image-generation/ 页面加载
   ============================================ */

/* ============================================
   页面外层
   ============================================ */
.ai-page-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 20px 60px;
    background: #fafafa;
    min-height: 100vh;
}
.ai-page-title {
    font-size: 32px;
    font-weight: 700;
    color: #111;
    margin: 0 0 20px 0;
}

/* ============================================
   签到横条
   ============================================ */
.user-sign-bar {
    margin-bottom: 24px;
}
.user-sign-bar #user-sign-panel {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 16px 24px !important;
    font-size: 14px !important;
}
.user-sign-bar #user-sign-panel > div {
    gap: 10px !important;
}

/* ============================================
   4 块 Grid 布局（桌面 5fr : 7fr，手机单列）
   ============================================ */
.ai-page-grid {
    display: grid;
    grid-template-columns: minmax(360px, 5fr) minmax(480px, 7fr);
    grid-template-rows: 560px auto;
    gap: 24px;
}

/* ============================================
   卡片基础样式
   ============================================ */
.ai-block {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #f0f0f0;
    box-sizing: border-box;
}
.card-input,
.card-result {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.card-recent,
.card-tips {
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

/* ============================================
   卡片① 输入区
   ============================================ */
.card-input {
    height: 560px;
    overflow: hidden;
    padding: 24px;
    box-sizing: border-box;
}
.card-inner-scroll {
    height: 100%;
    overflow-y: auto;
    padding-right: 8px;
}

/* ============================================
   Prompt 输入
   ============================================ */
.ai-gen-prompt {
    width: 100%;
    padding: 14px;
    font-size: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-sizing: border-box;
    margin: 0 0 16px 0;
    resize: none;
    font-family: inherit;
    min-height: 60px;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.5;
}
.ai-gen-prompt:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.15);
}

/* ============================================
   Section / Hint
   ============================================ */
.ai-gen-section {
    margin: 16px 0;
}
.ai-gen-hint {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
    line-height: 1.5;
}

/* ============================================
   Style Presets（卡片式：图标 + 名称 + 描述）
   ============================================ */
.style-preset-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}
.style-preset-btn {
    cursor: pointer;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px 14px;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    transition: all 0.2s ease;
    user-select: none;
    font-family: inherit;
}
.style-preset-btn:hover {
    border-color: #b0d4ea;
    background: #fafdff;
}
.style-preset-btn.is-active {
    border-color: #0073aa;
    background: #f0f8ff;
}
.style-preset-icon {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}
.style-preset-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.style-preset-title {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    line-height: 1.2;
}
.style-preset-btn.is-active .style-preset-title {
    color: #0073aa;
}
.style-preset-desc {
    font-size: 12px;
    color: #888;
    line-height: 1.3;
}

/* ============================================
   Aspect Ratio
   ============================================ */
.aspect-ratio-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.aspect-ratio-btn {
    cursor: pointer;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px 14px;
    background: #fff;
    text-align: center;
    min-width: 100px;
    transition: all 0.2s ease;
    user-select: none;
}
.aspect-ratio-btn:hover {
    border-color: #b0d4ea;
}
.aspect-ratio-btn.is-active {
    border-color: #0073aa;
    background: #f0f8ff;
}
.aspect-ratio-label {
    font-size: 15px;
    font-weight: 700;
    color: #333;
}
.aspect-ratio-btn.is-active .aspect-ratio-label {
    color: #0073aa;
}
.aspect-ratio-desc {
    font-size: 11px;
    color: #888;
    margin-top: 4px;
    line-height: 1.3;
}

/* ============================================
   AI Mode
   ============================================ */
#ai-mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.ai-mode-loading {
    text-align: center;
    color: #888;
    font-size: 13px;
    padding: 10px;
}
.ai-mode-card {
    position: relative;
    cursor: pointer;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 14px 12px;
    text-align: center;
    background: #fff;
    transition: all 0.2s ease;
    user-select: none;
    overflow: visible;
}
.ai-mode-card:hover {
    border-color: #b0d4ea;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.ai-mode-card.is-active {
    border-color: #0073aa;
    background: #f0f8ff;
    box-shadow: 0 4px 12px rgba(0,115,170,0.12);
}
.ai-mode-label {
    font-weight: bold;
    font-size: 15px;
    color: #333;
}
.ai-mode-card.is-active .ai-mode-label {
    color: #0073aa;
}
.ai-mode-desc {
    font-size: 12px;
    color: #777;
    margin-top: 4px;
}
.ai-mode-cost {
    font-size: 13px;
    color: #0073aa;
    font-weight: bold;
    margin-top: 6px;
}
.ai-mode-badge {
    position: absolute;
    top: -8px;
    right: 10px;
    background: #0073aa;
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 10px;
}
.ai-mode-card[data-mode="fast"] .ai-mode-badge {
    background: #f59e0b;
}

/* ============================================
   生成按钮
   ============================================ */
.ai-gen-btn {
    width: 100%;
    padding: 14px;
    font-size: 17px;
    background-color: #0073aa;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-family: inherit;
    margin-top: 16px;
    transition: background-color 0.2s ease;
}
.ai-gen-btn:hover:not(:disabled) {
    background-color: #005a8c;
}
.ai-gen-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================
   状态提示
   ============================================ */
.ai-gen-status {
    margin: 12px 0;
    font-size: 14px;
}

/* ============================================
   卡片② 预览画布（Grid 叠层状态机）
   ============================================ */
.card-result {
    height: 560px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}
.canvas-area {
    position: relative;
    width: 100%;
    height: 100%;
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}
.canvas-state {
    grid-area: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 24px;
    box-sizing: border-box;
    text-align: center;
}
.canvas-state[hidden] { display: none; }

/* 空状态 */
.canvas-empty .ai-empty-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    display: block;
    object-fit: contain;
}
.canvas-empty .ai-empty-title {
    margin: 0 0 10px 0;
    font-size: 20px;
    font-weight: 700;
    color: #333;
}
.canvas-empty .ai-empty-text {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: #888;
    max-width: 400px;
}

/* 加载状态 */
.canvas-loading .ai-progress {
    width: 100%;
    max-width: 480px;
    text-align: left;
}
.canvas-loading .ai-progress-label {
    font-size: 12px;
    font-weight: bold;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.canvas-loading .ai-progress-stage {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 20px;
}
.canvas-loading .ai-progress-desc {
    margin: 0 0 20px 0;
    color: #888;
    font-size: 14px;
}
.canvas-loading .ai-progress-track {
    width: 100%;
    height: 8px;
    background: #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
}
.canvas-loading .ai-progress-bar {
    width: 0%;
    height: 100%;
    background: #0073aa;
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* ============================================
   结果状态：图片居中，Save + Share 固定在底部
   ============================================ */
.canvas-result {
    padding: 16px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;              /* ← 加这一行 */
}
.canvas-result .ai-image-output {
    flex: 1;
    width: 100%;
    min-height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.canvas-result .ai-image-output img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    display: block;
}
.canvas-result .ai-result-actions {
    flex-shrink: 0;
    min-height: 88px;
    padding-top: 12px;
    text-align: center;
}
.canvas-result .ai-save-wrap {
    margin-top: 0;
    text-align: center;
}
.ai-save-btn {
    background: #28a745;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    font-family: inherit;
}
.ai-save-btn:hover:not(:disabled) {
    background: #218838;
}
.ai-save-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.ai-save-msg {
    margin-top: 8px;
    font-size: 14px;
}


/* ============================================
   卡片④ Quick Tips
   ============================================ */
.card-tips {
    display: flex;
    flex-direction: column;
}
.ai-tips-title {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 700;
    color: #111;
}
.ai-tips-list {
    margin: 0;
    padding: 0;
    list-style: none;
}
.ai-tips-list li {
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid #f5f5f5;
}
.ai-tips-list li:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.ai-tips-list a {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}
.ai-tips-list a:hover {
    color: #0073aa;
}
.ai-tips-list .tip-icon {
    font-size: 20px;
    line-height: 1.4;
    flex-shrink: 0;
}
.ai-tips-list .tip-body {
    flex: 1;
}
.ai-tips-list .tip-title {
    font-size: 14px;
    font-weight: 600;
    color: #111;
    margin-bottom: 4px;
}
.ai-tips-list .tip-desc {
    font-size: 12px;
    color: #888;
    line-height: 1.4;
}
.ai-tips-list a:hover .tip-title {
    color: #0073aa;
}

/* ============================================
   卡片③ Recent 短代码样式覆盖
   ============================================ */
.card-recent #recent-gallery-wrap {
    max-width: 100% !important;
    margin: 0 !important;
    padding-top: 0 !important;
    border-top: none !important;
}
.card-recent #recent-gallery-list {
    grid-template-columns: repeat(3, 1fr) !important;
}
.card-recent #recent-gallery-list img {
    height: 100px !important;
}

/* ============================================
   弹窗
   ============================================ */
.ai-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
.ai-modal-content {
    background: #fff;
    padding: 32px;
    border-radius: 10px;
    max-width: 420px;
    width: 90%;
    text-align: center;
}
.ai-modal-title {
    margin-top: 0;
    font-size: 20px;
}
.ai-modal-text {
    font-size: 16px;
    color: #555;
}
.ai-modal-actions {
    margin-top: 24px;
    display: flex;
    gap: 12px;
    justify-content: center;
}
.ai-modal-btn-secondary {
    padding: 10px 24px;
    background: #fff;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}
.ai-modal-btn-primary {
    padding: 10px 24px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* ============================================
   响应式：手机端单列，块1→块2→块3→块4
   ============================================ */
@media (max-width: 921px) {
    .ai-page-wrapper {
        padding: 20px 15px 40px;
    }
    .ai-page-title {
        font-size: 24px;
    }
    .user-sign-bar #user-sign-panel {
        padding: 12px 16px !important;
        font-size: 13px !important;
    }

    .ai-page-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
        gap: 16px;
    }

    .card-input {
        height: auto;
        overflow: visible;
        padding: 20px;
    }
    .card-inner-scroll {
        height: auto;
        overflow: visible;
        padding-right: 0;
    }

    .card-result {
        height: auto;
        min-height: 320px;
    }

    .style-preset-list {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .style-preset-btn {
        padding: 10px;
        gap: 8px;
    }
    .style-preset-icon {
        font-size: 20px;
    }
    .style-preset-title {
        font-size: 13px;
    }
    .style-preset-desc {
        font-size: 11px;
    }

    #ai-mode-selector {
        grid-template-columns: 1fr;
    }
    .ai-mode-card {
        padding: 12px 10px;
    }
    .ai-mode-label {
        font-size: 14px;
    }
    .ai-mode-desc {
        font-size: 11px;
    }
    .ai-mode-cost {
        font-size: 12px;
    }

    .aspect-ratio-list {
        gap: 8px;
    }
    .aspect-ratio-btn {
        min-width: calc(50% - 4px);
        padding: 8px 10px;
        flex: 1 1 calc(50% - 4px);
    }

    .ai-gen-btn {
        display: block;
        width: 100%;
        margin-top: 16px;
    }
}

@media (max-width: 420px) {
    .style-preset-list {
        grid-template-columns: 1fr;
    }
    .aspect-ratio-btn {
        min-width: 100%;
        flex: 1 1 100%;
    }
}

/* 无障碍：减少动画 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
}