/* TCI kiosk: ecran tactil în depozit, folosit în picioare, cu scannerul în mână. */

:root {
  --ink: #15233A;
  --ink-2: #4A5A70;
  --concrete: #E4E8EB;
  --concrete-2: #D3D9DE;
  --paper: #FFFEFA;
  --line: #C9D1D8;
  --carbon: #2C4BA0;
  --lager: #F2B33D;
  --lager-2: #E09D1A;
  --lager-tint: #FDF0D2;
  --ok: #1E7A4C;
  --ok-tint: #E2F2E9;
  --stop: #B8322A;
  --stop-tint: #FBE6E3;

  --font-ui: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --font-num: "Barlow Condensed", "Arial Narrow", "Segoe UI", sans-serif;
  --radius: 14px;
  --gutter: clamp(24px, 3vw, 56px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--concrete);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 20px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 4px solid var(--carbon); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

h1 {
  margin: 0 0 12px;
  font-size: clamp(34px, 3.1vw, 54px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.01em;
  max-width: 20ch;
  text-wrap: balance;
}
h2 { margin: 0 0 12px; font-size: 32px; line-height: 1.15; }
.k-lede { margin: 0 0 20px; font-size: clamp(19px, 1.35vw, 23px); color: var(--ink-2); max-width: 46ch; }

/* ---- Cadru ---------------------------------------------------------------- */

.k-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.k-top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px var(--gutter);
  border-bottom: 2px solid var(--concrete-2);
}
.k-mark {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 32px;
  letter-spacing: 0.04em;
  line-height: 1;
  padding: 6px 10px 4px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 6px;
}
.k-place { font-weight: 600; font-size: 20px; color: var(--ink-2); }
.k-lang {
  margin-left: auto;
  min-height: 52px;
  padding: 0 22px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  font-weight: 700;
}
.k-lang:active { background: var(--ink); color: var(--paper); }

.k-screen {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(380px, 1fr);
  gap: clamp(32px, 4vw, 80px);
  padding: clamp(24px, 3.2vh, 48px) var(--gutter);
}
.k-main { min-height: 0; display: flex; flex-direction: column; }
.k-side { min-height: 0; display: flex; flex-direction: column; gap: 20px; }

/* ---- Câmp, tastatură, butoane -------------------------------------------- */

.k-entry { display: grid; gap: 16px; max-width: 580px; }
.k-input {
  width: 100%;
  height: clamp(80px, 10vh, 104px);
  padding: 0 24px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--carbon);
  font-family: var(--font-num);
  font-weight: 600;
  font-size: clamp(44px, 5.5vh, 60px);
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  caret-color: var(--carbon);
}
.k-input::placeholder { color: var(--line); font-weight: 500; letter-spacing: 0.02em; }
.k-input:focus { outline: none; box-shadow: 0 0 0 5px rgba(44, 75, 160, 0.25); }

.k-numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.k-key {
  height: clamp(64px, 7vh, 84px);
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  border-radius: 12px;
  background: var(--paper);
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 40px;
  line-height: 1;
}
.k-key:active { background: var(--ink); border-color: var(--ink); color: var(--paper); transform: translateY(2px); border-bottom-width: 2px; }
.k-key--clear, .k-key--back { font-family: var(--font-ui); font-size: 19px; font-weight: 700; color: var(--ink-2); background: transparent; }

.k-btn {
  min-height: clamp(72px, 9vh, 92px);
  padding: 0 32px;
  border: 0;
  border-radius: var(--radius);
  font-size: clamp(22px, 1.6vw, 28px);
  font-weight: 700;
  line-height: 1.1;
}
.k-btn--go, .k-btn--add, .k-btn--finish { background: var(--lager); color: var(--ink); box-shadow: inset 0 -5px 0 var(--lager-2); }
.k-btn--go:active, .k-btn--add:active, .k-btn--finish:active { box-shadow: inset 0 -2px 0 var(--lager-2); transform: translateY(2px); }
.k-btn--quiet { background: transparent; border: 2px solid var(--ink-2); color: var(--ink-2); min-height: 64px; font-size: 21px; }
.k-btn:disabled { background: var(--concrete-2); color: var(--ink-2); box-shadow: none; cursor: default; }
.k-btn__count { font-weight: 600; }

.k-inline-error {
  margin: 20px 0 0;
  max-width: 580px;
  padding: 18px 22px;
  border-left: 8px solid var(--stop);
  border-radius: 8px;
  background: var(--stop-tint);
  font-size: 22px;
  font-weight: 600;
}

/* ---- Ecranul de scanare --------------------------------------------------- */

.k-carrier { margin: 0 0 10px; font-size: 22px; color: var(--ink-2); }
.k-carrier strong { color: var(--ink); }
.k-carrier span { font-family: var(--font-num); font-size: 24px; letter-spacing: 0.04em; margin-left: 6px; }

.k-entry--scan { max-width: 640px; }
.k-entry__row { display: grid; grid-template-columns: 1fr auto; gap: 16px; }
/* Mesajul stă imediat sub tastatură, pe aceeași lățime: încape și pe tabletă. */
.k-entry__grid { display: grid; grid-template-columns: 1fr; gap: 16px; }

