/* ===== AI IMAGE PAGE STYLES ===== */


.img-page-hero {
    text-align: center;
    padding: var(--spacing-lg) 0 var(--spacing-md);
}
.img-page-hero h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: var(--spacing-xxs);
}
.img-page-hero h1 em {
    font-style: normal;
    background: linear-gradient(135deg, var(--primary), #ff9a5c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.img-page-hero p {
    font-size: 14px;
    color: var(--ink-subtle);
}

/* Layout */
.img-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: var(--spacing-lg);
    align-items: start;
}

/* Settings Panel */
.img-settings {
    background: var(--surface-1);
    border: 1px solid var(--hairline);
    border-radius: var(--rounded-xl);
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    position: sticky;
    top: calc(var(--header-offset) + var(--spacing-md));
}

.img-field-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-muted);
    margin-bottom: var(--spacing-xs);
}
.img-field-label .char-count {
    font-size: 11px;
    font-weight: 400;
    color: var(--ink-tertiary);
    font-variant-numeric: tabular-nums;
}

/* Mode Toggle */
.img-mode-toggle {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 2px;
    background: var(--hairline);
    border-radius: var(--rounded-md);
    padding: 2px;
}
.img-mode-btn {
    padding: 10px 16px;
    background: var(--surface-2);
    border: none;
    border-radius: var(--rounded-sm);
    color: var(--ink-subtle);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: center;
}
.img-mode-btn:hover {
    color: var(--ink-muted);
}
.img-mode-btn.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(204, 82, 0, 0.25);
}

/* Prompt textarea */
.img-prompt-area {
    position: relative;
}
.img-prompt-area textarea {
    width: 100%;
    min-height: 140px;
    padding: var(--spacing-sm);
    background: var(--surface-2);
    border: 1px solid var(--hairline);
    border-radius: var(--rounded-md);
    color: var(--ink);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.2s;
}
.img-prompt-area textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.img-prompt-area textarea::placeholder {
    color: var(--ink-tertiary);
}
.img-lang-hint {
    position: absolute;
    top: var(--spacing-xs);
    right: var(--spacing-xs);
    padding: 2px 8px;
    background: var(--surface-3);
    border: 1px solid var(--hairline);
    border-radius: var(--rounded-xs);
    font-size: 10px;
    font-weight: 600;
    color: var(--ink-subtle);
    letter-spacing: 0.5px;
    pointer-events: none;
}

/* Example Tags */
.img-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: var(--spacing-xs);
}
.img-example-label {
    font-size: 11px;
    color: var(--ink-tertiary);
    line-height: 26px;
    margin-right: 2px;
}
.img-example-btn {
    padding: 4px 10px;
    background: var(--surface-3);
    border: 1px solid var(--hairline);
    border-radius: var(--rounded-pill);
    color: var(--ink-subtle);
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
}
.img-example-btn:hover {
    border-color: var(--primary-subtle);
    color: var(--primary);
    background: var(--primary-subtler);
}

/* Upload Area */
.img-upload-zone {
    border: 2px dashed var(--hairline-strong);
    border-radius: var(--rounded-lg);
    padding: var(--spacing-lg) var(--spacing-md);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--surface-2);
    position: relative;
    overflow: hidden;
}
.img-upload-zone:hover,
.img-upload-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-subtler);
}
.img-upload-zone .upload-emoji {
    font-size: 32px;
    margin-bottom: var(--spacing-xs);
    display: block;
}
.img-upload-zone p {
    font-size: 13px;
    color: var(--ink-subtle);
    margin-bottom: 2px;
}
.img-upload-zone .upload-sub {
    font-size: 11px;
    color: var(--ink-tertiary);
}
.img-upload-preview {
    position: relative;
    display: none;
}
.img-upload-preview img {
    max-width: 100%;
    max-height: 180px;
    border-radius: var(--rounded-md);
    display: block;
    margin: 0 auto;
}
.img-upload-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 24px;
    height: 24px;
    background: var(--semantic-error);
    color: #fff;
    border: 2px solid var(--surface-1);
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: transform 0.15s;
}
.img-upload-remove:hover {
    transform: scale(1.1);
}

