/* Template picker (views/template-picker.js, docs/SPEC_TEMPLATES.md §2) — prefix .tpl- */

.tpl-modal.modal { max-width: 720px; }
.tpl-modal .modal-body { padding-top: 0; padding-bottom: 0; }
.tpl { display: flex; flex-direction: column; min-width: 0; }
.tpl-top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 0 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tpl-search { width: 100%; }
.tpl-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  padding-bottom: 2px;
  min-width: 0;
}
.tpl-chip { flex: 0 0 auto; white-space: nowrap; }
.tpl-chip-n { margin-left: 6px; font-size: 12px; color: var(--text-3, var(--text-2)); font-variant-numeric: tabular-nums; }
.tpl-intro, .tpl-count { margin: 0; font-size: 13px; color: var(--text-2); }
.tpl-list { display: flex; flex-direction: column; min-width: 0; padding: 4px 0 8px; }
.tpl-group {
  margin: 12px 0 2px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-2);
}
.tpl-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 4px 6px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.tpl--own .tpl-row, .tpl-row:not(:has(.tpl-check)) { grid-template-columns: minmax(0, 1fr) auto; }
.tpl-row.is-selected { background: var(--accent-soft); border-radius: var(--radius-sm); }
.tpl-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-height: 36px;
  cursor: pointer;
}
.tpl-cb { width: 18px; height: 18px; margin: 0; cursor: pointer; }
.tpl-body { min-width: 0; }
.tpl-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 36px;
  padding: 4px 6px;
  margin: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.tpl-main:hover { background: var(--surface-2); }
.tpl-main:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tpl-name { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.tpl-meta { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 13px; color: var(--text-2); }
.tpl-price { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.tpl-range { font-variant-numeric: tabular-nums; }
.tpl-cond, .tpl-conf, .tpl-extra { white-space: nowrap; }
.tpl-conf { color: var(--warning-text, var(--text-2)); }
.tpl-hint {
  margin: 0 6px 2px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.tpl-src { white-space: normal; }
a.tpl-src { color: var(--link); }
.tpl-side { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tpl-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.tpl-star:hover { background: var(--surface-2); }
.tpl-star.is-on { color: #c98a00; }
.tpl-star:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tpl-empty { margin: 16px 0; color: var(--text-2); }
.tpl-disclaimer { margin: 8px 0 12px; font-size: 12px; line-height: 1.45; color: var(--text-2); }
.tpl-foot {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tpl-foot[hidden] { display: none; }
.tpl-foot-count { font-weight: 600; }
.tpl-foot-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

/* Row details: "Šablóna: … · ceny 2026 · zdroj" + "Uložiť ako šablónu" */
.tpl-info { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-width: 0; }
.tpl-info[hidden], .tpl-info-line[hidden] { display: none; }
.tpl-info-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
  min-width: 0;
  flex: 1 1 260px;
  overflow-wrap: anywhere;
}
.tpl-info-line > svg { flex: 0 0 auto; align-self: center; }
.tpl-info-src a { color: var(--link); }

/* Phones: a bottom sheet over the full width, most of the height. */
@media (max-width: 560px) {
  .modal-backdrop:has(> .tpl-modal) { padding: 8px 0 0; }
  .tpl-modal.modal {
    max-width: none;
    height: calc(100vh - 8px);
    max-height: calc(100vh - 8px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: 0;
  }
  .tpl-modal .modal-header { padding: 12px 12px 4px 16px; }
  .tpl-modal .modal-body { padding-left: 12px; padding-right: 12px; }
  .tpl-foot-actions { width: 100%; }
  .tpl-foot-actions .btn { flex: 1 1 auto; }
}
@supports (height: 100dvh) {
  @media (max-width: 560px) {
    .tpl-modal.modal { height: calc(100dvh - 8px); max-height: calc(100dvh - 8px); }
  }
}
/* Phone: a hint takes at most two lines (more results above the keyboard); a ticked row shows it whole. */
@media (max-width: 720px) {
  .tpl-hint { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .tpl-row.is-selected .tpl-hint { display: block; -webkit-line-clamp: unset; line-clamp: none; overflow: visible; }
}
/* Touch: 16 px search (no iOS zoom) and ≥ 40 px tap targets. */
@media (pointer: coarse), (max-width: 720px) {
  .tpl-search { font-size: 16px; min-height: 40px; }
  .tpl-chip { min-height: 40px; }
  .tpl-check { width: 40px; min-height: 44px; }
  .tpl-main { min-height: 44px; }
  .tpl-star { width: 40px; height: 44px; }
  .tpl-foot .btn, .tpl-save { min-height: 40px; }
  .tpl-del.btn-icon { width: 40px; height: 40px; }
}
