/* ============================================================
   AI Image Upscaler — Frontend CSS
   Design: Google Gemini Dark Mode inspired premium SaaS UI
   ============================================================ */

/* ── CSS Variables ──────────────────────────────────────────── */
.aiu-app {
    --bg-base:        #0f0f11;
    --bg-surface:     #1a1b1e;
    --bg-elevated:    #22242a;
    --bg-hover:       #2a2c33;
    --border:         rgba(255,255,255,0.08);
    --border-focus:   rgba(138,180,248,0.5);
    --text-primary:   #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted:     #5f6368;
    --accent-blue:    #8ab4f8;
    --accent-purple:  #c084fc;
    --accent-teal:    #34d399;
    --accent-orange:  #fb923c;
    --accent-red:     #f87171;
    --gradient-main:  linear-gradient(135deg, #8ab4f8 0%, #c084fc 100%);
    --gradient-btn:   linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --shadow-sm:      0 1px 3px rgba(0,0,0,0.4);
    --shadow-md:      0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg:      0 8px 32px rgba(0,0,0,0.6);
    --radius-sm:      8px;
    --radius-md:      12px;
    --radius-lg:      16px;
    --radius-xl:      24px;
    --transition:     0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ──────────────────────────────────────────────────── */
.aiu-app *,
.aiu-app *::before,
.aiu-app *::after { box-sizing: border-box; }

.aiu-app {
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: 'Google Sans', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    max-width: 860px;
    margin: 0 auto;
    padding: 32px 20px 48px;
    min-height: 500px;
}

/* ── Header ─────────────────────────────────────────────────── */
.aiu-app-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 32px;
}

.aiu-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.aiu-header-icon {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    filter: drop-shadow(0 0 16px rgba(138,180,248,0.4));
}

.aiu-header-icon svg { width: 100%; height: 100%; }

.aiu-header-text h1 {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.4px;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 4px;
    line-height: 1.2;
}

.aiu-header-text p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* ── Credit Badge ───────────────────────────────────────────── */
.aiu-credit-badge {
    flex-shrink: 0;
}

.aiu-credit-inner {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 40px;
    padding: 8px 16px;
    font-size: 14px;
}

.aiu-credit-inner svg {
    width: 14px;
    height: 14px;
    color: #fbbf24;
    fill: #fbbf24;
}

.aiu-balance-val {
    font-weight: 700;
    font-size: 16px;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: var(--transition);
}

.aiu-balance-label {
    color: var(--text-secondary);
    font-size: 12px;
}

/* ── Main Card ──────────────────────────────────────────────── */
.aiu-main-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.aiu-main-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: var(--gradient-main);
    opacity: 0.4;
}

/* ── Upload Zone ────────────────────────────────────────────── */
.aiu-upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    position: relative;
    overflow: hidden;
    background: var(--bg-elevated);
}

.aiu-upload-zone:hover,
.aiu-upload-zone.drag-over {
    border-color: var(--accent-blue);
    background: rgba(138,180,248,0.04);
}

.aiu-upload-zone.drag-over {
    background: rgba(138,180,248,0.08);
}

.aiu-upload-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px;
    text-align: center;
}

.aiu-upload-icon {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    transition: color var(--transition), transform var(--transition);
}
.aiu-upload-zone:hover .aiu-upload-icon {
    color: var(--accent-blue);
    transform: translateY(-2px);
}

.aiu-upload-icon svg { width: 100%; height: 100%; }

.aiu-upload-title {
    font-size: 17px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}
.aiu-upload-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 2px 0;
}
.aiu-upload-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

