/* RunwayRobot – Web UI Styles */

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

:root {
  --bg:        #f5f5f7;
  --surface:   #ffffff;
  --border:    #d2d2d7;
  --border-lt: #e8e8ed;
  --text:      #1d1d1f;
  --text-2:    #515154;
  --text-3:    #86868b;
  --blue:      #0066cc;
  --green:     #1a8d36;
  --red:       #d32f2f;
  --amber:     #856404;
  --radius:    10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.07);
}

.login-logo { font-size: 42px; margin-bottom: 8px; }

.login-box h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }

.login-sub { color: var(--text-3); font-size: 14px; margin-bottom: 28px; }

.login-box input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  margin-bottom: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-box input[type="password"]:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,102,204,0.15);
}

.login-error {
  background: #fff0f0;
  border: 1px solid #ffcccc;
  border-radius: 8px;
  color: var(--red);
  font-size: 13px;
  padding: 8px 12px;
  margin-bottom: 10px;
  text-align: left;
}

/* ── Header ────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 { font-size: 18px; font-weight: 700; }

.header-right { display: flex; align-items: center; gap: 12px; }

/* ── Status bar ────────────────────────────────────────────────────────── */
.status-bar {
  display: flex;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  gap: 24px;
  overflow-x: auto;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 13px;
}

