/* GDSFF ჟურნალი — UI styles (SPEC 5.0: sunlight, gloves, phone). Light theme only. */

:root {
  --bg: #ffffff;
  --fg: #000000;
  --muted: #333333;
  --line: #4a4a4a;
  --line-soft: #c8c8c8;
  --surface: #f4f4f4;
  --primary: #111111;
  --gold: #c9a54a;
  --gold-text: #6b4f08;
  --danger: #b00020;
  --success: #1b5e20;
  --warn-fg: #6b4400;
  --warn-bg: #fff1c2;
  --focus: #005fcc;
  --radius: 10px;
  --gap: 8px;
  --touch: 56px;
  --chip: 48px;
  --base: 18px;
  font-size: var(--base);
}

html.big {
  --base: 22px;
}

/* device confirmation (Annex 3): the staff UI is out of reach until the password is re-entered */
html.kiosk .bottom-nav,
html.kiosk .user-btn,
html.kiosk .app-header__session,
html.kiosk .user-menu {
  display: none !important;
}

html.kiosk .app-header__brand {
  pointer-events: none;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Georgian", "DejaVu Sans", sans-serif;
  font-size: 1rem;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0.6em 0 0.4em;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.33rem;
}

h3 {
  font-size: 1.22rem;
}

p {
  margin: 0.4em 0;
}

a {
  color: #0b3d91;
  text-decoration: underline;
  text-underline-offset: 2px;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

* {
  transition-duration: 0s !important;
  animation-duration: 0s !important;
}

/* ---------------------------------------------------------------- header */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 4px solid var(--gold);
}

.app-header__row {
  display: flex;
  align-items: center;
  gap: var(--gap);
  max-width: 1000px;
  margin: 0 auto;
  padding: 6px 12px;
  min-height: 60px;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--fg);
  text-decoration: none;
  min-height: 48px;
  min-width: 0;
  flex: 1 1 auto;
}

.app-header__logo {
  height: 40px;
  width: auto;
  display: block;
}

.app-header__title {
  font-weight: 700;
  font-size: 1.15rem;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header__spacer {
  display: none;
}

.app-header__session {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 12px 6px;
}

.app-header__session:has(.session-chip[hidden]) {
  display: none;
}

.session-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--touch);
  padding: 4px 14px;
  border: 2px solid var(--success);
  border-radius: var(--radius);
  color: var(--success);
  background: var(--bg);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.2;
}

.session-chip::before {
  content: "●";
}

.session-chip--suspended {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-color: var(--warn-fg);
}

.user-btn {
  white-space: nowrap;
  min-height: var(--touch);
  min-width: var(--touch);
  flex: 0 0 auto;
  border: 2px solid var(--fg);
  border-radius: 999px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-weight: 700;
  padding: 4px 12px;
  cursor: pointer;
}

.user-menu {
  grid-template-columns: minmax(0, 1fr);
  position: absolute;
  right: 12px;
  top: 100%;
  min-width: 260px;
  max-width: calc(100vw - 24px);
  background: var(--bg);
  border: 2px solid var(--fg);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  gap: var(--gap);
  z-index: 30;
}

.user-menu__name {
  font-weight: 700;
}

.user-menu__role {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------------------------------------------------------------- layout */

main#app {
  max-width: 1000px;
  margin: 0 auto;
  padding: 12px 16px 120px;
  min-height: 60vh;
}

.page-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap);
  margin: 8px 0 12px;
}

.page-title h1 {
  margin: 0;
}

.stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-items: center;
}

.grid-2 {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 700px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.card {
  border: 2px solid var(--fg);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--bg);
  min-width: 0;
}

.card--soft {
  border-color: var(--line-soft);
}

.card h2,
.card h3 {
  margin-top: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.86rem;
}

.mono {
  font-family: ui-monospace, "DejaVu Sans Mono", Consolas, monospace;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.center {
  text-align: center;
}

hr {
  border: 0;
  border-top: 2px solid var(--line-soft);
  margin: 16px 0;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 8px 18px;
  border-radius: var(--radius);
  border: 2px solid var(--primary);
  background: var(--primary);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.btn--secondary {
  background: var(--bg);
  color: var(--fg);
}

.btn--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.btn--success {
  background: var(--success);
  border-color: var(--success);
  color: #ffffff;
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--fg);
  text-decoration: underline;
}

.btn--block {
  display: flex;
  width: 100%;
}

.btn--big {
  min-height: 72px;
  font-size: 1.15rem;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  margin: 12px 0;
}

.actions--stack {
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 700px) {
  .actions--stack {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.actions--sticky {
  /* the gate submit stays in reach above the bottom nav (SPEC 5.2) */
  position: sticky;
  bottom: calc(68px + env(safe-area-inset-bottom));
  z-index: 10;
  background: var(--bg);
  padding: 8px 0;
  margin: 0 0 12px;
}

.fab {
  position: fixed;
  right: 16px;
  bottom: 96px;
  z-index: 15;
  min-height: 64px;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 1.1rem;
}

/* ---------------------------------------------------------------- forms */

.field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  margin: 0 0 14px;
}

.field > label,
.field__label {
  font-weight: 700;
}

.field__hint {
  font-size: 0.86rem;
  color: var(--muted);
}

.field__error {
  color: var(--danger);
  font-weight: 700;
  font-size: 0.9rem;
}

.field__error::before {
  content: "⚠ ";
}

.field--invalid input,
.field--invalid select,
.field--invalid textarea {
  border-color: var(--danger);
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input:not([type]),
select,
textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

select {
  appearance: auto;
}

input[readonly] {
  background: var(--surface);
}

.input-row {
  display: flex;
  gap: var(--gap);
  align-items: stretch;
}

.input-row > input,
.input-row > select {
  flex: 1 1 auto;
  min-width: 0;
}

.input-row > .btn {
  flex: 0 0 auto;
}

/* big checkbox / toggle */
.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--touch);
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  font-weight: 600;
  margin: 0 0 10px;
}

.toggle input {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  accent-color: var(--primary);
  margin: 0;
}

.toggle--on {
  border-color: var(--fg);
  background: var(--surface);
}

/* chip groups */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}