.aiu-link-btn {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
    font-family: inherit;
    color: var(--accent-blue);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.aiu-link-btn:hover { color: #a8c7fa; }

/* ── Preview ────────────────────────────────────────────────── */
.aiu-upload-preview {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    gap: 12px;
}

.aiu-preview-image-wrap {
    position: relative;
    max-width: 100%;
    max-height: 180px;
}

.aiu-preview-image-wrap img {
    max-height: 180px;
    max-width: 100%;
    border-radius: var(--radius-md);
    object-fit: contain;
    box-shadow: var(--shadow-md);
    display: block;
}

.aiu-remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 28px;
    height: 28px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
    padding: 0;
}

.aiu-remove-btn:hover {
    background: var(--accent-red);
    color: white;
    border-color: var(--accent-red);
}

.aiu-remove-btn svg { width: 16px; height: 16px; }

.aiu-preview-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.aiu-preview-name {
    color: var(--text-primary);
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aiu-preview-size {
    color: var(--text-muted);
}

/* ── Scale Options ──────────────────────────────────────────── */
.aiu-scale-section {
    margin-top: 24px;
}

.aiu-scale-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 12px;
}

.aiu-scale-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.aiu-scale-option {
    cursor: pointer;
}

.aiu-scale-option input { display: none; }

.aiu-scale-card {
    background: var(--bg-elevated);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    text-align: center;
    transition: all var(--transition);
    position: relative;
}

.aiu-scale-option:hover .aiu-scale-card {
    border-color: rgba(138,180,248,0.3);
    background: var(--bg-hover);
}

.aiu-scale-option.active .aiu-scale-card {
    border-color: var(--accent-blue);
    background: rgba(138,180,248,0.06);
    box-shadow: 0 0 0 1px rgba(138,180,248,0.2), 0 4px 16px rgba(138,180,248,0.1);
}

.aiu-scale-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.aiu-scale-option:not(.active) .aiu-scale-value {
    background: none;
    -webkit-text-fill-color: var(--text-secondary);
    color: var(--text-secondary);
}

.aiu-scale-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.aiu-scale-cost {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #fbbf24;
    background: rgba(251,191,36,0.1);
    border-radius: 20px;
    padding: 3px 10px;
}
.aiu-scale-cost svg { width: 10px; height: 10px; fill: #fbbf24; }

/* ── Action Button ──────────────────────────────────────────── */
.aiu-action-section {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.aiu-btn-upscale {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--gradient-btn);
    color: white;
    border: none;
    border-radius: 40px;
    padding: 14px 40px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 4px 20px rgba(102,126,234,0.4);
    letter-spacing: 0.3px;
    min-width: 200px;
}

.aiu-btn-upscale:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 28px rgba(102,126,234,0.55);
    filter: brightness(1.1);
}

.aiu-btn-upscale:active:not(:disabled) {
    transform: translateY(0);
}

.aiu-btn-upscale:disabled {
    background: var(--bg-hover);
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
}

.aiu-btn-upscale.loading {
    pointer-events: none;
}

.aiu-btn-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.aiu-btn-upscale.loading .aiu-btn-icon {
    animation: aiu-spin 0.8s linear infinite;
}

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

.aiu-action-meta {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.aiu-time-notice {
    font-size: 12px;
    color: var(--text-muted);
    margin: 6px 0 0;
    text-align: center;
    opacity: 0.7;
}

.aiu-time-notice strong {
    color: var(--text-secondary);
    font-weight: 600;
}

/* ── Progress ───────────────────────────────────────────────── */
.aiu-progress-section {
    margin-top: 28px;
    border-top: 1px solid var(--border);
    padding-top: 24px;
}

.aiu-progress-bar-wrap {
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 20px;
}

.aiu-progress-bar {
    height: 100%;
    background: var(--gradient-main);
    border-radius: 2px;
    width: 0%;
    transition: width 0.5s ease;
    position: relative;
    overflow: hidden;
}

.aiu-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: aiu-shimmer 1.5s infinite;
}

@keyframes aiu-shimmer {
    to { left: 100%; }
}

.aiu-progress-steps {
    display: flex;
    align-items: center;
    gap: 0;
}

.aiu-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    flex: 1;
    transition: color var(--transition);
}

.aiu-step.active { color: var(--accent-blue); }
.aiu-step.done   { color: var(--accent-teal); }

.aiu-step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg-hover);
    border: 2px solid currentColor;
    transition: all var(--transition);
    flex-shrink: 0;
}

.aiu-step.active .aiu-step-dot {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(138,180,248,0.2);
    animation: aiu-pulse 1.2s ease-in-out infinite;
}

.aiu-step.done .aiu-step-dot {
    background: var(--accent-teal);
    border-color: var(--accent-teal);
}

@keyframes aiu-pulse {
    0%,100% { box-shadow: 0 0 0 3px rgba(138,180,248,0.2); }
    50%      { box-shadow: 0 0 0 6px rgba(138,180,248,0.05); }
}

.aiu-step-line {
    height: 2px;
    background: var(--border);
    flex: 1;
    margin: 0 8px;
    max-width: 40px;
}

/* ── Result Section ─────────────────────────────────────────── */
.aiu-result-section {
    margin-top: 28px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 28px 32px;
    box-shadow: var(--shadow-md);
    animation: aiu-fadeSlide 0.4s ease;
}

@keyframes aiu-fadeSlide {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.aiu-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.aiu-result-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(52,211,153,0.12);
    color: var(--accent-teal);
    border: 1px solid rgba(52,211,153,0.25);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
}
.aiu-result-badge svg { width: 14px; height: 14px; }

.aiu-result-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ── Before/After Compare ───────────────────────────────────── */
.aiu-compare-wrap {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: center;
    margin-bottom: 24px;
}