.s-label {
  color: var(--text-3);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ── Badge ─────────────────────────────────────────────────────────────── */
.badge { font-size: 12px; padding: 4px 12px; border-radius: 12px; font-weight: 600; }
.badge.connected    { background: #d4f5dd; color: #1a7a32; }
.badge.disconnected { background: #fdd;    color: var(--red); }

.explore-badge { font-size: 12px; font-weight: 600; }
.explore-badge.available { color: #1a7a32; }
.explore-badge.busy      { color: var(--amber); }

.queue-status-badge { font-size: 12px; font-weight: 600; }
.queue-status-badge.running { color: #1a7a32; }
.queue-status-badge.paused  { color: var(--text-3); }

.queue-activity {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}

/* ── Info box ──────────────────────────────────────────────────────────── */
.info-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
}
.info-box a { color: var(--blue); text-decoration: underline; }

/* ── Main layout ─────────────────────────────────────────────────────────*/
main { padding: 20px 24px 40px; max-width: 1200px; margin: 0 auto; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

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

.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

section {}

h2 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
}

/* ── Template config form ──────────────────────────────────────────────── */
.template-config {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.tpl-cfg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.tpl-cfg-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tpl-source-badge {
  font-size: 11px;
  color: var(--green);
  background: #e9f7ec;
  border-radius: 4px;
  padding: 1px 6px;
}

.tpl-cfg-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.tpl-cfg-grid label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--text-3);
  font-weight: 600;
}

.tpl-cfg-grid select {
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}

.tpl-cfg-grid select:focus {
  border-color: var(--blue);
}

.tpl-cfg-audio {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tpl-cfg-audio input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 4px;
  cursor: pointer;
}

.tpl-save-status {
  font-size: 12px;
  color: var(--green);
  margin-left: 8px;
}

/* ── Template info (legacy, kept for compat) ───────────────────────────── */
.template-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 10px;
  font-size: 13px;
}
.template-info .label { color: var(--text-3); font-weight: 600; }
.template-info .sep   { color: var(--border); }

/* ── Textarea ──────────────────────────────────────────────────────────── */
textarea {
  width: 100%;
  min-height: 110px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,102,204,0.15);
}
textarea::placeholder { color: #a1a1a6; }

/* ── Image mode row ────────────────────────────────────────────────────── */
.image-mode-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.image-mode-row label { font-size: 12px; color: var(--text-3); font-weight: 600; }
.image-mode-row select {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}
.image-mode-row select:focus { border-color: var(--blue); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover  { filter: brightness(1.05); transform: translateY(-0.5px); }
.btn:active { filter: brightness(0.95); transform: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.full    { width: 100%; margin-top: 10px; }
.btn.sm      { padding: 6px 14px; font-size: 12px; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.success { background: var(--green); color: #fff; }
.btn.danger  { background: var(--red); color: #fff; }
.btn.ghost   { background: var(--surface); color: var(--text-2); border: 1px solid var(--border); }
.btn.ghost:hover { background: #f0f0f2; border-color: #b0b0b6; }

/* ── Controls row ──────────────────────────────────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.controls .spacer { flex: 1; }

/* ── Count chip ────────────────────────────────────────────────────────── */
.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  background: #e9e9ed;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 700;
  padding: 0 7px;
  color: var(--text-2);
  margin-left: 6px;
  vertical-align: middle;
}

/* ── Task list ─────────────────────────────────────────────────────────── */
.task-list { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

/* Show-all / show-less row */
.show-all-row {
  display: flex;
  justify-content: center;
  padding: 8px 0 2px;
}
.show-all-btn {
  font-size: 12px;
  color: var(--blue);
}

.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  min-height: 44px;
  min-width: 0;
  width: 100%;
}

.task-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: #eaf6ee;
}
.task-progress-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--green);
  transition: width 0.4s ease;
}

/* Status dot */
.dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.dot.active    { background: var(--blue);  box-shadow: 0 0 0 2px rgba(0,102,204,0.25); animation: pulse 1.5s infinite; }
.dot.queued    { background: var(--text-3); }
.dot.completed { background: var(--green); }
.dot.failed    { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.prompt {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.meta  { font-size: 11px; color: var(--text-3); white-space: nowrap; margin-left: auto; }
.error { font-size: 11px; color: var(--red);     white-space: nowrap; margin-left: auto; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

.actions { display: flex; gap: 4px; margin-left: 4px; }
.actions button, .retry-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-2);
  cursor: pointer;
  font-size: 13px;
  padding: 3px 8px;
  transition: all 0.12s;
}
.actions button:hover, .retry-btn:hover { background: #f0f0f2; border-color: #b0b0b6; }

.reuse-btn { color: var(--blue) !important; border-color: #cce0f5 !important; }
.reuse-btn:hover { background: #eaf3fc !important; border-color: var(--blue) !important; }

.task-thumbs { display: flex; gap: 3px; }
.task-thumb  { width: 28px; height: 28px; border-radius: 4px; object-fit: cover; }

.empty { color: var(--text-3); font-size: 13px; padding: 10px 0; }

/* ── Image grid ────────────────────────────────────────────────────────── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.image-grid-empty {
  font-size: 12px;
  color: var(--text-3);
  padding: 12px 0;
  margin-bottom: 10px;
}

.image-card {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
  aspect-ratio: 1;
  background: var(--border-lt);
}
.image-card img       { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-card.selected  { border-color: var(--blue); }
.image-card .check-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  background: var(--blue);
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}
.image-card.selected .check-badge { display: flex; }
.remove-img {
  position: absolute;
  bottom: 3px;
  right: 3px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  cursor: pointer;
  font-size: 10px;
  display: none;
  align-items: center;
  justify-content: center;
}
.image-card:hover .remove-img { display: flex; }

.image-add-row { display: flex; gap: 8px; }
.image-add-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}
.image-add-row input:focus { border-color: var(--blue); }

.image-hint { font-size: 12px; color: var(--text-3); margin-top: 8px; line-height: 1.5; }

/* ── Log list ──────────────────────────────────────────────────────────── */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  max-height: 300px;
  overflow-y: auto;
}
.log-entry { font-size: 12px; color: var(--text-2); padding: 3px 0; border-bottom: 1px solid var(--border-lt); font-family: monospace; }
.log-entry:last-child { border-bottom: none; }
.log-time  { color: var(--text-3); margin-right: 8px; }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-box {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  max-width: 90vw;
  max-height: 90vh;
}
.modal-box video { display: block; max-width: 90vw; max-height: 85vh; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.modal-close:hover { background: rgba(0,0,0,0.9); }
