/* ============================================================
   Wycena Web — App layout overrides
   Bazuje na tokens.css + components.css. Tu wpisujemy tylko
   to, co specyficzne dla naszego use-case (nie design system
   universal — Wycena nie ma 3D viewport z sidebar+panel).
   ============================================================ */

/* ---------- User font-size scaling (9–24 pt, base 13 pt) ----------
   --font-scale to mnożnik ustawiany przez JS z localStorage.
   Redeklarujemy --fs-* tokens jako scaled — działa bo app.css
   ładuje się po tokens.css (specyficzność = same, kolejność wygrywa). */
:root {
  --font-scale: 1;

  --fs-11: calc(11px * var(--font-scale));
  --fs-12: calc(12px * var(--font-scale));
  --fs-13: calc(13px * var(--font-scale));
  --fs-14: calc(14px * var(--font-scale));
  --fs-15: calc(15px * var(--font-scale));
  --fs-16: calc(16px * var(--font-scale));
  --fs-18: calc(18px * var(--font-scale));
  --fs-20: calc(20px * var(--font-scale));
  --fs-24: calc(24px * var(--font-scale));
  --fs-32: calc(32px * var(--font-scale));
  --fs-44: calc(44px * var(--font-scale));
}

/* Font controls w toolbar */
.font-controls {
  display: inline-flex;
  background: var(--c-surface-1);
  border: 1px solid var(--c-surface-3);
  border-radius: var(--r-md);
  overflow: hidden;
}
.font-controls button {
  background: transparent; border: none; color: var(--c-text-muted);
  font: inherit; font-weight: var(--fw-medium);
  padding: 0 var(--s-2); height: 32px; min-width: 32px;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  white-space: nowrap;
}
.font-controls button:hover { background: var(--c-surface-2); color: var(--c-text); }
.font-controls button:not(:last-child) { border-right: 1px solid var(--c-surface-3); }
.font-controls button[aria-label="A+"] { font-size: 14px; }
.font-controls button[aria-label="A"]  { font-size: 13px; }
.font-controls button[aria-label="A-"] { font-size: 11px; }

/* ---------- Page wrappers ---------- */
.page {
  max-width: var(--layout-max);
  margin: 0 auto;
  padding: var(--s-5) var(--s-5) var(--s-12);
}
.page--narrow { max-width: 760px; }
.page--auth   { max-width: 420px; padding-top: var(--s-12); }

/* ---------- Toolbar (top navigation bar) ---------- */
.toolbar { position: sticky; top: 0; z-index: var(--z-sticky); }
.toolbar__brand-link {
  color: inherit; text-decoration: none;
  display: inline-flex; align-items: center; gap: var(--s-3);
}
.toolbar__nav {
  display: flex; align-items: center; gap: var(--s-2);
  margin-left: var(--s-5);
}
.toolbar__nav a {
  color: var(--c-text-muted);
  text-decoration: none;
  padding: 6px var(--s-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-13); font-weight: var(--fw-medium);
  transition: color var(--dur-fast), background var(--dur-fast);
}
.toolbar__nav a:hover   { color: var(--c-text); background: var(--c-surface-2); }
.toolbar__nav a.is-active { color: var(--c-text); background: var(--c-surface-2); }
@media (max-width: 767px) {
  .toolbar__nav { gap: 0; margin-left: var(--s-2); flex: 1; overflow-x: auto; }
  .toolbar__nav a { padding: 6px var(--s-2); font-size: var(--fs-12); }
}