.chip {
  min-height: var(--chip);
  min-width: var(--chip);
  padding: 8px 16px;
  border: 2px solid var(--fg);
  border-radius: 22px;
  text-align: left;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.chip[aria-pressed="true"],
.chip[aria-checked="true"] {
  background: var(--primary);
  color: #ffffff;
}

.chip[aria-pressed="true"]::before,
.chip[aria-checked="true"]::before {
  content: "✓ ";
}

.chip[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.chip--suggested {
  border-style: dashed;
  border-width: 3px;
}

/* tri-state result buttons (Annex 4) */
.results {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
}

.result-btn {
  min-height: var(--touch);
  border: 2px solid var(--fg);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 6px;
}

.result-btn[aria-pressed="true"].result-btn--ok {
  background: var(--success);
  border-color: var(--success);
  color: #ffffff;
}

.result-btn[aria-pressed="true"].result-btn--defect {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.result-btn[aria-pressed="true"].result-btn--na {
  background: var(--primary);
  color: #ffffff;
}

.result-btn[aria-pressed="true"]::before {
  content: "✓ ";
}

.result-btn--suggested {
  border-style: dashed;
  border-width: 3px;
}

.result-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------------------------------------------------------------- badges, banners */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  border: 2px solid var(--fg);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.5;
  max-width: 100%;
  background: var(--bg);
  color: var(--fg);
}

.badge--ok {
  border-color: var(--success);
  color: var(--success);
}

.badge--ok::before {
  content: "✓ ";
}

.badge--danger {
  border-color: var(--danger);
  color: #ffffff;
  background: var(--danger);
}

.badge--danger::before {
  content: "✗ ";
}

.badge--warn {
  border-color: var(--warn-fg);
  color: var(--warn-fg);
  background: var(--warn-bg);
}

.badge--warn::before {
  content: "! ";
}

.badge--gold {
  border-color: var(--gold-text);
  color: var(--gold-text);
}

.badge--dark {
  background: var(--primary);
  color: #ffffff;
}

.banner {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 10px 0;
  border: 2px solid var(--fg);
  font-weight: 600;
}

.banner--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.banner--danger a {
  color: #ffffff;
  font-weight: 700;
}

.banner--warn {
  background: var(--warn-bg);
  border-color: var(--warn-fg);
  color: var(--warn-fg);
}

.banner--ok {
  border-color: var(--success);
  color: var(--success);
}

.banner--info {
  background: var(--surface);
}

.offline-banner {
  /* first child of the sticky header: it scrolls with the header and never covers ☰ (SPEC 5.0) */
  position: static;
  margin: 0;
  border-radius: 0;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.offline-banner__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  margin-top: 4px;
}

.offline-banner__links a {
  display: inline-block;
  padding: 4px 0;
}

/* ---------------------------------------------------------------- lists, tables */

.list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
  margin: 8px 0;
  padding: 0;
  list-style: none;
}

.list-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--touch);
  padding: 10px 14px;
  border: 2px solid var(--fg);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  text-align: left;
  text-decoration: none;
}

button.list-row,
a.list-row {
  cursor: pointer;
}

.list-row__main {
  flex: 1 1 210px;
  min-width: 0;
}

.list-row__title {
  font-weight: 700;
  display: block;
}

.list-row__sub {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
}

.list-row__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.list-row__aside {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-items: center;
}

.list-row--disabled {
  /* no opacity: the badge that explains why the row is closed keeps full contrast (SPEC 5.0) */
  border-style: dashed;
  background: var(--surface);
}

.voided,
.voided .list-row__title,
.voided td {
  text-decoration: line-through;
}

.voided .badge {
  text-decoration: none;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 2px solid var(--fg);
  border-radius: var(--radius);
  margin: 8px 0;
}

table.data {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
}

