/* Presupusta — free quote generator. Builds on ../styles.css tokens. */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.tool-page { background: var(--surface); }

.tool-hero {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(36px, 6vw, 64px) clamp(16px, 4vw, 40px) 8px;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.chips .lang-switch { font-size: 14px; }
.chip {
  background: var(--surface-container); color: var(--on-surface-variant);
  font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: var(--radius-full);
}
.tool-hero h1 { font-size: clamp(30px, 4.5vw, 44px); font-weight: 800; }
.tool-hero__lead { margin-top: 12px; color: var(--on-surface-variant); font-size: 17px; max-width: 640px; }

/* ---- Layout ---- */
.tool {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 40px) 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .95fr);
  gap: 28px;
  align-items: start;
}
.preview { position: sticky; top: 76px; }

/* ---- Form ---- */
.card {
  background: var(--white);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 0 0 16px;
  box-shadow: var(--shadow-sm);
}
fieldset.card { min-width: 0; }
legend { font-weight: 700; font-size: 15px; padding: 0 6px; margin-left: -6px; color: var(--on-surface); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field > span { font-size: 13px; font-weight: 600; color: var(--on-surface-variant); }
.field em { color: var(--error); font-style: normal; }

input[type="text"], input[type="tel"], input[type="email"], input[type="date"], input[type="number"], select, textarea {
  font: inherit; font-size: 15px;
  color: var(--on-surface);
  background: var(--surface);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  width: 100%;
  min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 88, 190, .15); background: var(--white);
}
input:invalid.touched { border-color: var(--error); }
textarea { resize: vertical; line-height: 1.5; }

