/* Flux Kontext image editor styles */

body.flux-kontext-page {
    --accent-primary: #1e3a5f;
    --accent-secondary: #2c4a6e;
    --accent-light: rgba(30, 58, 95, 0.18);
    --accent-gradient: linear-gradient(135deg, #1e3a5f 0%, #2c4a6e 50%, #3d5a80 100%);
}

.editor-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-top: 40px;
}

.editor-layout.api-docs-active {
    grid-template-columns: 1fr;
    gap: 0;
}

.editor-layout.api-docs-active .editor-panel {
    min-height: auto;
}

.editor-panel,
.preview-panel {
    min-height: 600px;
}

.editor-panel {
    display: flex;
}

.editor-panel > .side-tabs {
    flex: 1;
}

/* Section styling */
.section-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.section-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 14px;
}

.prompts-section textarea {
    width: 100%;
    min-height: 140px;
    resize: vertical;
    font-size: 15px;
    line-height: 1.55;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.92);
    box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.06);
}

.prompts-section textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
}

section {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

/* Upload area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: var(--bg-tertiary);
}

.upload-area:hover {
    border-color: var(--accent-primary);
    background-color: var(--accent-light);
}

.upload-area.dragover {
    border-color: var(--accent-primary);
    background-color: var(--accent-light);
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.upload-text {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.file-status {
    color: var(--text-muted);
    font-size: 14px;
}

.upload-progress {
    margin-top: 16px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    display: grid;
    gap: 8px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background-color: rgba(148, 163, 184, 0.25);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    border-radius: 999px;
    transition: width 0.2s ease;
}

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

.status-success {
    color: var(--success);
    font-weight: 600;
}

.status-error {
    color: var(--error);
    font-weight: 600;
}

.status-warning {
    color: var(--warning);
    font-weight: 600;
}

/* Image preview */
.image-preview {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview img {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

.s3-url-info {
    background-color: rgba(14, 165, 233, 0.08);
    border-top: 1px solid rgba(14, 165, 233, 0.2);
    padding: 12px 16px;
    font-size: 12px;
    color: var(--text-secondary);
}

.remove-image {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.remove-image:hover {
    background-color: var(--error);
}

/* Slider styling */
.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-container input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background-color: var(--bg-tertiary);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--accent-primary);
    cursor: pointer;
    border: 2px solid var(--bg-primary);
}

.slider-container input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--accent-primary);
    cursor: pointer;
    border: 2px solid var(--bg-primary);
}

.slider-value {
    min-width: 40px;
    text-align: center;
    font-weight: 500;
    color: var(--accent-primary);
}

.advanced-section details {
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 16px 20px;
    cursor: pointer;
}

.advanced-section details summary {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
}

.advanced-section details summary::-webkit-details-marker {
    display: none;
}

