/* TESAIoT Developer Hub — Remote Flash modal.
 * Restyle of tesaiot-landing's flash modal using Developer Hub design tokens
 * (see css/style.css :root). Tablet/desktop only — no mobile (project rule). */

.rf-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 16px;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(3px);
  overflow-y: auto;
  animation: rf-fade 0.16s ease;
}
@keyframes rf-fade { from { opacity: 0; } to { opacity: 1; } }

#remoteFlashModal.hidden { display: none; }

.rf-modal {
  width: 100%;
  max-width: 560px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  font-family: var(--font-sans);
  color: var(--text-primary);
  animation: rf-rise 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
@keyframes rf-rise { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }

/* Header */
.rf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, var(--tesa-primary-subtle), var(--bg-surface));
}
.rf-head-l { display: flex; align-items: center; gap: 9px; }
.rf-head-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--tesa-primary); color: #fff; font-size: 14px;
}
.rf-title { font-weight: 700; font-size: 15px; }
.rf-step { font-size: 11px; color: var(--text-tertiary); margin-left: 4px; }
.rf-close {
  border: none; background: var(--bg-muted); color: var(--text-secondary);
  width: 28px; height: 28px; border-radius: 7px; cursor: pointer; font-size: 13px;
}
.rf-close:hover { background: var(--border-color); color: var(--text-primary); }

.rf-body { padding: 16px; }

/* Onboarding */
.rf-onb-hero { text-align: center; margin-bottom: 16px; }
.rf-onb-ico { font-size: 30px; }
.rf-onb-img {
  width: 64px; height: 64px; border-radius: 16px;
  object-fit: contain; box-shadow: var(--shadow-md);
}
.rf-h2 { font-size: 17px; font-weight: 700; margin: 8px 0 4px; }
.rf-fg { color: var(--tesa-primary); }
.rf-sub { font-size: 13px; color: var(--text-secondary); line-height: 1.5; max-width: 440px; margin: 0 auto; }
.rf-os-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 8px; }
.rf-os-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 10px; border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color); background: var(--bg-surface);
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  text-decoration: none; cursor: pointer; transition: var(--transition);
}
.rf-os-btn:hover { border-color: var(--tesa-primary); color: var(--tesa-primary); }
.rf-os-btn.disabled { opacity: 0.5; cursor: not-allowed; }
.rf-note { font-size: 12px; color: var(--text-tertiary); text-align: center; margin: 6px 0 14px; }
.rf-note a, .rf-sub a { color: var(--tesa-primary); }
.rf-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rf-steps li { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--text-secondary); }
.rf-steps .n {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--tesa-primary-light); color: var(--tesa-primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.rf-foot { margin-top: 16px; display: flex; justify-content: flex-end; }
.rf-go-inline {
  border: none; background: var(--tesa-primary); color: #fff;
  padding: 9px 16px; border-radius: var(--border-radius-sm);
  font-weight: 600; font-size: 13px; cursor: pointer;
}
.rf-go-inline:hover { background: var(--tesa-primary-hover); }

/* Session cards */
.rf-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rf-card { border: 1px solid var(--border-color); border-radius: 10px; padding: 11px 12px; background: var(--bg-muted); }
.rf-card-h { display: flex; align-items: center; justify-content: space-between; }
.rf-card-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); font-weight: 700; }
.rf-new-btn { border: none; background: transparent; color: var(--text-secondary); font-size: 11px; cursor: pointer; }
.rf-new-btn:hover { color: var(--tesa-primary); }
.rf-status { display: flex; align-items: center; gap: 7px; margin-top: 8px; }
.rf-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.rf-dot.ok { background: var(--color-success); box-shadow: 0 0 0 3px rgba(80, 205, 137, 0.18); }
.rf-dot.wait { background: var(--color-warning); box-shadow: 0 0 0 3px rgba(255, 199, 0, 0.18); }
.rf-status-txt { font-size: 12.5px; color: var(--text-primary); }
.rf-code-row { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.rf-code {
  font-family: var(--font-mono); font-size: 16px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--tesa-primary); background: var(--bg-surface);
  border: 1px dashed var(--tesa-primary-light); border-radius: 6px; padding: 4px 10px; flex: 1;
}
.rf-copy { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border-color); background: var(--bg-surface); color: var(--text-secondary); border-radius: 6px; padding: 5px 9px; font-size: 12px; font-weight: 600; cursor: pointer; transition: var(--transition); }
.rf-copy:hover { border-color: var(--tesa-primary); color: var(--tesa-primary); }
.rf-copy.done { border-color: var(--color-success); color: var(--color-success); background: rgba(80, 205, 137, 0.08); }
.rf-copy svg { flex: none; }
.rf-board-status { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: var(--text-secondary); }
.rf-dot.off { background: var(--text-tertiary); box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.15); }
.rf-board-name { font-size: 14px; font-weight: 600; margin-top: 7px; }
.rf-board-name.muted { font-weight: 400; color: var(--text-secondary); }
.rf-board-meta { font-size: 11.5px; color: var(--text-tertiary); margin-top: 3px; }

