/* lora-trainer.css — LoRA Trainer page (lora-trainer.html). Reuses common.css theme vars + components
   (#app-header, .btn-*, .toast, #login-gate, #lightbox, .status-dot, .empty-state). */

#trainer-app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.lt-workspace { flex: 1; min-height: 0; display: flex; }
.lt-workspace.hidden { display: none; }

/* ── Jobs ──────────────────────────────────────────────────────────────── */
.lt-sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}
.lt-jobs { display: flex; flex-direction: column; gap: 6px; }
.lt-jobrow {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 8px;
    align-items: center;
    padding: 10px 12px;
    text-align: left;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}
.lt-jobrow:hover { background: var(--bg-hover); }
.lt-jobrow.active { border-color: var(--primary); background: var(--bg-active); }
.lt-jobname { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lt-jobmeta { grid-column: 1 / -1; font-size: 0.78rem; color: var(--text-muted); }

/* ── Status badge ──────────────────────────────────────────────────────── */
.lt-badge {
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    white-space: nowrap;
    background: var(--bg-hover);
    color: var(--text-muted);
}
.lt-badge.lt-training { background: var(--primary); color: #fff; }
.lt-badge.lt-queued, .lt-badge.lt-paused { background: var(--warning); color: #000; }
.lt-badge.lt-finished { background: var(--success); color: #fff; }
.lt-badge.lt-failed { background: var(--error); color: #fff; }

/* ── One job ───────────────────────────────────────────────────────────── */
.lt-main { flex: 1; min-width: 0; overflow-y: auto; padding: 20px; }
#lt-job { display: flex; flex-direction: column; gap: 16px; max-width: 1180px; margin: 0 auto; }
#lt-job.hidden { display: none; }

.lt-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
}
.lt-card.hidden { display: none; }
.lt-card h2 { font-size: 1.05rem; }
.lt-card h3 {
    margin: 20px 0 10px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.lt-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.lt-count { font-weight: 400; color: var(--text-muted); }
.lt-hint { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 10px; }
.lt-hint code, .lt-drop code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--bg-input);
    font-size: 0.8rem;
}

.lt-jobhead { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.lt-grow { flex: 1; min-width: 220px; }
.lt-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lt-actions a.btn-primary { text-decoration: none; display: inline-flex; align-items: center; }
.lt-actions .hidden { display: none; }

/* ── Form ──────────────────────────────────────────────────────────────── */
.lt-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; align-items: end; }
.lt-span2 { grid-column: span 2; }
.lt-span3 { grid-column: span 3; }
.lt-hint.lt-warning { color: var(--warning); }
.lt-span4 { grid-column: 1 / -1; }
.lt-field { display: flex; flex-direction: column; gap: 5px; font-size: 0.8rem; color: var(--text-muted); min-width: 0; }
.lt-field.hidden { display: none; }
.lt-field input[type="number"], .lt-field select, .lt-sample input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition);
}
.lt-field input[type="number"]:focus, .lt-field select:focus, .lt-sample input:focus { border-color: var(--primary); }
.lt-card input:disabled, .lt-card select:disabled, .lt-card textarea:disabled { opacity: 0.6; }
.lt-checks { display: flex; gap: 6px 18px; flex-wrap: wrap; padding: 9px 0; font-size: 0.88rem; color: var(--text); }
.lt-checks label { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; white-space: nowrap; }

.lt-sample {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.lt-sample-head { display: flex; align-items: center; justify-content: space-between; font-size: 0.86rem; }
.lt-sample textarea { padding: 8px 10px; font-size: 0.86rem; resize: vertical; }
.lt-sample-numbers { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.lt-advanced { margin-top: 18px; }
.lt-advanced summary, .lt-log summary { cursor: pointer; font-size: 0.86rem; color: var(--text-muted); user-select: none; }
.lt-advanced textarea { margin-top: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; }

/* ── Progress ──────────────────────────────────────────────────────────── */
.lt-progress { height: 10px; border-radius: 999px; background: var(--bg-input); overflow: hidden; }
.lt-progress-bar { height: 100%; width: 0; background: var(--primary); transition: width 0.6s ease; }
.lt-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 14px; margin-top: 14px; }
.lt-stat { display: flex; flex-direction: column; gap: 2px; font-size: 0.78rem; color: var(--text-muted); }
.lt-stat strong { font-size: 0.95rem; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.lt-error {
    margin-top: 14px;
    padding: 10px 12px;
    border-left: 3px solid var(--error);
    background: var(--bg-input);
    border-radius: var(--radius);
    font-size: 0.88rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.lt-error.hidden { display: none; }
.lt-previews { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.lt-preview-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.lt-preview-tag { width: 130px; flex-shrink: 0; font-size: 0.82rem; color: var(--text-muted); }
.lt-preview-loss { margin-top: 4px; font-size: 0.76rem; color: var(--text); cursor: help; }
.lt-preview-row img {
    height: 180px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: zoom-in;
}
.lt-log { margin-top: 14px; }
.lt-log pre {
    margin-top: 8px;
    max-height: 260px;
    overflow: auto;
    padding: 10px 12px;
    background: var(--bg-input);
    border-radius: var(--radius);
    font-size: 0.78rem;
    white-space: pre-wrap;
}

/* ── Dataset ───────────────────────────────────────────────────────────── */
.lt-drop {
    padding: 22px 18px;
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-muted);
    transition: border-color var(--transition), background var(--transition);
}
.lt-drop.lt-over { border-color: var(--primary); background: var(--bg-hover); }
.lt-drop.lt-disabled { opacity: 0.5; pointer-events: none; }
.lt-upload { margin-top: 12px; font-size: 0.86rem; color: var(--text-muted); }
.lt-upload.hidden { display: none; }
.lt-upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.lt-upload-row .hidden { display: none; }
.lt-upload-failed {
    margin-top: 8px;
    max-height: 140px;
    overflow: auto;
    padding: 8px 10px;
    background: var(--bg-input);
    border-radius: var(--radius);
    font-size: 0.8rem;
    white-space: pre-wrap;
}
.lt-upload-failed.hidden { display: none; }
.lt-tagging { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.lt-tagging .lt-field { min-width: 280px; }
.lt-tagging-now { display: flex; gap: 8px; flex-wrap: wrap; }
.lt-tagging + .lt-hint { margin-top: 8px; }

/* ── The LoRA of one epoch ─────────────────────────────────────────────── */
.lt-epoch-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; width: 100%; margin-bottom: 6px; font-size: 0.82rem; }
.lt-epoch-tools code { padding: 3px 7px; background: var(--bg-input); border-radius: 4px; }
.lt-epoch-tools .btn-secondary { padding: 4px 10px; font-size: 0.8rem; text-decoration: none; }

/* ── Picking from the account's generations ────────────────────────────── */
.lt-gen-content { width: 980px; max-width: 94vw; }
.lt-gen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    max-height: 60vh;
    overflow: auto;
    padding: 2px;
}
.lt-gen-item {
    position: relative;
    padding: 0;
    border: 3px solid transparent;
    border-radius: var(--radius);
    background: var(--bg-input);
    cursor: pointer;
    aspect-ratio: 1;
    overflow: hidden;
}
.lt-gen-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lt-gen-item.selected { border-color: var(--primary); }
.lt-gen-item.present { opacity: 0.35; cursor: default; }
.lt-gen-more { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.lt-gen-more .lt-hint { margin: 0; }

/* ── Using the finished LoRA ───────────────────────────────────────────── */
.lt-use {
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px solid var(--primary);
    border-radius: var(--radius-lg);
    background: var(--bg);
    font-size: 0.9rem;
}
.lt-use.hidden { display: none; }

/* What training costs: the introduction's lines, and the open job's price under its buttons */
.lt-intro { max-width: 620px; text-align: left; }
.lt-intro > p { text-align: center; margin-bottom: 14px; }
.lt-pricing {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg);
    font-size: 0.9rem;
    color: var(--text);
}
.lt-pricing.hidden { display: none; }
.lt-pricing p { margin: 0 0 8px; }
.lt-pricing p:last-child { margin-bottom: 0; }
.lt-price { flex-basis: 100%; font-size: 0.9rem; color: var(--text-muted); }
.lt-price.hidden { display: none; }
.lt-price.lt-price-short { color: var(--danger, #c0392b); }

/* Making a LoRA public */
.lt-publish-content { max-width: 560px; }
.lt-publish-content ul { margin: 10px 0 10px 18px; }
.lt-publish-content li { margin-bottom: 6px; }
.lt-publish-refund { font-weight: 600; }
.lt-check { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0 6px; }
.lt-check input { margin-top: 3px; }
.lt-use h3 { margin: 0 0 6px; }
.lt-use p { margin: 0 0 8px; color: var(--text-muted); }
.lt-use-tag { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lt-use-tag code {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    background: var(--bg-input);
    border-radius: var(--radius);
    font-size: 0.82rem;
    overflow-wrap: anywhere;
    user-select: all;
}
.lt-use ul { margin: 10px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 5px; }
.lt-use li code { padding: 1px 5px; background: var(--bg-input); border-radius: 4px; font-size: 0.82rem; }
.lt-use li.hidden { display: none; }
.lt-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 12px;
    margin-top: 14px;
}
.lt-image {
    position: relative;
    display: flex;
    gap: 10px;
    padding: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.lt-image img {
    width: 110px;
    height: 110px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: var(--radius);
    cursor: zoom-in;
}
.lt-image-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.lt-image-name {
    padding-right: 26px;
    font-size: 0.78rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lt-image-name span { color: var(--text-dim); }
.lt-image textarea { padding: 6px 8px; font-size: 0.8rem; resize: vertical; }
.lt-image-remove { position: absolute; top: 4px; right: 4px; }

@media (max-width: 980px) {
    .lt-workspace { flex-direction: column; }
    .lt-sidebar { width: auto; max-height: 220px; border-right: 0; border-bottom: 1px solid var(--border); }
    .lt-grid, .lt-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .lt-sample-numbers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