.advanced-section details summary::after {
    content: '▼';
    display: inline-block;
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.advanced-section details[open] summary::after {
    transform: rotate(180deg);
}

.summary-hint {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

.advanced-content {
    margin-top: 16px;
    display: grid;
    gap: 20px;
}

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

/* Checkbox styling */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    position: relative;
    transition: all 0.2s ease;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Code block */
.code-block {
    position: relative;
    background: #0f172a;
    border: 1px solid rgba(30, 41, 59, 0.85);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.4);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(148, 163, 184, 0.08);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.code-block pre {
    padding: 22px;
    margin: 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #f1f5f9;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.copy-button {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-button:hover {
    background-color: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* Generate button */
.generate-button {
    width: 100%;
    background-color: var(--accent-primary);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.generate-button:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.generate-button:disabled {
    background-color: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.button-icon {
    font-size: 14px;
}

/* Preview section */
.preview-info {
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-muted);
}

.variant-label {
    background-color: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.preview-subtitle {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
}

.preview-note {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 20px;
}



.preview-container {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
    min-height: 360px;
    display: flex;
    align-items: stretch;
    justify-content: center;
}

#resultImage {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    background: radial-gradient(circle at 50% 0%, rgba(148, 163, 184, 0.18), transparent 65%);
}

.result-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-align: center;
    padding: 48px 32px;
    color: var(--text-muted);
    background: linear-gradient(160deg, rgba(14, 165, 233, 0.12) 0%, rgba(14, 116, 233, 0.08) 60%, rgba(79, 70, 229, 0.05) 100%);
}

.result-placeholder .placeholder-icon {
    font-size: 42px;
}

.placeholder-headline {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.result-placeholder .placeholder-text {
    font-size: 14px;
    max-width: 360px;
    line-height: 1.6;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    gap: 16px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.download-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: var(--success);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.download-button:hover {
    background-color: #22c55e;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Generation time */
.generation-time {
    margin-top: 12px;
    padding: 8px 16px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

.generation-time .time-label {
    font-weight: 500;
    margin-right: 6px;
}

.generation-time .time-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Advanced Settings */
.advanced-section {
    margin-bottom: 24px;
}

.advanced-header {
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}

.advanced-header:hover .fold-icon {
    color: var(--accent-primary);
}

.advanced-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.advanced-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
    opacity: 1;
    margin-top: 16px;
}

.advanced-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.input-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    margin-bottom: 0;
}

/* Metadata */
.metadata-section {
    margin: 20px 0;
}

.metadata-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 12px;
}

.metadata-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.metadata-header:hover .fold-icon {
    color: var(--accent-primary);
}

.fold-icon {
    font-size: 14px;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.metadata-header .fold-icon.collapsed {
    transform: rotate(-90deg);
}

.metadata-status {
    font-size: 12px;
    color: var(--text-muted);
}

.metadata-list {
    list-style: none;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 16px;
}

.metadata-list li {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
}

.metadata-list li:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.metadata-list strong {
    color: var(--text-primary);
}

.metadata-list span {
    color: var(--text-secondary);
}

.metadata-placeholder {
    display: grid;
    place-items: center;
    gap: 12px;
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
}

.placeholder-icon {
    font-size: 28px;
}

.placeholder-text {
    font-size: 14px;
}

/* History */
.history-section {
    margin-top: 20px;
}

.history-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 12px;
}

.clear-history {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    margin-bottom: 16px;
    transition: all 0.2s ease;
}

.clear-history:hover {
    color: var(--error);
    border-color: var(--error);
}

.history-list {
    min-height: 100px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 14px;
    color: var(--text-muted);
}

.history-item {
    padding: 8px;
    border-left: 3px solid var(--accent-primary);
    background-color: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 12px;
}

.history-item:last-child {
    margin-bottom: 0;
}

/* Responsive design for editor */
@media (max-width: 1024px) {
    .editor-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .side-tabs {
        padding: 18px;
    }
}

@media (max-width: 768px) {
    .page-title {
        font-size: 28px;
    }

    .page-description {
        font-size: 15px;
    }

    section {
        padding: 18px;
        margin-bottom: 18px;
    }

    .side-tabs {
        padding: 16px;
        gap: 14px;
    }

    .side-tabs__button {
        font-size: 14px;
        padding: 10px 14px;
    }

    .side-tabs__body {
        padding: 18px 16px;
    }

    .section-title {
        font-size: 18px;
    }

    .section-description {
        font-size: 13px;
    }

    .upload-area {
        padding: 20px;
        min-height: 150px;
    }

    .upload-icon {
        font-size: 32px;
    }

    .upload-text {
        font-size: 15px;
    }

    .upload-hint {
        font-size: 13px;
    }

    .image-preview-container {
        gap: 12px;
    }

    .image-preview {
        max-height: 180px;
    }

    .input-group textarea {
        min-height: 100px;
        font-size: 14px;
    }

    .slider-container {
        gap: 10px;
    }

    .slider-label {
        font-size: 14px;
    }

    .slider-value {
        font-size: 13px;
    }

    .aspect-ratio-buttons {
        flex-wrap: wrap;
        gap: 8px;
    }

    .aspect-button {
        font-size: 13px;
        padding: 8px 14px;
        flex: 1 1 calc(33.333% - 6px);
        min-width: 80px;
    }

    .generate-button {
        padding: 14px 24px;
        font-size: 15px;
        width: 100%;
    }

    .status-message {
        font-size: 14px;
        padding: 12px;
    }

    .preview-container {
        min-height: 250px;
        padding: 16px;
    }

    .generated-image {
        max-height: 400px;
    }

    .image-actions {
        flex-direction: column;
        gap: 10px;
    }

    .download-button, .new-generation-button {
        width: 100%;
        font-size: 14px;
        padding: 12px 20px;
    }

    .code-block pre {
        font-size: 12px;
        padding: 16px;
    }

    .copy-button {
        top: 12px;
        right: 12px;
        padding: 6px 12px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .editor-layout {
        gap: 16px;
    }

    .page-title {
        font-size: 24px;
    }

    .page-description {
        font-size: 14px;
    }

    section {
        padding: 14px;
        margin-bottom: 14px;
    }

    .side-tabs {
        padding: 12px;
        gap: 12px;
    }

    .side-tabs__button {
        font-size: 13px;
        padding: 9px 12px;
    }

    .side-tabs__body {
        padding: 16px 14px;
    }

    .upload-area {
        padding: 18px;
        min-height: 130px;
    }

    .upload-icon {
        font-size: 28px;
    }

    .upload-text {
        font-size: 14px;
    }

    .upload-hint {
        font-size: 12px;
    }

    .aspect-button {
        flex: 1 1 calc(50% - 4px);
        font-size: 12px;
        padding: 8px 10px;
    }

    .slider-container {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .slider-value {
        text-align: left;
    }

    .preview-container {
        min-height: 200px;
    }

    .generated-image {
        max-height: 300px;
    }
}

.params-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.params-table th {
    text-align: left;
    padding: 12px;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    font-weight: 600;
}

.params-table td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.params-table code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 13px;
}

.output-cost-note {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.response-headers {
    background: #f8fafc;
    padding: 16px;
    border-radius: 8px;
    margin-top: 12px;
}

.response-headers ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.response-headers li {
    margin-bottom: 4px;
}

.error-section ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.error-section li {
    margin-bottom: 8px;
}

.api-footer {
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.api-footer p {
    margin: 0 0 8px 0;
}

.api-footer p:last-child {
    margin-bottom: 0;
}

.api-footer a {
    text-decoration: none;
}

.api-footer a:hover {
    text-decoration: underline;
}