/* Size Grid */
.img-size-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.img-size-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 12px 4px 10px;
    background: var(--surface-2);
    border: 1px solid var(--hairline);
    border-radius: var(--rounded-md);
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
    color: var(--ink-subtle);
}
.img-size-btn:hover {
    border-color: var(--hairline-strong);
    background: var(--surface-3);
}
.img-size-btn.active {
    border-color: var(--primary);
    background: var(--primary-subtle);
    color: var(--primary);
}
.img-size-icon {
    display: block;
    border: 1.5px solid currentColor;
    border-radius: 2px;
    opacity: 0.7;
}
.img-size-btn.active .img-size-icon {
    opacity: 1;
}
.img-size-ratio {
    font-size: 12px;
    font-weight: 600;
}
.img-size-dim {
    font-size: 9px;
    opacity: 0.6;
    letter-spacing: 0.3px;
}

/* Locked Value */
.img-locked-value {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 10px var(--spacing-sm);
    background: var(--surface-2);
    border: 1px solid var(--hairline);
    border-radius: var(--rounded-md);
    font-size: 13px;
    color: var(--ink-subtle);
    cursor: not-allowed;
    opacity: 0.7;
}
.img-locked-icon {
    font-size: 16px;
}

/* Generate Button */
.img-generate-wrap {
    padding-top: var(--spacing-xs);
}
.img-generate-btn {
    width: 100%;
    padding: 14px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--rounded-md);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 12px rgba(204, 82, 0, 0.2);
}
.img-generate-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(204, 82, 0, 0.35);
    background: var(--primary-hover);
}
.img-generate-btn:active:not(:disabled) {
    transform: translateY(0);
}
.img-generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.img-generate-tip {
    font-size: 11px;
    color: var(--ink-tertiary);
    text-align: center;
    margin-top: var(--spacing-xs);
}

/* Output Panel */
.img-output {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* Result Canvas */
.img-result-canvas {
    background: var(--surface-1);
    border: 1px solid var(--hairline);
    border-radius: var(--rounded-xl);
    overflow: hidden;
    min-height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.img-result-inner {
    width: 100%;
    padding: var(--spacing-lg);
}

/* Placeholder */
.img-placeholder {
    text-align: center;
    padding: var(--spacing-xxl) 0;
}
.img-placeholder .ph-icon {
    font-size: 56px;
    margin-bottom: var(--spacing-sm);
    opacity: 0.6;
}
.img-placeholder .ph-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink-muted);
    margin-bottom: 4px;
}
.img-placeholder .ph-sub {
    font-size: 13px;
    color: var(--ink-tertiary);
}

/* Loading */
.img-loading {
    text-align: center;
    padding: var(--spacing-xxl) 0;
    display: none;
}
.img-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--hairline);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: imgSpin 0.8s linear infinite;
    margin: 0 auto var(--spacing-md);
}
@keyframes imgSpin { to { transform: rotate(360deg); } }
.img-loading .ld-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink-muted);
    margin-bottom: 4px;
}
.img-loading .ld-sub {
    font-size: 12px;
    color: var(--ink-tertiary);
}

/* Result Image */
.img-result-display {
    display: none;
}
.img-result-display img {
    width: 100%;
    border-radius: var(--rounded-md);
    display: block;
}
.img-result-actions {
    display: flex;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-md);
    flex-wrap: wrap;
}
.img-action-btn {
    padding: 10px 20px;
    background: var(--surface-3);
    border: 1px solid var(--hairline);
    border-radius: var(--rounded-md);
    color: var(--ink-muted);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}