.k-feedback {
  padding: 18px 24px;
  border-radius: var(--radius);
  border-left: 12px solid var(--line);
  background: var(--paper);
}
.k-feedback__title { margin: 0 0 4px; font-size: clamp(22px, 1.7vw, 28px); font-weight: 700; line-height: 1.2; }
.k-feedback__detail { margin: 0; font-size: 19px; color: var(--ink-2); }
.k-feedback--ok { border-color: var(--ok); background: var(--ok-tint); }
.k-feedback--ok .k-feedback__title { color: var(--ok); }
.k-feedback--warn { border-color: var(--lager-2); background: var(--lager-tint); }
.k-feedback--stop { border-color: var(--stop); background: var(--stop-tint); }
.k-feedback--stop .k-feedback__title { color: var(--stop); }
.k-feedback.is-pulse { animation: pulse 420ms ease-out; }
@keyframes pulse { from { transform: translateX(-10px); } to { transform: none; } }

.k-foot {
  margin-top: auto;
  padding-top: 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}
.k-help { font-size: 18px; color: var(--ink-2); }
.k-help p { margin: 0 0 8px; }
.k-help audio { display: block; height: 44px; margin-top: 6px; }
.k-help--row { display: flex; gap: 28px; text-align: left; }
.k-help--row > span { display: block; max-width: 300px; }

/* ---- Recipisa ------------------------------------------------------------- */

.k-side::before {
  /* fanta imprimantei din care iese recipisa */
  content: "";
  display: block;
  height: 14px;
  margin: 0 -10px -26px;
  border-radius: 7px;
  background: var(--ink);
  position: relative;
  z-index: 2;
}

.slip {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 34px 28px 22px;
  margin-bottom: 14px;
  background: var(--paper);
  box-shadow: 0 22px 32px -26px rgba(21, 35, 58, 0.55);
}
.slip::after {
  /* marginea ruptă */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -12px;
  height: 12px;
  background:
    linear-gradient(135deg, var(--paper) 50%, transparent 50%) 0 0 / 18px 12px repeat-x,
    linear-gradient(225deg, var(--paper) 50%, transparent 50%) 0 0 / 18px 12px repeat-x;
}

.slip__title { margin: 0; font-family: var(--font-num); font-weight: 600; font-size: 28px; letter-spacing: 0.02em; color: var(--ink-2); }
.slip__carrier { margin: 2px 0 0; font-size: 22px; font-weight: 700; line-height: 1.25; }
.slip__ref { margin: 6px 0 0; font-size: 17px; color: var(--ink-2); }
.slip__refno { font-family: var(--font-num); font-weight: 600; font-size: 26px; letter-spacing: 0.05em; color: var(--carbon); margin-left: 4px; }
.slip__head { padding-bottom: 14px; border-bottom: 2px dashed var(--line); }

