@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Raleway:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #EC5C39;
    --primary-dark: #d44e2e;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --bg: #F4F4F3;
    --surface: #ffffff;
    --surface-light: #f8f8f7;
    --text: #12141a;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Raleway', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-family: 'Space Grotesk', system-ui, sans-serif;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: var(--surface);
    color: var(--text);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text);
    font-size: 1rem;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.radio-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    font-size: 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 0.5rem;
    cursor: pointer;
    margin-left: 0.5rem;
}

.btn-secondary:hover {
    background: var(--surface-light);
}

.result {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: 0.5rem;
}

.result.hidden {
    display: none;
}

.result h3 {
    margin-bottom: 1rem;
}

.job-info {
    font-family: inherit;
}

/* Job Status Display Styles */
.job-status-display {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.job-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.job-id {
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-muted);
    word-break: break-all;
}

.job-status-badge {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    text-transform: capitalize;
}

.progress-section {
    background: var(--bg);
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.progress-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.progress-percent {
    font-weight: 600;
    font-size: 0.95rem;
}

.progress-bar-large {
    width: 100%;
    height: 12px;
    background: var(--surface-light);
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.3s ease, background 0.3s ease;
}

.job-meta {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.job-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: 0.5rem;
    padding: 1rem;
    color: var(--error);
}

/* Outputs Section */
.outputs-section {
    margin-top: 1rem;
}

.outputs-section h4 {
    margin-bottom: 1rem;
    color: var(--text);
}

.no-outputs {
    color: var(--text-muted);
    font-style: italic;
}

.output-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.output-preview {
    margin-bottom: 1rem;
    border-radius: 0.375rem;
    overflow: hidden;
    background: var(--surface);
}

.output-preview img {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    display: block;
}

.output-preview video {
    width: 100%;
    max-height: 400px;
    display: block;
}

.output-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.output-info {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.output-info span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.output-dim {
    font-family: monospace;
}

.output-format {
    background: var(--surface-light);
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
}

.output-size {
    color: var(--text);
}

.output-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-view,
.btn-download {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-view {
    background: var(--primary);
    color: white;
}

.btn-view:hover {
    background: var(--primary-dark);
}

.btn-download {
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-download:hover {
    background: var(--border);
}

/* Job Modal */
.job-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.job-modal-content {
    background: var(--surface);
    border-radius: 0.75rem;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.job-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.job-modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.job-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

/* Job Queue Table */
#jobs-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

#jobs-table th,
#jobs-table td {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

#jobs-table th {
    color: var(--text-muted);
    font-weight: 500;
}

#jobs-table button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.4rem 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.85rem;
}

#jobs-table button:hover {
    background: var(--primary-dark);
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-queued { background: var(--secondary); }
.status-processing { background: var(--warning); }
.status-completed { background: var(--success); }
.status-failed { background: var(--error); }

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--surface-light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

/* Poll Controls */
.poll-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.poll-controls button {
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.poll-controls button:hover {
    background: var(--border);
}

.poll-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Raw JSON View */
.raw-json {
    margin-top: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
}

.raw-json summary {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
    user-select: none;
}

.raw-json summary:hover {
    background: var(--surface);
}

.raw-json pre {
    padding: 1rem;
    margin: 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    background: #0a0f1c;
    color: var(--text);
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

footer {
    margin-top: 3rem;
    text-align: center;
    color: var(--text-muted);
}

footer a {
    color: var(--primary);
    text-decoration: none;
}

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

@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    .tab-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .job-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .output-details {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .output-info {
        width: 100%;
    }
    
    .output-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .job-modal-content {
        max-height: 95vh;
    }
}

.poll-controls {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}

.raw-json {
    margin-top: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 12px;
}

.raw-json pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12px;
    user-select: text;
}

.raw-json-actions {
    margin: 6px 0 8px 0;
}

/* Checkbox Group Styles */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text);
    font-size: 0.95rem;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.checkbox-label span {
    color: var(--text);
}
