/* ========================================
   图文生图页面样式
   ======================================== */

.ig-page {
    margin-top: 60px;
    min-height: calc(100vh - 60px);
    padding: 32px 24px 64px;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ig-page-header {
    text-align: center;
    margin-bottom: 32px;
}

.ig-page-header h1 {
    font-size: 28px;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.ig-page-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

.ig-page-content {
    display: flex;
    gap: 24px;
    width: 100%;
    max-width: 1200px;
}

/* ========================================
   左侧输入面板
   ======================================== */

.ig-input-panel {
    flex: 0 0 38%;
    max-width: 480px;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ig-input-panel h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* 模式切换 Tabs */
.ig-mode-tabs {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 4px;
    gap: 4px;
}

.ig-mode-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ig-mode-tab:hover {
    color: var(--text-primary);
}

.ig-mode-tab.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .ig-mode-tab.active {
    background: var(--bg-tertiary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* 图片上传区域 */
.ig-upload-area {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    overflow: hidden;
    background: var(--bg-secondary);
}

.ig-upload-area:hover {
    border-color: var(--primary-color);
    background: var(--bg-tertiary);
}

.ig-upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.15);
}

.ig-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 24px;
    color: var(--text-muted);
}

.ig-upload-placeholder svg {
    opacity: 0.5;
}

.ig-upload-placeholder p {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.ig-upload-placeholder span {
    font-size: 12px;
    color: var(--text-muted);
}

/* 多图预览列表 */
.ig-upload-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    width: 100%;
}

.ig-upload-preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.ig-upload-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ig-upload-preview-item .ig-remove-item-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 0;
}

.ig-upload-preview-item .ig-remove-item-btn:hover {
    background: rgba(239, 68, 68, 0.9);
    transform: scale(1.1);
}

.ig-upload-preview-item .ig-remove-item-btn svg {
    width: 10px;
    height: 10px;
}

/* 上传操作按钮 */
.ig-upload-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.ig-add-more-btn,
.ig-clear-all-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ig-add-more-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.ig-clear-all-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
}

.ig-remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ig-remove-btn:hover {
    background: rgba(239, 68, 68, 0.9);
    transform: scale(1.1);
}

/* 提示词 */
.ig-prompt-section textarea,
.ig-negative-section textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
    transition: border-color var(--transition-fast);
    box-sizing: border-box;
    line-height: 1.5;
}

.ig-prompt-section textarea:focus,
.ig-negative-section textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ig-prompt-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.ig-char-count {
    font-size: 12px;
    color: var(--text-muted);
}

/* 反向提示词折叠 */
.ig-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
}

.ig-section-header h3 {
    margin-bottom: 0;
}

.ig-toggle-arrow {
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.ig-toggle-arrow.open {
    transform: rotate(180deg);
}

.ig-negative-body {
    margin-top: 8px;
}

.ig-negative-section textarea {
    min-height: 70px;
}

/* ========================================
   生成配置
   ======================================== */

.ig-config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.ig-config-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ig-config-item label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.ig-config-full {
    grid-column: 1 / -1;
}

.ig-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.ig-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 模型选择器 */
.ig-model-selector {
    display: flex;
    gap: 10px;
}

.ig-model-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.ig-model-option:hover {
    border-color: var(--primary-color);
}

.ig-model-option.active {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

[data-theme="dark"] .ig-model-option.active {
    background: rgba(102, 126, 234, 0.1);
}

.ig-model-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.ig-model-desc {
    font-size: 11px;
    color: var(--text-muted);
}

.ig-model-badge {
    position: absolute;
    top: -1px;
    right: -1px;
    padding: 2px 8px;
    background: var(--primary-gradient);
    color: white;
    font-size: 10px;
    font-weight: 700;
    border-radius: 0 var(--radius-md) 0 var(--radius-sm);
    letter-spacing: 0.5px;
}

/* 宽高比选择器 */
.ig-ratio-selector {
    display: flex;
    gap: 6px;
}

.ig-ratio-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ig-ratio-btn:hover {
    border-color: var(--primary-color);
}

.ig-ratio-btn.active {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.08);
}

.ig-ratio-icon {
    border: 1.5px solid var(--text-muted);
    border-radius: 2px;
    transition: border-color var(--transition-fast);
}

.ig-ratio-btn.active .ig-ratio-icon {
    border-color: var(--primary-color);
}

.ig-ratio-btn span {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
}

.ig-ratio-btn.active span {
    color: var(--primary-color);
}

/* ========================================
   生成按钮
   ======================================== */

.ig-generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: var(--primary-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

.ig-generate-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

.ig-generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.ig-generate-btn.generating {
    opacity: 0.7;
    cursor: wait;
}

/* ========================================
   右侧结果面板
   ======================================== */

.ig-result-panel {
    flex: 1;
    min-width: 0;
}

.ig-result-panel > h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.ig-result-area {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    min-height: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* 空状态 */
.ig-result-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 24px;
    color: var(--text-muted);
    text-align: center;
}

.ig-result-empty p {
    font-size: 14px;
    color: var(--text-secondary);
}

.ig-result-empty span {
    font-size: 12px;
}

/* 加载状态 */
.ig-result-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 48px 24px;
    text-align: center;
    width: 100%;
}

.ig-loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: ig-spin 1s linear infinite;
}