/* Firmware section */
.rf-sec { margin-top: 16px; }
.rf-sec-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); font-weight: 700; margin: 0 0 8px; }

/* Board picker — compact selectable cards (2-up), shown only when an example
   ships more than one per-board .hex variant. Selected card drives S.target. */
.rf-board-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.rf-board-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px;
  border: 1.5px solid var(--border-color); border-radius: 12px; padding: 12px 10px;
  background: var(--bg-surface); cursor: pointer; font: inherit; color: inherit; text-align: center;
  transition: border-color .12s ease, background .12s ease;
}
.rf-board-card:hover { border-color: var(--tesa-primary-light); }
.rf-board-card.on { border-color: var(--tesa-primary); background: var(--tesa-primary-subtle); }
.rf-board-img { width: 100%; height: 84px; border-radius: 8px; object-fit: contain; background: var(--bg-muted); }
.rf-board-ph { display: inline-flex; align-items: center; justify-content: center; color: var(--text-tertiary); font-weight: 700; font-size: 14px; }
.rf-board-label { font-size: 13px; font-weight: 600; line-height: 1.2; }
.rf-board-check {
  position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--tesa-primary); color: #fff; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
}
.rf-fw {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border-color); border-radius: 12px; padding: 12px;
  background: var(--bg-surface);
}
.rf-fw-loading, .rf-fw-missing { color: var(--text-secondary); font-size: 13px; }
.rf-fw-icowrap { position: relative; flex: none; }
.rf-fw-img { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; background: var(--bg-muted); }
.rf-fw-ico {
  width: 54px; height: 54px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--tesa-primary); color: #fff; font-weight: 700; font-size: 16px;
}
.rf-fw-badge {
  position: absolute; right: -4px; bottom: -4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--tesa-primary); color: #fff; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-surface);
}
.rf-fw-main { min-width: 0; flex: 1; }
.rf-fw-name-row { display: flex; align-items: center; gap: 8px; }
.rf-fw-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rf-fw-ver {
  font-size: 11px; font-weight: 700; color: var(--tesa-primary);
  background: var(--tesa-primary-subtle); border-radius: 5px; padding: 1px 6px; flex: none;
}
.rf-fw-hash { font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary); margin-top: 4px; word-break: break-all; }
.rf-fw-warn { font-size: 11.5px; color: var(--color-warning); margin-top: 5px; }

.rf-mismatch {
  margin-top: 12px; font-size: 12.5px; color: #92400e;
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 11px;
}

/* Action */
.rf-action { margin-top: 16px; }
.rf-go {
  width: 100%; border: none; border-radius: 10px; padding: 13px;
  background: var(--color-success); color: #fff; font-weight: 700; font-size: 14px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: var(--transition);
}
.rf-go:hover:not(:disabled) { background: var(--color-success-hover); }
.rf-go:disabled { background: var(--bg-muted); color: var(--text-tertiary); cursor: not-allowed; }