.slip__lines { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.slip__line {
  display: grid;
  grid-template-columns: 2.2em 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--concrete);
}
.slip__n { font-family: var(--font-num); font-size: 22px; color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
.slip__doc { font-family: var(--font-num); font-weight: 600; font-size: clamp(32px, 2.6vw, 42px); letter-spacing: 0.05em; color: var(--carbon); font-variant-numeric: tabular-nums; line-height: 1.1; }
.slip__time { font-size: 17px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.slip__remove {
  min-height: 48px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.slip__remove:active { background: var(--stop-tint); color: var(--stop); }
.slip__line.is-new { animation: feed 520ms cubic-bezier(.2, .8, .2, 1); }
@keyframes feed {
  from { transform: translateY(-22px); opacity: 0; background: var(--lager-tint); }
  40% { opacity: 1; }
  to { transform: none; background: transparent; }
}
.slip__none { margin: 18px 0; color: var(--ink-2); font-size: 20px; }

.slip--blank { flex: 0 1 auto; min-height: 280px; }
.slip--blank .slip__blank {
  margin: 14px 0 0;
  padding-top: 18px;
  border-top: 2px dashed var(--line);
  color: var(--ink-2);
  font-size: 21px;
  min-height: 170px;
  background: repeating-linear-gradient(to bottom, transparent 0 56px, var(--concrete) 56px 58px) 0 64px / 100% calc(100% - 64px) no-repeat;
}

.k-btn--finish { width: 100%; min-height: clamp(84px, 11vh, 112px); font-size: clamp(26px, 2vw, 32px); }

/* ---- Gata ----------------------------------------------------------------- */

.k-screen--done { grid-template-columns: minmax(300px, 440px) minmax(0, 1fr); align-items: center; }
.slip--torn {
  flex: none;
  padding: 36px 32px 40px;
  transform: rotate(-2.5deg);
  animation: tear 900ms cubic-bezier(.3, .7, .2, 1) both;
  box-shadow: 0 30px 40px -24px rgba(21, 35, 58, 0.5);
}
.slip--torn::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -12px;
  height: 12px;
  background:
    linear-gradient(45deg, var(--paper) 50%, transparent 50%) 0 0 / 18px 12px repeat-x,
    linear-gradient(-45deg, var(--paper) 50%, transparent 50%) 0 0 / 18px 12px repeat-x;
}
.slip__bigref { margin: 22px 0 6px; font-family: var(--font-num); font-weight: 700; font-size: 58px; line-height: 1; letter-spacing: 0.04em; color: var(--carbon); }
.slip__total { margin: 0; font-size: 22px; color: var(--ink-2); }
@keyframes tear {
  0% { transform: translateY(-40px) rotate(0); }
  35% { transform: translateY(0) rotate(0); }
  100% { transform: translateY(8px) rotate(-2.5deg); }
}
.k-done h1 { font-size: clamp(44px, 4.4vw, 76px); max-width: 14ch; }
.k-done .k-lede { font-size: 25px; }
.k-countdown { margin: 22px 0 0; color: var(--ink-2); font-size: 19px; }

/* ---- Dialoguri și ecrane de mesaj ---------------------------------------- */

.k-dialog {
  width: min(680px, calc(100vw - 48px));
  padding: 40px;
  border: 0;
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
}
.k-dialog::backdrop { background: rgba(21, 35, 58, 0.6); }
.k-dialog p { font-size: 23px; color: var(--ink-2); margin: 0 0 28px; }
.k-dialog__actions { display: flex; gap: 16px; justify-content: flex-end; flex-wrap: wrap; }

.k-shell--message .k-notice { padding: 12vh var(--gutter); max-width: 900px; }
.k-notice p { font-size: 24px; color: var(--ink-2); max-width: 46ch; }
.k-notice__en { font-size: 20px !important; }

/* ---- Ecrane mai mici (1280×1024 / 1024×768) ------------------------------ */

/* Ecran mare de kiosk: instrucțiunile audio stau în spațiul liber din dreapta tastaturii. */
@media (min-width: 1601px) and (min-height: 821px) {
  .k-screen--scan .k-main {
    display: grid;
    grid-template-columns: minmax(0, 640px) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto 1fr;
    column-gap: 40px;
  }
  .k-screen--scan .k-main > * { grid-column: 1; }
  .k-screen--scan .k-foot { display: contents; }
  .k-screen--scan .k-help--row { grid-column: 2; grid-row: 4; align-self: end; flex-direction: column; gap: 18px; }
  .k-screen--scan [data-cancel] { grid-row: 5; align-self: end; justify-self: start; margin-top: 16px; }
}
@media (max-width: 1600px) {
  .k-help--row { flex-direction: column; gap: 6px; }
  .k-help--row audio { height: 34px; width: 280px; margin-top: 2px; }
}
@media (max-width: 1180px) {
  .k-screen { grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr); gap: 28px; }
  .k-feedback { padding: 14px 18px; }
  .k-feedback__title { font-size: 21px; }
  .k-feedback__detail { font-size: 17px; }
  .slip { padding: 30px 18px 18px; }
  .slip__line { grid-template-columns: 1.6em 1fr auto; gap: 8px; }
  .slip__time { display: none; }
  .slip__doc { font-size: 30px; }
  .k-btn--finish { font-size: 22px; padding: 0 16px; }
}
@media (max-height: 820px) {
  h1 { font-size: 32px; }
  .k-screen--scan .k-lede { display: none; }
  .k-input { height: 68px; font-size: 40px; }
  .k-key { height: 58px; font-size: 32px; }
  .k-key--clear, .k-key--back { font-size: 17px; }
  .k-btn { min-height: 64px; }
  .k-help--row { display: none; }
  .k-foot { padding-top: 12px; }
  .k-screen { padding-top: 16px; padding-bottom: 16px; }
  .k-carrier { margin-bottom: 4px; }
  .k-entry__grid, .k-entry { gap: 10px; }
  .k-key { height: 52px; }
  .k-numpad { gap: 8px; }
}

/* Tabletă în portrait / ecran îngust: recipisa coboară sub tastatură, pagina se poate derula. */
@media (orientation: portrait), (max-width: 860px) {
  html, body { overflow: auto; }
  .k-shell { height: auto; min-height: 100vh; }
  .k-screen, .k-screen--done { grid-template-columns: 1fr; gap: 28px; }
  .k-entry, .k-entry--scan { max-width: none; }
  .k-side { min-height: auto; }
  .slip { flex: none; max-height: 46vh; }
  .slip--blank { display: none; }
  .k-screen--carrier .k-side::before { display: none; }
  .k-foot { margin-top: 20px; }
  .k-done h1 { max-width: none; }
  .k-key { height: 68px; }
  /* "Am terminat" rămâne mereu la îndemână, fără derulare. */
  .k-screen--scan { padding-bottom: 132px; }
  .k-screen--scan .k-btn--finish {
    position: fixed;
    left: var(--gutter);
    right: var(--gutter);
    bottom: 16px;
    width: auto;
    z-index: 5;
    box-shadow: inset 0 -5px 0 var(--lager-2), 0 10px 30px rgba(21, 35, 58, 0.35);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