@keyframes ig-spin {
    to { transform: rotate(360deg); }
}

.ig-loading-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.ig-loading-subtext {
    font-size: 13px;
    color: var(--text-muted);
}

.ig-progress-container {
    width: 80%;
    max-width: 300px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.ig-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--primary-gradient);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.ig-progress-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-color);
}

/* 结果画廊 */
.ig-result-gallery {
    display: grid;
    gap: 12px;
    padding: 16px;
    width: 100%;
}

.ig-result-gallery.single {
    grid-template-columns: 1fr;
}

.ig-result-gallery.multi {
    grid-template-columns: 1fr 1fr;
}

.ig-result-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.ig-result-item:hover {
    transform: scale(1.02);
}

.ig-result-item img {
    width: 100%;
    display: block;
    border-radius: var(--radius-md);
}

.ig-result-item-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 12px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.ig-result-item:hover .ig-result-item-actions {
    opacity: 1;
}

.ig-result-action-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.ig-result-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

/* 错误状态 */
.ig-result-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 48px 24px;
    text-align: center;
}

.ig-error-text {
    font-size: 14px;
    color: #ef4444;
}

.ig-retry-btn {
    padding: 8px 24px;
    background: var(--primary-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ig-retry-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

/* ========================================
   历史记录
   ======================================== */

.ig-history {
    margin-top: 24px;
}

.ig-history h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.ig-history-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.ig-history-item {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

.ig-history-item:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.ig-history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ig-history-item {
    position: relative;
    aspect-ratio: 1;
}

.ig-history-item-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px 8px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    display: flex;
    flex-direction: column;
    gap: 2px;
    pointer-events: none;
}

.ig-history-item-prompt {
    font-size: 11px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ig-history-item-date {
    font-size: 10px;
    color: rgba(255,255,255,0.6);
}

.ig-history-item-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.ig-history-load-more {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ig-history-load-more:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* ========================================
   生成队列
   ======================================== */

.ig-queue-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    overflow: hidden;
    margin-bottom: 12px;
}

.ig-queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.ig-queue-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.ig-queue-clear-btn {
    padding: 3px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ig-queue-clear-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
}

.ig-queue-list {
    max-height: 280px;
    overflow-y: auto;
}

.ig-queue-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}

.ig-queue-item:last-child {
    border-bottom: none;
}

.ig-queue-item:hover {
    background: var(--bg-tertiary);
}

.ig-queue-item.status-completed {
    opacity: 0.75;
}

.ig-queue-item.status-failed {
    background: rgba(239, 68, 68, 0.03);
}

.ig-queue-item-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ig-queue-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: ig-spin 0.8s linear infinite;
}

.ig-queue-item-body {
    flex: 1;
    min-width: 0;
}

.ig-queue-item-prompt {
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.ig-queue-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 3px;
}

.ig-queue-item-status {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.ig-queue-item.status-generating .ig-queue-item-status {
    color: var(--primary-color);
}

.ig-queue-item.status-completed .ig-queue-item-status {
    color: #10b981;
}

.ig-queue-item.status-failed .ig-queue-item-status {
    color: #ef4444;
}

.ig-queue-item-order {
    font-size: 10px;
    color: var(--text-muted);
}

.ig-queue-item-progress {
    margin-top: 5px;
    height: 3px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.ig-queue-item-progress-bar {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* ========================================
   图片预览 Lightbox
   ======================================== */

.ig-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.ig-lightbox.show {
    opacity: 1;
    visibility: visible;
}

.ig-lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.ig-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.ig-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ========================================
   Toast 通知
   ======================================== */

.ig-toast {
    position: fixed;
    top: 80px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: white;
    z-index: 9999;
    animation: ig-toast-in 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ig-toast.success { background: #10b981; }
.ig-toast.error { background: #ef4444; }
.ig-toast.info { background: #3b82f6; }

@keyframes ig-toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ========================================
   响应式
   ======================================== */

@media (max-width: 900px) {
    .ig-page {
        padding: 20px 16px;
    }

    .ig-page-content {
        flex-direction: column;
    }

    .ig-input-panel {
        flex: none;
        width: 100%;
    }

    .ig-config-grid {
        grid-template-columns: 1fr;
    }

    .ig-result-gallery.multi {
        grid-template-columns: 1fr;
    }

    .ig-history-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .ig-ratio-selector {
        flex-wrap: wrap;
    }

    .ig-model-selector {
        flex-direction: column;
    }

    .ig-history-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