.toolbar__lang {
  appearance: none; -webkit-appearance: none;
  background: var(--c-surface-1); color: var(--c-text);
  border: 1px solid var(--c-surface-3); border-radius: var(--r-md);
  padding: 0 28px 0 var(--s-3); height: 32px;
  font-size: var(--fs-12); font-weight: var(--fw-medium);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%238b949e' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 5 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.icon { width: 16px; height: 16px; stroke-width: 1.75; flex-shrink: 0; }
.icon--lg { width: 20px; height: 20px; }
.icon--brand-mark { width: 18px; height: 18px; color: #fff; }

/* ---------- Brand colors ---------- */
.brand__mark { color: #fff; }

/* ---------- Headings on pages ---------- */
.page-header   { margin-bottom: var(--s-5); }
.page-header h1, .page-header .t-h1 { margin-bottom: var(--s-1); }
.page-header__meta { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }

/* ---------- Flash banners ---------- */
.flash {
  margin-bottom: var(--s-4);
}

/* ---------- Forms layout helpers ---------- */
.form-actions {
  display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap;
  margin-top: var(--s-4);
}
.form-actions__hint { color: var(--c-text-subtle); font-size: var(--fs-12); margin-left: auto; }

/* ---------- Field group hint (clientes autocomplete) ---------- */
.field__meta { font-size: var(--fs-11); color: var(--c-text-muted); display: block; min-height: 1.2em; margin-top: var(--s-1); }

/* ---------- Dropzone (upload) ---------- */
.dropzone {
  border: 2px dashed var(--c-surface-3);
  background: var(--c-surface-1);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.dropzone:hover, .dropzone.is-over {
  border-color: var(--c-blue-500);
  background: rgba(31,111,235,.08);
}
.dropzone__label { color: var(--c-text-link); text-decoration: underline; cursor: pointer; }
.dropzone__hint  { color: var(--c-text-subtle); font-size: var(--fs-11); margin-top: var(--s-2); }
.upload-feedback {
  margin-top: var(--s-3); min-height: 1.5em; font-size: var(--fs-12);
}

/* ---------- File list (uploads) ---------- */
.file-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
}
.file-row + .file-row { border-top: 1px solid var(--c-surface-2); }
.file-row__name { flex: 1; font-size: var(--fs-13); }
.file-row__meta { font-size: var(--fs-11); color: var(--c-text-muted); }

/* ---------- Save-status indicator ---------- */
.save-status {
  display: inline-block; margin-left: var(--s-3); font-size: var(--fs-12);
  min-width: 7rem; color: var(--c-text-muted);
}
.save-status.is-saving { color: var(--c-text-muted); }
.save-status.is-saved  { color: var(--c-green-400); }
.save-status.is-error  { color: var(--c-red-400); }

/* ---------- Table: inline editable inputs ---------- */
.table .input,
.table .input-group,
.table select {
  height: 28px; padding: 0 var(--s-2); font-size: var(--fs-12);
}
.table .input.input--right { text-align: right; }
.table select {
  appearance: none; -webkit-appearance: none;
  background: var(--c-surface-1); color: var(--c-text);
  border: 1px solid var(--c-surface-3); border-radius: var(--r-md);
}
.table__actions form { display: inline; margin: 0; }

/* ---------- Wizard buttons grid ---------- */
.wizard-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-3);
}
.wizard-grid > * { width: 100%; }
@media (max-width: 767px) {
  .wizard-grid { grid-template-columns: 1fr; }
}

/* ---------- Stat / KV list ---------- */
.kv {
  display: grid; grid-template-columns: minmax(0, 240px) 1fr; gap: var(--s-2) var(--s-4);
  font-size: var(--fs-13);
}
.kv dt { color: var(--c-text-muted); font-size: var(--fs-11); text-transform: uppercase; letter-spacing: .04em; font-weight: var(--fw-semibold); align-self: center; }
.kv dd { margin: 0; color: var(--c-text); font-variant-numeric: tabular-nums; }

/* ---------- Method picker (home landing) ---------- */
.method-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-4);
}
@media (max-width: 1023px) {
  .method-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 767px) {
  .method-grid { grid-template-columns: 1fr; }
}
.method-card {
  display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-5);
  background: var(--c-surface-1);
  border: 1px solid var(--c-surface-3);
  border-radius: var(--r-xl);
  text-decoration: none; color: inherit;
  transition: border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast);
  min-height: 240px;
}
.method-card--active:hover {
  border-color: var(--c-blue-500);
  background: var(--c-surface-2);
  transform: translateY(-2px);
}
.method-card--active:active { transform: translateY(0); }
.method-card--disabled {
  opacity: .55;
  cursor: not-allowed;
  background: var(--c-surface-0);
}
.method-card__icon {
  width: 56px; height: 56px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-lg);
  background: rgba(31,111,235,.12);
  color: var(--c-blue-400);
  flex-shrink: 0;
}
.method-card--disabled .method-card__icon {
  background: var(--c-surface-2);
  color: var(--c-text-subtle);
}
.method-card__body {
  display: flex; flex-direction: column; gap: var(--s-3);
  flex: 1;
}
.method-card__head-row {
  display: flex; align-items: center; gap: var(--s-2); justify-content: space-between;
}
.method-card__title {
  font-size: var(--fs-18); font-weight: var(--fw-semibold);
  line-height: var(--lh-snug); margin: 0;
}
.method-card__desc {
  color: var(--c-text-muted); font-size: var(--fs-13);
  line-height: var(--lh-base); flex: 1;
}
.method-card__cta {
  display: inline-flex; align-items: center; gap: var(--s-1);
  color: var(--c-text-link); font-weight: var(--fw-medium); font-size: var(--fs-13);
  margin-top: auto;
}
.method-card--active:hover .method-card__cta { color: var(--c-text-link-2); }

