/* ==================== 设计宝典（ImagePrompt） ==================== */

/* ========== 提示词卡片列表（上图下文，一行4个） ========== */
.ip-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.ip-card {
    background: var(--color-card-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
    -webkit-tap-highlight-color: transparent;
}

    .ip-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
    }

    .ip-card:active {
        transform: scale(0.98);
    }

.ip-card-image {
    width: 100%;
    height: 260px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

    /* 固定高度裁切：竖版长图只展示顶部一截 */
    .ip-card-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: top center;
        display: block;
    }

    .ip-card-image .ip-card-empty {
        padding: 0;
    }

.ip-card-empty {
    font-size: 13px;
    color: #ccc;
    padding: 60px 0;
    user-select: none;
}

.ip-card-title {
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: color var(--transition-base);
}

    .ip-card-title:hover {
        color: var(--color-primary);
    }

/* ========== 详情弹窗（左右式） ========== */
.ip-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: ipModalFade 0.25s ease;
    padding: 20px;
}

@keyframes ipModalFade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* 弹窗默认高 880px，宽由 .ip-modal-landscape / .ip-modal-portrait 决定 */
.ip-modal {
    background: #fff;
    border-radius: 16px;
    width: 900px;
    max-width: 100%;
    height: 880px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
    animation: ipModalUp 0.3s ease;
}

/* 横版图片：1344 x 880 */
.ip-modal-landscape {
    width: 1344px;
}

/* 竖版图片：900 x 880 */
.ip-modal-portrait {
    width: 900px;
}

@keyframes ipModalUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.ip-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.ip-modal-header-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
}

.ip-modal-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: #f0f0f0;
    color: #666;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

    .ip-modal-close:hover {
        background: #e5e5e5;
        color: #333;
    }

.ip-modal-body {
    display: flex;
    gap: 24px;
    padding: 22px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* 左侧大图预览区（占据弹窗除右侧 380px 以外的全部宽度与高度） */
.ip-modal-preview {
    position: relative;
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    height: 100%;
    background: #f5f5f5;
    border-radius: 12px;
    overflow: hidden;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
}

    /* 图片在左侧区域内尽量填满（不裁切） */
    .ip-modal-preview img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        display: block;
    }

/* 右侧表单区（固定 380px） */
.ip-modal-form {
    flex: 0 0 380px;
    width: 380px;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.ip-modal-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.4;
    margin-bottom: 16px;
    word-break: break-all;
}

.ip-modal-form .size-selector {
    margin-bottom: 14px;
}

/* 详细提示词（支持修改，撑满右列剩余高度） */
.ip-prompt-input {
    width: 100%;
    flex: 1 1 auto;
    min-height: 240px;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text);
    white-space: pre-wrap;
    resize: vertical;
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

    .ip-prompt-input:focus {
        border-color: var(--color-primary);
        box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.12);
    }

#ipGenerateBtn {
    width: 100%;
    margin-top: 16px;
    justify-content: center;
}

    #ipGenerateBtn:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

/* ========== 生成中：预览区半透明遮罩 + loading + 倒计时 ========== */
.ip-preview-mask {
    position: absolute;
    inset: 0;
    background: rgba(17, 17, 17, 0.55);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 20;
}

.ip-spin {
    width: 42px;
    height: 42px;
    border: 3px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ipSpin 0.9s linear infinite;
}

@keyframes ipSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.ip-gen-text {
    font-size: 14px;
    color: #fff;
    text-align: center;
    padding: 0 18px;
    line-height: 1.5;
}

.ip-gen-bar {
    width: 70%;
    height: 6px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.25);
    overflow: hidden;
}

.ip-gen-fill {
    height: 100%;
    width: 1%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-hover));
    transition: width 0.3s ease;
}

/* ========== 结果图右下角功能按钮 ========== */
.ip-result-actions {
    position: absolute;
    right: 10px;
    bottom: 10px;
    display: flex;
    gap: 8px;
    z-index: 25;
}

    .ip-result-actions .result-download-btn,
    .ip-result-actions .img-redraw-open-btn,
    .ip-result-actions .psd-export-btn {
        /* 必须 !important：.img-redraw-open-btn 自带 margin-top/margin-left 为 !important，否则三个按钮上下错位 */
        margin-top: 0 !important;
        margin-left: 0 !important;
        font-size: 12px;
        padding: 6px 10px;
        background: rgba(0, 0, 0, 0.55);
        color: #fff;
        border: 1px solid rgba(255, 255, 255, 0.35);
        box-shadow: none;
    }

        .ip-result-actions .result-download-btn:hover,
        .ip-result-actions .img-redraw-open-btn:hover,
        .ip-result-actions .psd-export-btn:hover {
            background: rgba(0, 0, 0, 0.75);
        }

/* ========== 响应式 ========== */
@media (min-width: 640px) and (max-width: 1023px) {
    .ip-cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 639px) {
    .ip-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .ip-modal-body {
        flex-direction: column;
    }

    /* 移动端：弹窗不再固定 880px，预览区整宽 + 固定高度 */
    .ip-modal {
        height: auto;
        max-height: calc(100vh - 40px);
    }

    .ip-modal-preview {
        width: 100%;
        flex: none;
        height: 320px;
    }

    .ip-modal-form {
        width: 100%;
        flex: none;
    }

    .design-panel {
        display: none;
    }
}
