/* Data Prep — pipeline UI styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: #16213e;
    border-bottom: 1px solid #2a2a4a;
}

header h1 {
    font-size: 20px;
    font-weight: 600;
    color: #fff;
}

header nav a {
    color: #8888cc;
    text-decoration: none;
    font-size: 14px;
}
header nav a:hover { color: #aaaaee; }

/* ── Layout ──────────────────────────────────────────────────── */

main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

@media (max-width: 900px) {
    main { grid-template-columns: 1fr; }
}

section {
    background: #16213e;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #2a2a4a;
}

h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #ccc;
}

/* ── Form elements ───────────────────────────────────────────── */

.form-group {
    margin-bottom: 14px;
}

.form-group > label {
    display: block;
    font-size: 13px;
    color: #999;
    margin-bottom: 4px;
}

input[type="text"],
input[type="number"] {
    background: #0f1729;
    border: 1px solid #333;
    color: #e0e0e0;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 14px;
}

input[type="text"] { width: 100%; }
input[type="number"] { width: 80px; }

input:focus {
    outline: none;
    border-color: #5555aa;
}

/* ── Drop zone ───────────────────────────────────────────────── */

#drop-zone {
    border: 2px dashed #444;
    border-radius: 8px;
    padding: 28px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

#drop-zone:hover,
#drop-zone.dragover {
    border-color: #6666bb;
    background: rgba(100, 100, 200, 0.05);
}

#drop-zone input[type="file"] {
    display: none;
}

#drop-zone p {
    color: #888;
    font-size: 14px;
}

.browse-link {
    color: #7777cc;
    text-decoration: underline;
}

#file-info {
    margin-top: 8px;
    padding: 8px 12px;
    background: #0f1729;
    border-radius: 4px;
    font-size: 13px;
    color: #aaa;
}

/* ── Fieldsets ────────────────────────────────────────────────── */

fieldset {
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

legend {
    font-size: 14px;
    font-weight: 500;
    color: #bbb;
    padding: 0 6px;
}

legend label {
    cursor: pointer;
}

.config-row {
    margin-top: 8px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.config-row label {
    font-size: 13px;
    color: #aaa;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.config-row.checkboxes label {
    min-width: 140px;
}

input[type="checkbox"] {
    accent-color: #6666bb;
}

.hint {
    color: #666;
    font-size: 12px;
}

/* ── Estimate box ────────────────────────────────────────────── */

#estimate-box {
    background: #0f1729;
    border-radius: 6px;
    padding: 14px;
    margin-bottom: 14px;
    border: 1px solid #2a2a4a;
}

#estimate-box h3 {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 8px;
}

#estimate-total {
    font-size: 18px;
    font-weight: 600;
    color: #7777cc;
    margin-bottom: 8px;
}

.estimate-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #888;
    padding: 2px 0;
}

/* ── Buttons ─────────────────────────────────────────────────── */

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

