/* ======================================================================
   AI Image Generator - Style
   匹配 Zibll (子比) 主题风格
   ====================================================================== */

/* -- 容器 -- */
.aig-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* -- 头部 -- */
.aig-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    margin-bottom: 20px;
    color: #fff;
    flex-wrap: wrap;
}

.aig-header-icon {
    width: 56px;
    height: 56px;
    background: rgba(255,255,255,0.2);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.aig-header-icon svg {
    stroke: #fff;
}

.aig-header-text {
    flex: 1;
    min-width: 200px;
}

.aig-header-text h2 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}

.aig-header-text p {
    margin: 0;
    font-size: 14px;
    opacity: 0.85;
    color: #fff;
}

.aig-header-quota {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    padding: 10px 18px;
    flex-shrink: 0;
}

.aig-quota-label {
    font-size: 12px;
    opacity: 0.8;
}

.aig-quota-count {
    font-size: 20px;
    font-weight: 700;
}

/* -- 表单区域 -- */
.aig-form-section {
    background: var(--main-bg-color, #fff);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid var(--main-border-color, #eee);
    margin-bottom: 20px;
}

.aig-prompt-box {
    position: relative;
}

.aig-textarea {
    width: 100%;
    min-height: 120px;
    padding: 16px;
    border: 2px solid var(--main-border-color, #e8e8e8);
    border-radius: 10px;
    font-size: 15px;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--main-bg-color, #fff);
    color: var(--main-color, #333);
    box-sizing: border-box;
    font-family: inherit;
}

.aig-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.aig-textarea::placeholder {
    color: #aaa;
}

.aig-prompt-footer {
    display: flex;
    justify-content: flex-end;
    padding: 6px 4px 0;
}

.aig-char-count {
    font-size: 12px;
    color: #999;
}

/* -- 参数区 -- */
.aig-params {
    margin-top: 20px;
}

.aig-param-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.aig-param-item {
    flex: 1;
    min-width: 200px;
}

.aig-param-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted-color, #666);
    margin-bottom: 8px;
}

.aig-select-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
}

.aig-select {
    flex: 1;
    height: 40px;
    padding: 0 12px;
    border: 1.5px solid var(--main-border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 14px;
    background: var(--main-bg-color, #fff);
    color: var(--main-color, #333);
    cursor: pointer;
    transition: border-color 0.2s;
}

.aig-select:focus {
    outline: none;
    border-color: #667eea;
}

.aig-btn-icon {
    width: 40px;
    height: 40px;
    border: 1.5px solid var(--main-border-color, #e0e0e0);
    border-radius: 8px;
    background: var(--main-bg-color, #fff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    color: var(--muted-color, #666);
}

.aig-btn-icon:hover {
    border-color: #667eea;
    color: #667eea;
}

.aig-btn-icon svg {
    stroke: currentColor;
}

.aig-btn-icon.loading svg {
    animation: aig-spin 1s linear infinite;
}

/* -- 尺寸选择 -- */
.aig-size-presets {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.aig-size-btn {
    flex: 1;
    height: 36px;
    border: 1.5px solid var(--main-border-color, #e0e0e0);
    border-radius: 8px;
    background: var(--main-bg-color, #fff);
    color: var(--muted-color, #666);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.aig-size-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.aig-size-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: #fff;
}

.aig-size-custom {
    display: flex;
    align-items: center;
    gap: 8px;
}

.aig-input-sm {
    flex: 1;
    height: 36px;
    padding: 0 10px;
    border: 1.5px solid var(--main-border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    background: var(--main-bg-color, #fff);
    color: var(--main-color, #333);
    transition: border-color 0.2s;
    max-width: 100px;
}

.aig-input-sm:focus {
    outline: none;
    border-color: #667eea;
}

.aig-size-x {
    color: #999;
    font-weight: 600;
}

/* -- 生成按钮 -- */
.aig-generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 50px;
    margin-top: 24px;
    padding: 0 24px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

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

.aig-generate-btn:active {
    transform: translateY(0);
}

.aig-generate-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.aig-generate-btn .aig-btn-icon-svg {
    stroke: #fff;
}

/* -- 状态 -- */
.aig-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    background: var(--main-bg-color, #fff);
    border-radius: 12px;
    border: 1px solid var(--main-border-color, #eee);
    margin-bottom: 20px;
    color: var(--muted-color, #666);
    font-size: 14px;
}

.aig-loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: aig-spin 0.8s linear infinite;
}

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

/* -- 错误提示 -- */
.aig-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 16px 20px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    margin-bottom: 20px;
    color: #b91c1c;
    font-size: 14px;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
    word-break: break-all;
}

.aig-error svg {
    flex-shrink: 0;
    margin-top: 2px;
    stroke: #dc2626;
}

/* -- 结果展示 -- */
.aig-result {
    background: var(--main-bg-color, #fff);
    border-radius: 12px;
    border: 1px solid var(--main-border-color, #eee);
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.aig-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--main-border-color, #eee);
    flex-wrap: wrap;
    gap: 10px;
}

.aig-result-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--main-color, #333);
}

.aig-result-actions {
    display: flex;
    gap: 8px;
}

.aig-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1.5px solid var(--main-border-color, #e0e0e0);
    border-radius: 8px;
    background: var(--main-bg-color, #fff);
    color: var(--muted-color, #555);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.aig-action-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.aig-action-btn svg {
    stroke: currentColor;
}

.aig-result-image-wrap {
    padding: 16px;
    text-align: center;
    background: #f9fafb;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aig-result-image-wrap img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.3s;
}

.aig-result-image-wrap img:hover {
    transform: scale(1.02);
}

.aig-result-meta {
    padding: 12px 20px;
    border-top: 1px solid var(--main-border-color, #eee);
    font-size: 12px;
    color: #999;
}

.aig-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* -- 历史记录 -- */
.aig-history {
    background: var(--main-bg-color, #fff);
    border-radius: 12px;
    border: 1px solid var(--main-border-color, #eee);
    padding: 20px;
    margin-bottom: 20px;
}

.aig-history h3 {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 600;
    color: var(--main-color, #333);
}

.aig-history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.aig-history-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 1;
    cursor: pointer;
    border: 1px solid var(--main-border-color, #eee);
    transition: transform 0.2s, box-shadow 0.2s;
}

.aig-history-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

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

/* -- 登录提示 -- */
.aig-login-required {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted-color, #666);
}

.aig-login-icon {
    margin-bottom: 16px;
    color: #999;
}

.aig-login-icon svg {
    fill: #ccc;
}

.aig-login-required a {
    color: #667eea;
    font-weight: 600;
    text-decoration: none;
}

.aig-login-required a:hover {
    text-decoration: underline;
}

/* -- 图片灯箱 -- */
.aig-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    animation: aig-fade-in 0.2s ease;
    backdrop-filter: blur(8px);
}

.aig-lightbox img {
    max-width: 92%;
    max-height: 92%;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}

.aig-lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 100000;
}

.aig-lightbox-close:hover {
    background: rgba(255,255,255,0.3);
}

@keyframes aig-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* -- 复制成功提示 -- */
.aig-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    background: #333;
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    z-index: 99999;
    animation: aig-toast-in 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

@keyframes aig-toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* -- 响应式 -- */
@media (max-width: 768px) {
    .aig-header {
        padding: 18px;
    }

    .aig-header-text h2 {
        font-size: 18px;
    }

    .aig-header-quota {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
    }

    .aig-form-section {
        padding: 16px;
    }

    .aig-param-row {
        flex-direction: column;
        gap: 16px;
    }

    .aig-param-item {
        min-width: 0;
    }

    .aig-generate-btn {
        height: 46px;
        font-size: 15px;
    }

    .aig-result-header {
        padding: 12px 16px;
    }

    .aig-result-image-wrap {
        padding: 12px;
    }

    .aig-history-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }

    .aig-result-actions {
        width: 100%;
    }

    .aig-action-btn {
        flex: 1;
        justify-content: center;
    }
}

/* -- 暗黑模式适配 -- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .aig-result-image-wrap {
        background: #1a1a2e;
    }

    :root:not([data-theme="light"]) .aig-error {
        background: #2d1b1b;
        border-color: #5c2020;
        color: #f87171;
    }

    :root:not([data-theme="light"]) .aig-error svg {
        stroke: #f87171;
    }
}

/* Zibll 暗黑模式 */
body.dark-theme .aig-result-image-wrap {
    background: #1a1a2e;
}

body.dark-theme .aig-error {
    background: #2d1b1b;
    border-color: #5c2020;
    color: #f87171;
}

body.dark-theme .aig-error svg {
    stroke: #f87171;
}