.aiu-compare-original,
.aiu-compare-result {
    position: relative;
}

.aiu-compare-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.aiu-compare-original img,
.aiu-compare-result img {
    width: 100%;
    border-radius: var(--radius-md);
    display: block;
    box-shadow: var(--shadow-md);
    max-height: 300px;
    object-fit: contain;
    background: var(--bg-elevated);
}

.aiu-compare-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--accent-blue);
    flex-shrink: 0;
}
.aiu-compare-arrow svg { width: 18px; height: 18px; }

/* ── Result Actions ─────────────────────────────────────────── */
.aiu-result-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.aiu-btn-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--gradient-btn);
    color: white;
    border-radius: 40px;
    padding: 11px 28px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition);
    box-shadow: 0 4px 16px rgba(102,126,234,0.35);
}
.aiu-btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102,126,234,0.5);
    color: white;
    text-decoration: none;
}
.aiu-btn-download svg { width: 16px; height: 16px; }

.aiu-btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 40px;
    padding: 11px 24px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}
.aiu-btn-secondary:hover {
    border-color: rgba(138,180,248,0.4);
    background: var(--bg-hover);
}
.aiu-btn-secondary svg { width: 16px; height: 16px; }

/* ── Error Section ──────────────────────────────────────────── */
.aiu-error-section {
    margin-top: 20px;
    background: rgba(248,113,113,0.06);
    border: 1px solid rgba(248,113,113,0.2);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    animation: aiu-fadeSlide 0.3s ease;
}

.aiu-error-inner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.aiu-error-icon {
    width: 20px;
    height: 20px;
    color: var(--accent-red);
    flex-shrink: 0;
    margin-top: 1px;
}

.aiu-error-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-red);
    margin: 0 0 4px;
}

.aiu-error-msg {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

/* ── History ────────────────────────────────────────────────── */
.aiu-history-section {
    margin-top: 40px;
}

.aiu-history-header {
    margin-bottom: 16px;
}

.aiu-history-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

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

.aiu-history-item {
    cursor: pointer;
}

.aiu-history-thumb {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 1;
    background: var(--bg-elevated);
}

.aiu-history-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--transition);
}

.aiu-history-thumb:hover img {
    transform: scale(1.03);
}

.aiu-history-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
}

.aiu-history-thumb:hover .aiu-history-overlay {
    opacity: 1;
}

.aiu-history-dl {
    width: 36px;
    height: 36px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    text-decoration: none;
}
.aiu-history-dl svg { width: 16px; height: 16px; }

.aiu-history-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 2px 0;
}

.aiu-scale-badge {
    background: rgba(138,180,248,0.12);
    color: var(--accent-blue);
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.aiu-history-date {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Login Notice ───────────────────────────────────────────── */
.aiu-login-notice {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 32px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 15px;
}
.aiu-login-notice a { color: var(--accent-blue); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
    .aiu-app { padding: 20px 16px 40px; }
    .aiu-main-card { padding: 20px; }
    .aiu-app-header { flex-direction: column; }
    .aiu-compare-wrap {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .aiu-compare-arrow { transform: rotate(90deg); }
    .aiu-result-section { padding: 20px; }
    .aiu-result-actions { flex-direction: column; }
    .aiu-btn-download, .aiu-btn-secondary { width: 100%; justify-content: center; }
    .aiu-profile-options { grid-template-columns: repeat(2, 1fr); }
}

/* ── Image Profile Selector ─────────────────────────────────── */
.aiu-profile-section {
    margin-top: 24px;
}

.aiu-profile-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.aiu-profile-option {
    cursor: pointer;
}

.aiu-profile-option input { display: none; }

.aiu-profile-card {
    background: var(--bg-elevated);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 12px;
    text-align: center;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-height: 100px;
}

.aiu-profile-option:hover .aiu-profile-card {
    border-color: rgba(138,180,248,0.3);
    background: var(--bg-hover);
}

.aiu-profile-option.active .aiu-profile-card {
    border-color: var(--accent-blue);
    background: rgba(138,180,248,0.06);
    box-shadow: 0 0 0 1px rgba(138,180,248,0.2), 0 4px 16px rgba(138,180,248,0.1);
}

.aiu-profile-icon {
    font-size: 22px;
    line-height: 1;
}

.aiu-profile-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: color var(--transition);
}

.aiu-profile-option.active .aiu-profile-label {
    color: var(--accent-blue);
}

.aiu-profile-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.3;
}

@media (max-width: 560px) {
    .aiu-profile-options { grid-template-columns: repeat(2, 1fr); }
}

