/* views/import.css — the "Add words" screen: paste → check → save. */

.import-page { display: grid; gap: var(--s-5); }
/* Desktop "Type a word": the form and the shelf sit side by side instead of
   stretching one input across the whole page. Other tabs keep the full width
   their table or text preview needs. */
@media (min-width: 1024px) {
  .import-page.is-type { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
  .import-page.is-type > .page-head { grid-column: 1 / -1; }
  .import-page.is-type > .import-main { grid-column: 1; grid-row: 2; }
  .import-page.is-type > .import-side { grid-column: 2; grid-row: 2; }
}
.import-tabs { width: fit-content; max-width: 100%; }
.import-tabs .tab-short { display: none; }
/* Phones: all three ways stay visible — equal columns, short one-line labels. */
@media (max-width: 480px) {
  .import-tabs { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .import-tabs button { white-space: nowrap; padding: 4px 6px; text-align: center; }
  .import-tabs .tab-long { display: none; }
  .import-tabs .tab-short { display: inline; }
}

/* Type a word */
.word-form { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.word-form .is-wide { grid-column: 1 / -1; }

/* Upload files */
.drop {
  display: grid; justify-items: center; gap: var(--s-2); text-align: center; cursor: pointer;
  padding: var(--s-6) var(--s-4); border: 2px dashed var(--line-strong); border-radius: var(--r-lg);
  color: var(--ink-2); transition: border-color var(--fast), background var(--fast);
}
.drop:hover { border-color: var(--brand); background: var(--brand-soft); }
.drop .icon { color: var(--brand); transform: rotate(-90deg); }
.drop b { color: var(--ink); font-size: var(--text-lg); }
.drop code { font-size: .85em; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); }
.file-list { display: grid; gap: var(--s-2); }
.file-row { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; padding: var(--s-2) var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); }
.file-name { display: grid; flex: 1; min-width: 180px; }
.import-step { padding: var(--s-5); display: grid; gap: var(--s-4); }
.import-step h2 { display: flex; align-items: center; gap: var(--s-3); font-size: var(--text-lg); }
.import-step h2 .step-n { width: 30px; height: 30px; font-size: var(--text-sm); background: var(--brand); color: var(--on-brand); }

.import-text {
  width: 100%; min-height: 180px; max-height: 50vh; resize: none; field-sizing: content;
  padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--ink);
  font: 400 .9rem/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace;
  tab-size: 18; white-space: pre; overflow-x: auto;
}
.import-text:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: var(--surface); }

.import-summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.badge.is-bad { background: var(--bad-soft); color: var(--bad); }

.import-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); max-height: 520px; overflow-y: auto; }
.import-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.import-table th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2);
  text-align: start; font-weight: 600; color: var(--ink-2); padding: var(--s-2) var(--s-3); white-space: nowrap;
}
.import-table td { padding: var(--s-2) var(--s-3); border-top: 1px solid var(--line); vertical-align: top; min-width: 90px; }
.import-table td:nth-child(4), .import-table td:nth-child(5) { min-width: 220px; }
.import-table tr.is-bad td { background: color-mix(in srgb, var(--bad-soft) 60%, transparent); }
.row-status { display: inline-block; padding: 2px 8px; border-radius: var(--r-pill); font-size: .72rem; font-weight: 700; white-space: nowrap; }
.row-status.is-ok { background: var(--good-soft); color: var(--good); }
.row-status.is-warn { background: var(--mark-soft); color: var(--on-mark); }
.row-status.is-bad { background: var(--bad-soft); color: var(--bad); }
.row-status.is-dup { background: var(--surface-2); color: var(--ink-2); }
.import-table tr.is-dup td { color: var(--ink-3); }
.row-issues { display: block; margin-top: 2px; font-size: .72rem; color: var(--ink-3); }

.import-done { display: flex; align-items: center; gap: var(--s-2); color: var(--good); font-weight: 600; }
.import-step code { font-size: .85em; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); }

.btn.danger { color: var(--bad); }

/* Type a word: one line, Enter adds it. Details are optional. */
.add-form { display: grid; gap: var(--s-3); }
.add-form .field-xl input { text-align: start; letter-spacing: 0; }
@media (max-width: 640px) {
  .add-form .field-xl input { font-size: 1rem; }
  .add-form .add-line .btn { padding: 0 var(--s-3); }
}
@media (max-width: 374px) {
  .add-form .add-line .btn { width: 46px; padding: 0; }
  .add-form .add-label { display: none; }
}
.add-more { border-top: 1px solid var(--line); padding-top: var(--s-3); }
.add-more > summary {
  display: inline-flex; align-items: center; gap: var(--s-2); min-height: var(--tap);
  cursor: pointer; list-style: none; font-weight: 600; color: var(--ink-2);
}
.add-more > summary::-webkit-details-marker { display: none; }
.add-more > summary .icon { transition: transform var(--fast); }
.add-more[open] > summary .icon { transform: rotate(90deg); }
.add-more .word-form { margin-top: var(--s-3); }