.rf-progress { border: 1px solid var(--border-color); border-radius: 10px; padding: 13px; background: var(--bg-muted); }
.rf-progress-h { display: flex; align-items: center; gap: 9px; }
.rf-progress-h .lbl { font-size: 13px; font-weight: 600; flex: 1; }
.rf-progress-pct { font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--tesa-primary); }
.rf-progress-sub { font-size: 12px; color: var(--text-secondary); margin: 6px 0 9px; }
.rf-bar { height: 8px; border-radius: 5px; background: var(--border-color); overflow: hidden; margin-top: 9px; }
.rf-bar-fill { height: 100%; background: linear-gradient(90deg, var(--tesa-primary), var(--color-info)); border-radius: 5px; transition: width 0.3s ease; }
.rf-spin { width: 15px; height: 15px; border: 2px solid var(--tesa-primary-light); border-top-color: var(--tesa-primary); border-radius: 50%; animation: rf-rot 0.7s linear infinite; flex: none; }
@keyframes rf-rot { to { transform: rotate(360deg); } }

.rf-result { border-radius: 10px; padding: 13px; }
.rf-result.ok { background: rgba(80, 205, 137, 0.1); border: 1px solid rgba(80, 205, 137, 0.4); }
.rf-result.err { background: rgba(241, 65, 108, 0.08); border: 1px solid rgba(241, 65, 108, 0.35); display: flex; align-items: center; gap: 10px; }
.rf-result-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.rf-result-ico { font-size: 18px; color: var(--color-success); }
.rf-result-ico.err { color: var(--color-danger); }
.rf-result-txt { flex: 1; font-size: 13px; }
.rf-result-actions { display: flex; gap: 8px; margin-top: 11px; }
.rf-btn-ghost { border: 1px solid var(--border-color); background: var(--bg-surface); border-radius: 7px; padding: 7px 13px; font-size: 13px; cursor: pointer; }
.rf-btn-ghost:hover { border-color: var(--tesa-primary); color: var(--tesa-primary); }
.rf-btn-mini { border: none; background: var(--tesa-primary); color: #fff; border-radius: 7px; padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer; }
.rf-btn-mini:hover { background: var(--tesa-primary-hover); }

/* Console */
.rf-console { margin-top: 14px; border-top: 1px solid var(--border-color); padding-top: 10px; }
.rf-console-btn { border: none; background: transparent; color: var(--text-secondary); font-size: 12px; cursor: pointer; font-family: var(--font-mono); }
.rf-caret { font-size: 9px; }
.rf-muted { color: var(--text-tertiary); }
.rf-console-pre {
  margin: 8px 0 0; max-height: 160px; overflow-y: auto;
  background: var(--bg-code); color: var(--text-code);
  border-radius: 8px; padding: 10px; font-family: var(--font-mono); font-size: 11px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}

/* ── Example Explorer card affordance ── */
/* Anchor absolutely-positioned card overlays (flash button + template badge)
 * to the card itself. */
.example-card { position: relative; }
/* A compact labelled pill ("⚡ Flash") reads as an intentional action rather
 * than a lone floating icon — it sits in the top-left corner of the card. */
.rf-card-btn {
  position: absolute; top: 10px; right: 10px; left: auto; z-index: 3;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  border: none; cursor: pointer;
  background: var(--color-success); color: #fff;
  font-family: var(--font-sans); font-size: 11px; font-weight: 700; line-height: 1;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(80, 205, 137, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.rf-card-btn:hover {
  background: var(--color-success-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(80, 205, 137, 0.55);
}

/* When a card has BOTH the ⚡ Flash pill (top-right) and the template
 * download badge (also top-right), nudge the subtle download badge to the
 * top-left so the two don't collide. Only applied on flashable cards. */
.template-badge-icon.tpl-shift-left { left: 8px; right: auto; }

@media (max-width: 767px) {
  .rf-card-btn { display: none; } /* no mobile support */
}