/* Lines */
.lines { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 104px 96px 32px;
  gap: 8px; align-items: center;
}
.line__amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; white-space: nowrap; }
.line__remove {
  width: 32px; height: 32px; border-radius: var(--radius-full);
  border: 1px solid var(--outline-variant); background: transparent; color: var(--outline);
  cursor: pointer; font-size: 18px; line-height: 1;
}
.line__remove:hover { color: var(--error); border-color: var(--error); }
.lines__head {
  display: grid; grid-template-columns: minmax(0, 1fr) 72px 104px 96px 32px; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--outline); padding: 0 2px;
}
.lines__head span:nth-child(n+2) { text-align: right; }
.prefill { margin-top: 12px; font-size: 13px; color: var(--on-surface-variant); line-height: 1.8; }
.prefill button {
  font: inherit; font-weight: 600; color: var(--primary); background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.prefill button:hover { color: var(--primary-container); }

/* Segmented VAT */
.segmented { display: inline-flex; border: 1px solid var(--outline-variant); border-radius: var(--radius-full); overflow: hidden; background: var(--surface); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span { display: block; padding: 9px 20px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--on-surface-variant); }
.segmented input:checked + span { background: var(--primary); color: #fff; }
.segmented input:focus-visible + span { box-shadow: inset 0 0 0 2px rgba(0,88,190,.5); }
.help { margin-top: 10px; font-size: 13px; color: var(--on-surface-variant); }
.help a { color: var(--primary); font-weight: 600; }

/* Totals + actions */
.totals { display: flex; flex-direction: column; gap: 8px; }
.totals > div { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; color: var(--on-surface-variant); }
.totals strong { font-variant-numeric: tabular-nums; color: var(--on-surface); }
.totals__total { border-top: 1px solid var(--outline-variant); padding-top: 10px; margin-top: 4px; font-size: 18px !important; }
.totals__total strong { font-size: 24px; font-weight: 800; color: var(--primary) !important; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.print-hint { margin-top: 12px; font-size: 13px; color: var(--on-surface-variant); background: var(--surface-container); padding: 10px 14px; border-radius: var(--radius-md); }
.form-error { margin-top: 12px; font-size: 14px; color: var(--error); font-weight: 600; }
.preview__close { display: none; margin: 16px auto 0; }

/* ---- Sheet (A4 preview + print) ---- */
.sheet {
  background: #fff;
  color: #111C2D;
  border: 1px solid var(--outline-variant);
  box-shadow: var(--shadow-md);
  padding: 32px 34px 24px;
  font-size: 12.5px;
  line-height: 1.45;
  min-height: 560px;
  display: flex; flex-direction: column;
}
.sheet__head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 18px; border-bottom: 2px solid var(--primary); }
.sheet__issuer strong { display: block; font-size: 17px; font-weight: 800; margin-bottom: 4px; }
.sheet__issuer div, .sheet__client div { color: #424754; }
.sheet__meta { text-align: right; white-space: nowrap; }
.sheet__title { font-size: 20px; font-weight: 800; letter-spacing: .08em; color: var(--primary); margin-bottom: 6px; }
.sheet__meta span { color: #727785; margin-right: 6px; }
.sheet__client { margin-top: 18px; }
.sheet__label { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #727785; margin-bottom: 4px; }
.sheet__client strong { display: block; font-size: 14px; }

.sheet__table { width: 100%; border-collapse: collapse; margin-top: 20px; }
.sheet__table th { text-align: left; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: #727785; padding: 6px 4px; border-bottom: 1px solid #C2C6D6; }
.sheet__table td { padding: 8px 4px; border-bottom: 1px solid #E7EEFF; vertical-align: top; }
.sheet__table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sheet__table .empty td { color: #727785; font-style: italic; text-align: center; padding: 18px 4px; }

.sheet__totals { margin: 16px 0 0 auto; width: 240px; }
.sheet__totals > div { display: flex; justify-content: space-between; padding: 4px 0; color: #424754; }
.sheet__totals strong { font-variant-numeric: tabular-nums; color: #111C2D; }
.sheet__total { border-top: 2px solid var(--primary); margin-top: 4px; padding-top: 8px !important; font-size: 14px; }
.sheet__total strong { font-size: 18px; font-weight: 800; color: var(--primary) !important; }

.sheet__conditions { margin-top: 22px; }
.sheet__conditions p { white-space: pre-line; color: #424754; }
.sheet__foot { margin-top: auto; padding-top: 22px; display: flex; align-items: center; gap: 12px; font-size: 10.5px; color: #727785; }
.sheet__qr { width: 56px; height: 56px; flex-shrink: 0; }
.sheet__foot-wm { font-weight: 600; color: #424754; }
.sheet__foot-url { color: #727785; }

/* ---- Compare + FAQ ---- */
.app-cta { padding-top: 24px; }
.compare { width: 100%; max-width: 640px; margin: 36px auto 0; border-collapse: collapse; background: var(--white); border: 1px solid var(--outline-variant); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.compare th, .compare td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--surface-container); font-size: 14.5px; }
.compare th { background: var(--surface-low); font-weight: 700; }
.compare th:nth-child(3), .compare td:nth-child(3) { color: var(--primary); font-weight: 600; }
.compare td.no { color: var(--outline); }
.compare tr:last-child td { border-bottom: 0; }

.faq dl { max-width: 720px; margin: 36px auto 0; }
.faq dt { font-weight: 700; font-size: 17px; margin-top: 22px; }
.faq dd { margin: 6px 0 0; color: var(--on-surface-variant); }
.faq a { color: var(--primary); font-weight: 600; }

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .tool { grid-template-columns: 1fr; }
  .preview { position: static; display: none; }
  .preview.is-open { display: block; }
  .preview__close { display: block; }
  .tool-form.is-hidden { display: none; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .line { grid-template-columns: minmax(0, 1fr) 32px; grid-template-areas: "desc remove" "qty qty" "price price" "amount amount"; }
  .line input[name="desc"] { grid-area: desc; }
  .line input[name="qty"] { grid-area: qty; }
  .line input[name="price"] { grid-area: price; }
  .line__amount { grid-area: amount; }
  .line__remove { grid-area: remove; }
  .lines__head { display: none; }
  .line { padding: 10px; border: 1px solid var(--outline-variant); border-radius: var(--radius-md); background: var(--surface); }
  .sheet { padding: 20px 18px; font-size: 11.5px; }
  .sheet__head { flex-direction: column; }
  .sheet__meta { text-align: left; }
}

/* ---- Print: only the sheet, A4 ---- */
@media print {
  @page { size: A4; margin: 14mm 14mm 16mm; }
  html, body { background: #fff !important; }
  body * { visibility: hidden; }
  .sheet, .sheet * { visibility: visible; }
  .site-header, .site-footer, .tool-hero, .tool-form, .app-cta, .faq, .preview__close, #aido-consent { display: none !important; }
  .tool { display: block; padding: 0; }
  .preview { display: block !important; position: static; }
  .sheet { position: absolute; left: 0; top: 0; width: 100%; min-height: 0; border: 0; box-shadow: none; padding: 0; font-size: 11.5pt; }
  .sheet__head, .sheet__total { border-color: #0058BE; }
  .sheet__title, .sheet__total strong { color: #0058BE; }
  .sheet__table tr { page-break-inside: avoid; }
}