/* Latest words: the shelf under the form, so the screen is never empty. */
.recent-list { list-style: none; padding: 0; display: grid; }
.recent-list li { border-top: 1px solid var(--line); }
.recent-list li:first-child { border-top: 0; }
.recent-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline;
  gap: 1px 12px; min-height: 54px; padding: 9px 2px;
  color: inherit; text-decoration: none;
}
.recent-row:hover .recent-word b { color: var(--brand); }
.recent-word { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.recent-word b { font-weight: 600; min-width: 0; overflow-wrap: break-word; hyphens: auto; }
.recent-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); align-self: center; }
.recent-dot[data-s="learning"] { background: var(--mark); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--on-mark) 28%, transparent); }
.recent-dot[data-s="mastered"] { background: var(--good); }
.recent-ar { color: var(--ink-2); font-size: .98rem; text-align: end; max-width: 42vw; overflow-wrap: anywhere; }
.recent-meta {
  grid-column: 1 / -1; font-size: var(--text-2xs); color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Long words take the full phone row: the Arabic meaning moves under the
   word and the meta line follows, instead of fragmenting both columns. */
@media (max-width: 640px) {
  .recent-row.is-long { grid-template-columns: minmax(0, 1fr); row-gap: 2px; }
  .recent-row.is-long .recent-ar { grid-column: 1; grid-row: 2; max-width: none; text-align: left; }
  .recent-row.is-long .recent-meta { grid-row: 3; }
}

/* Empty library: one quiet explanation of the method instead of dead paper. */
.import-next { padding: var(--s-4) var(--s-5) var(--s-3); }
.import-next h2 { font-size: var(--text-md); }
.import-next-list { list-style: none; padding: 0; display: grid; margin-top: var(--s-2); }
.import-next-list li {
  display: grid; grid-template-columns: 76px minmax(0, 1fr);
  gap: var(--s-3); padding: 10px 0; border-top: 1px solid var(--line);
}
.import-next-when { color: var(--ink-3); font-size: var(--text-xs); font-weight: 700; padding-top: 1px; }
.import-next-list p { color: var(--ink-2); font-size: var(--text-sm); line-height: 1.45; }

#importCheck { scroll-margin-top: calc(var(--bar-h) + var(--s-3)); }

/* Phones: each row becomes a small labelled card instead of a wide table */
@media (max-width: 640px) {
  .import-table-wrap { border: 0; max-height: none; overflow: visible; }
  .import-table thead { display: none; }
  .import-table, .import-table tbody, .import-table tr, .import-table td { display: block; width: 100%; }
  .import-table tr { border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-3); margin-bottom: var(--s-2); background: var(--surface); }
  .import-table tr.is-bad { background: color-mix(in srgb, var(--bad-soft) 60%, var(--surface)); }
  .import-table td { border: 0; padding: 2px 0; min-width: 0; }
  .import-table tr.is-bad td { background: none; }
  .import-table td[data-label]::before { content: attr(data-label) ": "; color: var(--ink-3); font-size: var(--text-xs); font-family: var(--font-body); }
  .import-table td[lang="ar"] { text-align: right; }
  .import-table td[lang="ar"]::before { float: left; }
  .import-table .c-status { margin-bottom: var(--s-1); }
  .import-step { padding: var(--s-4); }
  .import-step .row .btn { flex: 1 1 auto; }
  .word-form { grid-template-columns: 1fr; }
}

/* ── From text: the learner marks words in a paragraph, like a highlighter on paper ── */
.collect-text {
  margin-top: var(--s-3); padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  font-family: var(--font-word); font-size: var(--text-lg); line-height: 2.1; overflow-wrap: anywhere;
}
.tok {
  font: inherit; color: inherit; line-height: inherit; padding: 1px 2px; margin: 0 -2px; border: 0; border-radius: 4px;
  background: transparent; cursor: pointer; transition: background-color var(--fast) var(--ease);
}
.tok:hover { background: var(--surface-2); }
.tok[aria-pressed="true"] { background: var(--mark); color: var(--on-mark); }
.tok.is-known { color: var(--ink-3); text-decoration: underline dotted; text-underline-offset: 4px; }
.tok:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.collect-picked { display: grid; gap: var(--s-3); margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--line); }
.collect-chips { gap: var(--s-2); }
.collect-chip { padding: 4px 10px; border-radius: var(--r-pill); background: var(--mark-soft); color: var(--on-mark); font-weight: 600; }
.collect-chip.is-known { background: var(--surface-2); color: var(--ink-3); text-decoration: line-through; }
.capture-help { margin-top: var(--s-5); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--surface-2); }
.capture-help summary { display: flex; align-items: center; gap: var(--s-2); min-height: var(--tap); cursor: pointer; font-weight: 600; }
.capture-help[open] { display: grid; gap: var(--s-2); }
.capture-help p { font-size: var(--text-sm); color: var(--ink-2); }
.bookmarklet { cursor: grab; }
.collect-input { font-family: var(--font-word); font-size: var(--text-md); line-height: 1.5; }