/* ---------- AnalysisLogger panel (procedura 2.1) ---------- */
.log-panel {
  background: var(--c-surface-0);
  border: 1px solid var(--c-surface-3);
  border-radius: var(--r-md);
  padding: var(--s-3);
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  max-height: 360px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: var(--lh-snug);
}
.log-panel:empty::before {
  content: attr(data-empty);
  color: var(--c-text-subtle);
  font-style: italic;
}
.log-entry {
  padding: 1px 0;
}
.log-entry__ts {
  color: var(--c-text-subtle);
  margin-right: var(--s-2);
}
.log-entry--PHASE   { color: var(--c-blue-400); font-weight: var(--fw-semibold); padding-top: var(--s-2); }
.log-entry--INFO    { color: var(--c-text); }
.log-entry--SUCCESS { color: var(--c-green-400); }
.log-entry--WARNING { color: var(--c-yellow-500); }
.log-entry--ERROR   { color: var(--c-red-400); }
.log-controls { display: flex; gap: var(--s-2); align-items: center; margin-bottom: var(--s-2); }
.log-controls .log-status { color: var(--c-text-muted); font-size: var(--fs-11); margin-left: auto; }
.log-controls .log-status.is-connected { color: var(--c-green-400); }
.log-controls .log-status.is-disconnected { color: var(--c-yellow-500); }

/* ---------- Thumbnails (procedura 2.8) ---------- */
.thumb-cell {
  display: block;
  width: 64px; height: 48px;
  object-fit: contain;
  background: var(--c-surface-0);
  border: 1px solid var(--c-surface-3);
  border-radius: var(--r-xs);
}
.thumb-cell:hover {
  transform: scale(2);
  transform-origin: left center;
  z-index: 10;
  position: relative;
  box-shadow: var(--elev-pop);
}

/* ---------- Row selection (procedura 2.17) ---------- */
tbody tr.is-selected {
  background: rgba(31,111,235,.10);
  box-shadow: inset 3px 0 0 var(--c-blue-500);
}

/* ---------- Context menu (CRUD detali) ---------- */
.ctx-menu {
  position: fixed; z-index: var(--z-overlay);
  background: var(--c-surface-1); border: 1px solid var(--c-surface-3);
  border-radius: var(--r-md); box-shadow: var(--elev-pop);
  padding: 4px 0; min-width: 160px;
  display: none;
}
.ctx-menu button {
  display: block; width: 100%; text-align: left;
  background: transparent; border: none; color: var(--c-text);
  padding: var(--s-2) var(--s-3); font-size: var(--fs-13); cursor: pointer;
}
.ctx-menu button:hover { background: var(--c-surface-2); }