table.data th,
table.data td {
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

/* record codes (INC-YYYY-N, YYYY-MM-DD-zone-N) and row numbers stay on one line; the box scrolls */
table.data td:first-child {
  white-space: nowrap;
}

table.data th {
  background: var(--surface);
  font-weight: 700;
  position: sticky;
  top: 0;
}

dl.kv {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px 12px;
  margin: 8px 0;
}

dl.kv dt {
  font-weight: 700;
  margin-top: 6px;
}

dl.kv dd {
  margin: 0;
}

@media (min-width: 700px) {
  dl.kv {
    grid-template-columns: minmax(180px, 34%) 1fr;
  }

  dl.kv dt {
    margin-top: 0;
  }
}

/* ---------------------------------------------------------------- tabs, accordion */

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin: 8px 0 12px;
  border-bottom: 2px solid var(--fg);
}

.tab {
  flex: 0 0 auto;
  min-height: var(--chip);
  padding: 8px 14px;
  border: 2px solid var(--fg);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--primary);
  color: #ffffff;
}

@media (max-width: 699px) {
  /* every tab stays visible on a phone (no hidden „დახურვა“ behind a sideways scroll) */
  .tabs {
    flex-wrap: wrap;
    overflow-x: visible;
    border-bottom: 0;
  }

  .tab {
    border-bottom: 2px solid var(--fg);
    border-radius: var(--radius);
  }
}

details.acc {
  border: 2px solid var(--fg);
  border-radius: var(--radius);
  margin: 0 0 10px;
  background: var(--bg);
}

details.acc > summary {
  min-height: var(--touch);
  padding: 12px 14px;
  font-weight: 700;
  font-size: 1.08rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

details.acc > summary::-webkit-details-marker {
  display: none;
}

details.acc > summary::before {
  content: "▸";
  font-size: 1.1rem;
}

details.acc[open] > summary::before {
  content: "▾";
}

details.acc > .acc__body {
  padding: 4px 14px 14px;
  border-top: 2px solid var(--line-soft);
}

/* ---------------------------------------------------------------- checklist rows */

.check-row {
  border: 2px solid var(--fg);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.check-row--critical {
  border-width: 3px;
}

.check-row__head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.check-row__no {
  font-weight: 800;
  min-width: 2em;
}

.topic {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  min-height: var(--touch);
  cursor: pointer;
  margin: 0 0 8px;
}

.topic input {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

.topic--on {
  border-color: var(--fg);
  background: var(--surface);
}

.declaration {
  font-size: 1.2rem;
  line-height: 1.5;
  border: 3px solid var(--fg);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}

/* ---------------------------------------------------------------- dialogs, toasts */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 700px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal {
  background: var(--bg);
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  border: 3px solid var(--fg);
  padding: 16px;
}

@media (min-width: 700px) {
  .modal {
    border-radius: var(--radius);
  }
}

.modal--full {
  max-width: none;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
}

.modal__title {
  margin-top: 0;
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 24px));
  display: grid;
  gap: var(--gap);
  z-index: 60;
}

.toast {
  background: var(--primary);
  color: #ffffff;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-weight: 700;
  border: 2px solid #ffffff;
}

.toast--error {
  background: var(--danger);
}

.toast--ok {
  background: var(--success);
}

/* ---------------------------------------------------------------- bottom nav */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--bg);
  border-top: 2px solid var(--fg);
  display: flex;
  justify-content: center;
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
  gap: 8px;
}

.bottom-nav a {
  flex: 1 1 auto;
  min-width: var(--touch);
  max-width: 220px;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px 2px;
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  font-weight: 700;
  font-size: clamp(10px, 3.1vw, 15px);
  line-height: 1.15;
  hyphens: none;
  overflow-wrap: anywhere;
}

.bottom-nav a[aria-current="page"] {
  background: var(--primary);
  color: #ffffff;
}

/* ---------------------------------------------------------------- login, footer */

.auth-box {
  max-width: 520px;
  margin: 24px auto;
}

.auth-logo {
  display: block;
  height: 96px;
  width: auto;
  margin: 8px auto;
}

.site-footer {
  margin: 32px 0 8px;
  padding-top: 12px;
  border-top: 2px solid var(--line-soft);
  font-size: 0.86rem;
  color: var(--muted);
  text-align: center;
}

.notice-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px;
}

.notice-page ol,
.notice-page ul {
  padding-left: 1.3em;
}

.notice-page li {
  margin: 0 0 8px;
}

.countdown {
  font-weight: 800;
  font-size: 1.1rem;
}

.kpi {
  font-size: 1.6rem;
  font-weight: 800;
}

.subnav {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
}

/* ---------------------------------------------------------------- print */

@media print {
  .app-header,
  .bottom-nav,
  .fab,
  .actions,
  .btn,
  .toasts,
  .tabs,
  .offline-banner,
  .no-print {
    display: none !important;
  }

  html,
  body,
  .card,
  .banner {
    background: #ffffff !important;
    color: #000000 !important;
  }

  main#app {
    padding: 0;
    max-width: none;
  }

  a {
    color: #000000;
    text-decoration: none;
  }
}
