/* CalcWorks Transfer: the file-sending app on calcworks.tech/transfer.
   Loaded after the site stylesheet and uses its colours, so it follows the
   site's light and dark modes. */

.page-hero-compact .wrap { padding-top: 52px; padding-bottom: 44px; }
.page-hero-compact h1 { font-size: clamp(2.1rem, 4.6vw, 3.3rem); }

.xfer-section { padding: 48px 0 88px; }
.xfer-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
@media (max-width: 960px) { .xfer-layout { grid-template-columns: minmax(0, 1fr); } }

.xfer svg, .xfer-side svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* The app card, with a gradient edge */
.xfer {
  display: flex; flex-direction: column; gap: 18px; padding: 24px; border-radius: 24px; min-width: 0;
  border: 1px solid transparent;
  background: linear-gradient(var(--bg), var(--bg)) padding-box, var(--grad) border-box;
  box-shadow: var(--shadow), 0 30px 60px -40px rgba(34, 211, 238, .55);
  font-size: .97rem;
}
@media (max-width: 640px) { .xfer { padding: 16px; border-radius: 18px; } }

/* ---------- Pairing code ---------- */
.device { display: flex; align-items: center; min-height: 44px; }
.device-view, .device-edit { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: 100%; }
.device-icon { width: 18px; height: 18px; color: var(--accent); }
.device-label { color: var(--text-muted); }
.device-code {
  font: 700 .95rem/1 var(--mono); letter-spacing: .08em; padding: 7px 12px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px;
}
.device-edit label { font-weight: 700; white-space: nowrap; }
.device-edit input {
  width: 100%; padding: 10px 14px;
  font: 600 1rem/1.3 var(--mono); letter-spacing: .03em; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.device-edit input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(34, 211, 238, .2); }
