/* ─── Reset & Base ────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    min-height: 100vh;
    color: #e0e0e0;
}

.container {
    background: rgba(30, 30, 50, 0.95);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.08);
}

h1 {
    text-align: center;
    color: #fff;
    margin-bottom: 6px;
    font-size: 28px;
}

.subtitle {
    text-align: center;
    color: #aaa;
    margin-bottom: 24px;
    font-size: 14px;
}

/* ─── Connection Status ───────────────────────────────────────── */
.connection-status {
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255,255,255,0.05);
}

.connection-status .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #666;
    animation: pulse 2s infinite;
}

.connection-status.connected .status-dot { background: #4caf50; }
.connection-status.error .status-dot { background: #f44336; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ─── Engine Selector ─────────────────────────────────────────── */
.engine-selector {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.engine-btn {
    padding: 12px 28px;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05);
    color: #ccc;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.engine-btn:hover:not(.disabled) {
    border-color: rgba(255,255,255,0.35);
    color: #fff;
}

.engine-btn.active {
    border-color: #7c5cfc;
    background: linear-gradient(135deg, #7c5cfc, #a855f7);
    color: #fff;
    box-shadow: 0 4px 20px rgba(124,92,252,0.4);
}

.engine-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.engine-btn .badge {
    display: inline-block;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(255,255,255,0.15);
    margin-left: 8px;
    vertical-align: middle;
}

/* ─── Status Bar ──────────────────────────────────────────────── */
.status-bar {
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13px;
}

.status-bar::after {
    content: attr(data-desc);
    color: #aaa;
}

.status-bar.seedream { background: rgba(33,150,243,0.15); border-left: 3px solid #2196f3; }
.status-bar.replicate { background: rgba(168,85,247,0.15); border-left: 3px solid #a855f7; }
.status-bar.xai { background: rgba(255,152,0,0.15); border-left: 3px solid #ff9800; }
.status-bar.doubao { background: rgba(76,175,80,0.15); border-left: 3px solid #4caf50; }
.status-bar.doubao45 { background: rgba(0,188,212,0.15); border-left: 3px solid #00bcd4; }

/* ─── Upload ──────────────────────────────────────────────────── */
.upload-section {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.upload-box {
    flex: 1;
    min-width: 280px;
    border: 2px dashed rgba(255,255,255,0.15);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    background: rgba(255,255,255,0.03);
    transition: border-color 0.3s;
}

.upload-box:hover { border-color: #7c5cfc; }

.upload-box h3 { color: #ccc; margin-bottom: 12px; font-size: 15px; }

.mode-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.mode-btn {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05);
    color: #ccc;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.mode-btn.active {
    border-color: #7c5cfc !important;
    background: rgba(124,92,252,0.2) !important;
    color: #fff !important;
}

.mode-btn:not(.active):hover {
    border-color: rgba(255,255,255,0.35) !important;
    color: #fff !important;
}

#current-image-info {
    padding: 10px;
    background: rgba(124,92,252,0.1);
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 12px;
}

#current-image-info p { color: #7c5cfc; margin-bottom: 6px; }
#current-preview {
    max-width: 100%;
    max-height: 150px;
    border-radius: 6px;
    display: block;
    margin: 8px 0;
}

.reset-btn {
    margin-top: 6px;
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.05);
    color: #ccc;
    cursor: pointer;
    font-size: 12px;
}

.reset-btn:hover {
    background: rgba(124,92,252,0.2) !important;
    border-color: #7c5cfc !important;
    color: #fff !important;
}

.upload-area {
    border: 2px dashed rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 24px 16px;
    cursor: pointer;
    transition: background 0.3s;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-area:hover { background: rgba(124,92,252,0.08); }
.upload-area p { color: #888; font-size: 14px; }
.upload-area small { color: #666; }

.preview-container { margin-top: 12px; }
.preview-container img {
    max-width: 100%;
    max-height: 180px;
    border-radius: 8px;
}

/* ─── Inpainting Tools ────────────────────────────────────────── */
#inpaint-tools {
    margin-top: 12px;
}

.inpaint-info {
    padding: 8px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    margin-bottom: 8px;
}

.inpaint-info p { color: #aaa; font-size: 12px; }

.brush-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.brush-controls label { color: #ccc; font-size: 12px; }

.brush-controls input[type="range"] {
    flex: 1;
    min-width: 100px;
}

#brush-size-label {
    color: #7c5cfc;
    font-size: 12px;
    min-width: 30px;
}

.brush-controls button {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.05);
    color: #ccc;
    cursor: pointer;
    font-size: 11px;
}

.canvas-wrapper {
    width: 100%;
    margin-bottom: 8px;
}

#inpaint-canvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
    cursor: crosshair;
    image-rendering: auto;
}

.inpaint-hint {
    color: #888;
    font-size: 11px;
    margin-top: 6px;
}

/* ─── Prompt ──────────────────────────────────────────────────── */
.prompt-section { margin: 24px 0; }
.prompt-section h3 { color: #ccc; margin-bottom: 10px; font-size: 15px; }

textarea {
    width: 100%;
    height: 130px;
    padding: 14px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    resize: vertical;
    font-size: 15px;
    background: rgba(255,255,255,0.06);
    color: #e0e0e0;
    font-family: inherit;
}

textarea::placeholder { color: #666; }
textarea:focus { outline: none; border-color: #7c5cfc; }

/* ─── Prompt History ──────────────────────────────────────────── */
#prompt-history-container {
    margin-top: 12px;
    padding: 12px;
    background: rgba(124,92,252,0.08);
    border-radius: 8px;
    font-size: 13px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-header strong { color: #7c5cfc; }

.history-header button {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255,100,100,0.3);
    background: rgba(255,100,100,0.1);
    color: #ff6b6b;
    cursor: pointer;
    font-size: 11px;
}

#prompt-history-list {
    margin: 0;
    padding-left: 20px;
    color: #aaa;
}

#combined-prompt-display {
    margin-top: 8px;
    padding: 8px;
    background: rgba(0,0,0,0.2);
    border-radius: 6px;
    color: #888;
    font-size: 12px;
    font-style: italic;
}

/* ─── Warning ─────────────────────────────────────────────────── */
.warning {
    background: rgba(255,193,7,0.1);
    border-left: 3px solid #ffc107;
    padding: 14px;
    border-radius: 0 8px 8px 0;
    margin: 20px 0;
    font-size: 13px;
    color: #ccc;
}

/* ─── Submit Button ───────────────────────────────────────────── */
#process-btn {
    background: linear-gradient(135deg, #7c5cfc, #a855f7);
    color: #fff;
    border: none;
    padding: 16px 44px;
    border-radius: 28px;
    cursor: pointer;
    font-size: 17px;
    font-weight: 600;
    display: block;
    margin: 24px auto;
    transition: all 0.25s ease;
    box-shadow: 0 4px 18px rgba(124,92,252,0.4);
}

#process-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(124,92,252,0.55);
}

#process-btn:active { transform: translateY(0); }
#process-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ─── Loading ─────────────────────────────────────────────────── */
.loading {
    display: none;
    text-align: center;
    margin: 24px 0;
}

.spinner {
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: #7c5cfc;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 14px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading p { color: #aaa; font-size: 14px; }

/* ─── Result ──────────────────────────────────────────────────── */
.result-section {
    margin-top: 30px;
    text-align: center;
}

.result-section h3 { color: #ccc; margin-bottom: 14px; }

.result-image {
    max-width: 100%;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
}

#download-link {
    display: inline-block;
    margin-top: 14px;
    color: #7c5cfc;
    text-decoration: none;
    font-weight: 600;
}

#download-link:hover { text-decoration: underline; }

.use-result-btn {
    margin-top: 12px;
    padding: 10px 24px;
    border-radius: 20px;
    border: 2px solid #7c5cfc;
    background: rgba(124,92,252,0.15);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.25s ease;
}

.use-result-btn:hover {
    background: rgba(124,92,252,0.3);
    transform: translateY(-2px);
}

.hidden { display: none; }

/* ─── Examples ────────────────────────────────────────────────── */
.examples {
    margin-top: 40px;
    padding: 24px;
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
}

.examples h3 { color: #ddd; margin-bottom: 16px; }

.example-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.example-item {
    background: rgba(255,255,255,0.05);
    padding: 18px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.06);
    transition: transform 0.2s;
}

.example-item:hover { transform: translateY(-3px); }
.example-item strong { color: #a855f7; display: block; margin-bottom: 8px; font-size: 14px; }
.example-item { font-size: 13px; color: #aaa; line-height: 1.5; }

/* ─── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    .upload-section { flex-direction: column; }
    .container { padding: 15px; border-radius: 0; }
    .engine-btn { padding: 10px 15px; font-size: 13px; }
    h1 { font-size: 22px; }
    textarea { height: 100px; }
    #process-btn { width: 100%; padding: 14px; }
}