.img-action-btn:hover {
    border-color: var(--hairline-strong);
    background: var(--surface-4);
    color: var(--ink);
}
.img-action-btn.primary {
    background: var(--primary-subtle);
    border-color: var(--primary);
    color: var(--primary);
}
.img-action-btn.primary:hover {
    background: var(--primary);
    color: #fff;
}

/* FAQ */
.img-faq {
    background: var(--surface-1);
    border: 1px solid var(--hairline);
    border-radius: var(--rounded-xl);
    padding: var(--spacing-lg);
}
.img-faq-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}
.img-faq-item {
    border-bottom: 1px solid var(--hairline);
}
.img-faq-item:last-child {
    border-bottom: none;
}
.img-faq-q {
    width: 100%;
    background: none;
    border: none;
    padding: var(--spacing-sm) 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: inherit;
    transition: color 0.15s;
}
.img-faq-q:hover {
    color: var(--primary);
}
.img-faq-q::after {
    content: '+';
    font-size: 18px;
    color: var(--ink-tertiary);
    transition: transform 0.3s ease;
    flex-shrink: 0;
    margin-left: var(--spacing-sm);
}
.img-faq-item.open .img-faq-q::after {
    transform: rotate(45deg);
    color: var(--primary);
}
.img-faq-a {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}
.img-faq-item.open .img-faq-a {
    max-height: 200px;
}
.img-faq-a p {
    padding: 0 0 var(--spacing-sm);
    font-size: 13px;
    color: var(--ink-subtle);
    line-height: 1.7;
}

/* History */
.img-history {
    background: var(--surface-1);
    border: 1px solid var(--hairline);
    border-radius: var(--rounded-xl);
    padding: var(--spacing-lg);
}
.img-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}
.img-history-title {
    font-size: 16px;
    font-weight: 700;
}
.img-history-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: var(--surface-2);
    border: 1px solid var(--hairline);
    border-radius: 100px;
    padding: 2px 10px;
    line-height: 1.4;
}
.img-history-tip {
    font-size: 12px;
    color: var(--ink-muted);
    background: var(--surface-2);
    border-radius: var(--rounded-sm);
    padding: 8px 12px;
    margin-bottom: var(--spacing-md);
    line-height: 1.5;
}
.img-history-delete-all {
    font-size: 11px;
    color: var(--danger, #e74c3c);
    background: none;
    border: 1px solid var(--danger, #e74c3c);
    border-radius: var(--rounded-sm, 4px);
    padding: 3px 10px;
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
}
.img-history-delete-all:hover {
    background: var(--danger, #e74c3c);
    color: #fff;
}
.img-history-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--spacing-sm);
}
.img-history-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--spacing-xl) 0;
    color: var(--ink-tertiary);
    font-size: 13px;
}
.img-history-card {
    position: relative;
    border-radius: var(--rounded-md);
    overflow: hidden;
    border: 1px solid var(--hairline);
    background: var(--surface-2);
    cursor: pointer;
    transition: var(--transition-fast);
}
.img-history-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}
.img-history-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}
.img-history-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-3);
    overflow: hidden;
}
.img-history-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.img-history-thumb.broken {
    flex-direction: column;
    gap: 4px;
    background: var(--surface-2);
}
.img-broken-icon {
    font-size: 24px;
    opacity: 0.3;
}
.img-broken-text {
    font-size: 11px;
    color: var(--ink-tertiary);
}
.img-history-info {
    padding: var(--spacing-xs);
}
.img-history-prompt {
    font-size: 11px;
    color: var(--ink-subtle);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}
.img-history-time {
    font-size: 10px;
    color: var(--ink-tertiary);
}
.img-history-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.img-history-card:hover .img-history-delete {
    display: flex;
}

/* Responsive */
@media (max-width: 900px) {
    .img-layout {
        grid-template-columns: 1fr;
    }
    .img-settings {
        position: static;
    }
    .img-size-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
@media (max-width: 500px) {
    .img-page-hero h1 { font-size: 22px; }
    .img-size-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