.device-edit input[aria-invalid="true"] { border-color: #e5484d; box-shadow: 0 0 0 3px rgba(229, 72, 77, .2); }
.field { position: relative; display: flex; flex: 1; min-width: 200px; }
/* Inline validation message, anchored under the code field. */
.field-error {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 5;
  padding: 8px 11px; font-size: .88rem; line-height: 1.4; color: #b42318;
  background: #fff5f5; border: 1px solid #f3c1bf; border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
}
@media (prefers-color-scheme: dark) { .field-error { background: #2a1214; border-color: #6b2a2d; color: #ffb4b0; } }
.link-button { padding: 0; font: inherit; font-weight: 600; color: var(--link); background: none; border: 0; cursor: pointer; }
.link-button:hover { text-decoration: underline; }

.xfer-help { margin: 0; color: var(--text-muted); }

/* ---------- Drop zone ---------- */
.dropzone {
  display: flex; align-items: center; gap: 18px; padding: 26px;
  border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 18px;
  background: var(--grad-soft); cursor: pointer; transition: background .15s, border-color .15s, transform .15s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.dragging { border-style: solid; border-color: var(--cyan); transform: scale(1.01); box-shadow: 0 0 0 6px rgba(34, 211, 238, .15); }
.dropzone.disabled { opacity: .55; cursor: not-allowed; }
.dropzone .dropzone-icon { width: 46px; height: 46px; padding: 10px; border-radius: 14px; background: var(--grad); color: #04140f; stroke-width: 1.8; }
.dropzone-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.dropzone-text strong { font-size: 1.08rem; }
.dropzone-text span { color: var(--text-muted); font-size: .93rem; }
.dropzone .btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- File list ---------- */
.xfer-files { display: flex; flex-direction: column; gap: 10px; }
.xfer-files-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.xfer-files-head h2 { font-size: 1.1rem; margin: 0; letter-spacing: -.01em; }
.tool-buttons { display: flex; gap: 6px; }
.tool {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  color: var(--text); font: 600 .88rem/1 var(--font); cursor: pointer; transition: border-color .15s, background .15s;
}
.tool svg { width: 17px; height: 17px; color: var(--accent); }
.tool:hover:not(:disabled) { border-color: var(--accent); background: var(--bg-soft); }
.tool:disabled { color: var(--text-muted); opacity: .55; cursor: default; }
.tool:disabled svg { color: inherit; }

.table-wrap { border: 1px solid var(--line); border-radius: 14px; overflow: auto; min-height: 150px; max-height: 420px; background: var(--bg); }
table.explorer { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .93rem; }
.explorer th {
  position: sticky; top: 0; z-index: 1;
  padding: 9px 12px; text-align: left; font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); background: var(--bg-soft); border-bottom: 1px solid var(--line);
}
.col-type { width: 96px; }
.col-size { width: 90px; }
.col-status { width: 32%; }
.explorer th.col-size, .explorer td.col-size { text-align: right; }
.explorer td {
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.explorer tbody tr:last-child td { border-bottom: 0; }
.explorer tbody tr.file-row { cursor: default; user-select: none; }
.explorer tbody tr.file-row:hover td { background: var(--bg-soft); }
.explorer tbody tr.selected td { background: color-mix(in srgb, var(--cyan) 14%, var(--bg)); }
.explorer:focus-within tbody tr.selected td,
.explorer:focus tbody tr.selected td { background: color-mix(in srgb, var(--cyan) 26%, var(--bg)); }
.explorer:focus { outline: none; }
.table-wrap:has(.explorer:focus-visible) { outline: 3px solid var(--cyan); outline-offset: 2px; }
.explorer td.col-size { font-variant-numeric: tabular-nums; color: var(--text-muted); }

.name-cell { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
.name-cell svg { width: 18px; height: 18px; color: var(--accent); }
.name-cell span { overflow: hidden; text-overflow: ellipsis; }

.status { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; font-weight: 600; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; background: currentColor; }
.status-waiting { color: #0891b2; }
.status-waiting::before { animation: pulse 1.6s ease-in-out infinite; box-shadow: 0 0 8px currentColor; }
.status-uploading { color: var(--text-muted); }
.status-failed { color: #d92d20; }
@media (prefers-color-scheme: dark) { .status-waiting { color: #67e8f9; } .status-failed { color: #ff8a80; } }
.status span { overflow: hidden; text-overflow: ellipsis; }
@keyframes pulse { 50% { opacity: .3; } }

.empty-row td { padding: 36px 16px; text-align: center; color: var(--text-muted); white-space: normal; background: none !important; }

.statusbar { display: flex; justify-content: space-between; gap: 16px; font-size: .86rem; color: var(--text-muted); padding: 0 4px; }
.statusbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.statusbar .error { color: #d92d20; }
@media (prefers-color-scheme: dark) { .statusbar .error { color: #ff8a80; } }

/* ---------- Side panel ---------- */
.xfer-side { position: sticky; top: 88px; padding: 24px; border-radius: 20px; background: var(--bg-soft); border: 1px solid var(--line); font-size: .95rem; }
.xfer-side h2 { font-size: 1.15rem; }
.xfer-steps { list-style: none; counter-reset: st; padding: 0; margin: 0 0 18px; display: grid; gap: 14px; }
.xfer-steps li { position: relative; padding-left: 40px; color: var(--text-muted); }
.xfer-steps li b { color: var(--text); }
.xfer-steps li::before { counter-increment: st; content: counter(st); position: absolute; left: 0; top: -.05em; width: 28px; height: 28px;
  border-radius: 9px; display: grid; place-items: center; background: var(--grad); color: #04140f; font-weight: 800; font-size: .85rem; }
.xfer-facts { margin: 0 0 16px; padding-left: 1.1em; color: var(--text-muted); font-size: .9rem; }
.xfer-facts li { margin: 6px 0; }
.xfer-side p { margin: 0; font-weight: 600; }
@media (max-width: 960px) { .xfer-side { position: static; } }

/* ---------- Narrow screens ---------- */
@media (max-width: 640px) {
  .device-edit label { flex-basis: 100%; }
  .device-edit .btn { flex: 1; }
  .dropzone { flex-wrap: wrap; justify-content: center; text-align: center; padding: 20px; }
  .dropzone-text { flex-basis: 100%; }
  .col-type { width: 70px; }
  .col-size { width: 70px; }
  .col-status { width: 34%; }
  .explorer th, .explorer td { padding-left: 8px; padding-right: 8px; }
  .tool span { display: none; }
  .tool { padding: 8px 10px; }
}
@media (max-width: 420px) {
  /* Collapse (not remove) the Type column so colspan rows still line up. */
  .explorer .col-type { width: 0; padding: 0; font-size: 0; border: 0; }
}