button {
    padding: 8px 18px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: #5555aa;
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #6666cc; }

.btn-secondary {
    background: #333;
    color: #ccc;
}
.btn-secondary:hover:not(:disabled) { background: #444; }

.btn-danger {
    background: #883333;
    color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #aa4444; }

/* ── Jobs list ───────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    color: #555;
    padding: 40px 0;
    font-size: 14px;
}

.job-card {
    background: #0f1729;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.2s;
}
.job-card:hover { border-color: #5555aa; }

.job-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.job-name {
    font-weight: 500;
    font-size: 14px;
    color: #ddd;
}

.job-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
    text-transform: uppercase;
}

.status-queued    { background: #444; color: #aaa; }
.status-pending   { background: #444; color: #aaa; }
.status-running   { background: #2a3a6a; color: #7799ee; }
.status-completed { background: #1a3a2a; color: #55bb77; }
.status-failed    { background: #3a1a1a; color: #cc5555; }
.status-cancelled { background: #3a3a1a; color: #bbaa55; }

.job-card-body {
    font-size: 13px;
    color: #888;
}

.mini-progress {
    height: 4px;
    background: #222;
    border-radius: 2px;
    margin: 4px 0;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    background: #5555aa;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.job-progress-text {
    font-size: 12px;
    color: #777;
}

.job-result { color: #55bb77; }
.job-error { color: #cc5555; font-size: 12px; }

.job-time {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #555;
}

/* ── Modal ───────────────────────────────────────────────────── */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden { display: none; }

.modal-content {
    background: #16213e;
    border: 1px solid #2a2a4a;
    border-radius: 10px;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #2a2a4a;
}

.modal-header h3 {
    font-size: 16px;
    color: #ddd;
}

.modal-header button {
    background: none;
    color: #888;
    font-size: 22px;
    padding: 0 4px;
}
.modal-header button:hover { color: #ccc; }

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.status-badge {
    display: inline-block;
    font-size: 13px;
    padding: 3px 12px;
    border-radius: 12px;
    font-weight: 500;
    text-transform: uppercase;
    margin-bottom: 12px;
}

/* Progress bar */
#modal-progress {
    margin-bottom: 16px;
}

#modal-progress-bar {
    height: 8px;
    background: #222;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

#modal-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4444aa, #6666cc);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

#modal-progress-text {
    font-size: 13px;
    color: #888;
}

/* Config summary */
.config-summary {
    background: #0f1729;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

.config-summary div {
    padding: 2px 0;
    color: #999;
}

.config-summary strong {
    color: #bbb;
}

/* Log */
#modal-log-container h4 {
    font-size: 13px;
    color: #888;
    margin-bottom: 6px;
}

#modal-log {
    background: #0a0e1a;
    border: 1px solid #222;
    border-radius: 6px;
    padding: 10px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: #8a8a8a;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

/* ── Queue status ─────────────────────────────────────────────── */

.queue-status {
    font-size: 12px;
    color: #888;
    padding: 4px 10px;
    background: #0f1729;
    border-radius: 10px;
    border: 1px solid #2a2a4a;
}

.queue-status.queue-full {
    border-color: #cc7733;
    color: #cc7733;
}

/* ── Queue position in card ──────────────────────────────────── */

.job-queue-pos {
    color: #aaa;
    font-size: 12px;
}

/* ── Stage timings in card ───────────────────────────────────── */

.job-timings {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

/* ── Stage duration bar (modal) ──────────────────────────────── */

#modal-stage-durations {
    margin-bottom: 12px;
}

.stage-bar {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    background: #222;
    margin-bottom: 6px;
}

.stage-seg {
    transition: width 0.5s ease;
    min-width: 2px;
}

.stage-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    font-size: 11px;
    color: #888;
}

.stage-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stage-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* ── Segmented controls (profile + DPI) ───────────────────────── */

.segmented {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.segmented .seg-btn {
    flex: 1;
    background: #0f1729;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    padding: 8px 12px;
    color: #aaa;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.segmented .seg-btn:hover {
    border-color: #4444aa;
}

.segmented .seg-btn.active {
    background: #2a2a5a;
    border-color: #6666cc;
    color: #fff;
}

.seg-title {
    font-size: 14px;
    font-weight: 600;
}

.seg-desc {
    font-size: 11px;
    color: #777;
}

.segmented .seg-btn.active .seg-desc {
    color: #aabbee;
}

.seg-sub {
    font-size: 10px;
    color: #777;
    margin-left: 4px;
}

.segmented .seg-btn.active .seg-sub {
    color: #aabbee;
}

.dpi-segmented .seg-btn {
    flex-direction: row;
    align-items: baseline;
    padding: 6px 10px;
    font-size: 14px;
    font-weight: 500;
}

#dpi-hint {
    font-size: 11px;
    color: #888;
    margin-left: 6px;
}

/* ── Advanced toggle ─────────────────────────────────────────── */

.link-button {
    background: none;
    border: none;
    color: #7777cc;
    font-size: 13px;
    cursor: pointer;
    padding: 8px 0;
    margin-bottom: 8px;
}

.link-button:hover {
    color: #9999dd;
}

.link-button .chevron {
    display: inline-block;
    margin-right: 4px;
    transition: transform 0.15s;
}

#advanced-options {
    border-top: 1px solid #2a2a4a;
    padding-top: 14px;
    margin-top: 4px;
}

/* ── File info warning ───────────────────────────────────────── */

#file-info.warning {
    border-left: 3px solid #cc7733;
    color: #cc7733;
}

#limits-info {
    margin-top: 6px;
    font-size: 11px;
    color: #666;
}

/* ── Priority indicator ──────────────────────────────────────── */

input[type="password"] {
    background: #0f1729;
    border: 1px solid #333;
    color: #e0e0e0;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
}

input[type="password"]:focus {
    outline: none;
    border-color: #cc9933;
}

.priority-badge {
    color: #ddaa44;
    font-weight: bold;
    margin-right: 2px;
}

.job-card.job-priority {
    border-left: 3px solid #ddaa44;
}

/* ── Estimate badges ─────────────────────────────────────────── */

.estimate-source {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

#modal-estimate-line {
    margin-bottom: 12px;
    font-size: 13px;
    color: #999;
}

.estimate-pill {
    display: inline-block;
    background: #2a2a5a;
    color: #aabbee;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 500;
    margin-right: 6px;
}

.estimate-calib {
    color: #777;
    font-size: 12px;
}

.badge-measured {
    display: inline-block;
    font-size: 10px;
    padding: 0 5px;
    border-radius: 6px;
    background: #1a3a2a;
    color: #55bb77;
    margin-left: 4px;
    vertical-align: middle;
}

.hidden { display: none !important; }
