/* public/styles.css — abbr-app v2
   Dark theme, original colour palette preserved.
   Portrait + Landscape both supported.
*/

/* ─── CSS variables (identical palette to original) ─────────────────────── */
:root {
  --bg:       #0f1115;
  --card:     #171a21;
  --surface:  #0e1015;
  --border:   #2a2f3a;
  --text:     #e6e6e6;
  --muted:    #9aa0a6;
  --accent:   #5b9cff;
  --danger:   #e05050;
  --success:  #4caf80;
  --warning:  #f4c12d;

  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  --gap-sm:  8px;
  --gap-md:  12px;
  --gap-lg:  20px;
}

/* ─── reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body { overflow-x: hidden; }
p, h1, h2, h3 { margin: 0; }

/* ─── screens ────────────────────────────────────────────────────────────── */
.screen { min-height: 100dvh; }
.screen[hidden] { display: none !important; }

.page-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 12px 14px 80px; /* bottom pad for action bar */
}

/* ─── top bar ────────────────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 14px;
}
.top-bar-title { font-size: 1rem; font-weight: 600; }
.top-bar-right { display: flex; align-items: center; gap: var(--gap-sm); }

/* ─── screen header ──────────────────────────────────────────────────────── */
.screen-header {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 10px 0 14px;
  flex-wrap: wrap;
}
.screen-header h2 { font-size: 1.1rem; font-weight: 600; flex: 1; }
.screen-context {
  font-size: 0.8rem;
  color: var(--muted);
  font-family: monospace;
}

/* ─── card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: var(--gap-md);
  margin-bottom: var(--gap-md);
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}
.card-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── form elements ──────────────────────────────────────────────────────── */
.field-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--muted);
}
.field-row {
  display: flex;
  gap: var(--gap-sm);
  align-items: flex-end;
  flex-wrap: wrap;
}

input, select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 1rem;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
select { cursor: pointer; }

/* ─── buttons ────────────────────────────────────────────────────────────── */
button { cursor: pointer; font-size: 1rem; border: 0; border-radius: var(--radius-md); padding: 10px 16px; }

.btn { border-radius: var(--radius-md); padding: 10px 18px; font-size: 0.95rem; font-weight: 500; border: 0; }
.btn.primary   { background: var(--accent); color: #041022; font-weight: 700; }
.btn.secondary { background: var(--border); color: var(--text); }
.btn.danger    { background: var(--danger); color: #fff; font-weight: 700; }
.btn.primary:active   { filter: brightness(0.85); }
.btn.secondary:active { filter: brightness(1.15); }
.btn.danger:active    { filter: brightness(0.85); }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

.btn-back {
  background: var(--border);
  color: var(--muted);
  border-radius: var(--radius-md);
  padding: 7px 12px;
  font-size: 0.85rem;
  border: 0;
  white-space: nowrap;
}
.btn-link {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 0.85rem;
  padding: 4px;
  text-decoration: underline;
  cursor: pointer;
}

/* file input label as button */
.btn-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.btn-file input[type=file] { display: none; }

/* ─── num-field (± buttons) ──────────────────────────────────────────────── */
.num-field {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.num-field input {
  border: none;
  border-radius: 0;
  text-align: center;
  flex: 1;
  min-width: 48px;
  font-family: monospace;
}
.num-field input:focus { outline: none; border: none; }
.num-btn {
  background: var(--border);
  color: var(--text);
  border: none;
  border-radius: 0;
  padding: 8px 14px;
  font-size: 1.1rem;
  line-height: 1;
}
.num-btn:active { background: var(--accent); color: #041022; }

/* ─── abbr preview bar ───────────────────────────────────────────────────── */
.abbr-preview {
  flex-direction: row;
  align-items: center;
  gap: var(--gap-sm);
  padding: 10px 14px;
}
.abbr-preview-label { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.abbr-preview code  { font-size: 1rem; font-family: monospace; color: var(--accent); }

/* ─── explain line ───────────────────────────────────────────────────────── */
.explain {
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2em;
}

/* ─── action bar (fixed bottom) ──────────────────────────────────────────── */
.action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: var(--gap-sm);
  padding: 10px 14px;
  background: rgba(15,17,21,0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
}
.action-bar .btn { flex: 1; text-align: center; }

/* ─── photo preview ──────────────────────────────────────────────────────── */
.photo-row {
  display: flex;
  gap: var(--gap-md);
  align-items: center;
}
.photo-preview {
  width: 96px;
  height: 72px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
}
.photo-placeholder {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
}
.photo-actions { display: flex; flex-direction: column; gap: var(--gap-sm); }

/* photo compare (add image screen) */
.photo-compare {
  flex-direction: row;
  align-items: center;
  gap: var(--gap-md);
}
.photo-compare-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex: 1;
}
.photo-compare-label { font-size: 0.7rem; color: var(--muted); }
.photo-compare-slot .photo-preview { width: 100%; height: 90px; }
.photo-compare-arrow { font-size: 1.4rem; color: var(--muted); flex-shrink: 0; }

/* ─── code / badge ───────────────────────────────────────────────────────── */
code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-family: monospace;
}
.badge-online {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 0.75rem;
  background: #144d2a;
  color: #b8f5ce;
}
.offline .badge-online { background: #4d1421; color: #ffd3d3; }
.badge-sync {
  font-size: 0.72rem;
  color: var(--muted);
}
.badge.synced  { color: #b8f5ce; border: 1px solid #1f5131; border-radius: 6px; padding: 2px 6px; font-size: 0.78rem; }
.badge.pending { color: #ffd3d3; border: 1px solid #5d2a2a; border-radius: 6px; padding: 2px 6px; font-size: 0.78rem; }
.badge.failed  { color: #ffb3b3; border: 1px solid #7a1a1a; border-radius: 6px; padding: 2px 6px; font-size: 0.78rem; }
.code-status { font-size: 0.8rem; align-self: flex-end; }

/* ─── suggest strip (ship code suggestions) ──────────────────────────────── */
.suggest-strip {
  display: flex;
  gap: var(--gap-sm);
  flex-wrap: wrap;
  padding-top: 4px;
}
.suggest-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-family: monospace;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--accent);
}
.suggest-chip:active { background: var(--accent); color: #041022; }

/* ─── HOME screen ────────────────────────────────────────────────────────── */
.home-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-md);
  margin: var(--gap-lg) 0;
}
.tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
  transition: background 0.15s;
  color: lightskyblue;
}
.tile:active { background: #1e2330; }
.tile-icon  { font-size: 1.8rem; line-height: 1; }
.tile-label { font-size: 0.9rem; font-weight: 600; text-align: center; }

.home-actions {
  display: flex;
  justify-content: center;
  gap: var(--gap-sm);
}
.home-actions .btn { flex: 1; max-width: 120px; text-align: center; font-size: 0.85rem; padding: 8px 10px; }

/* ─── LOGIN screen ───────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 4px 24px rgba(0,0,0,.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.login-title { font-size: 1.1rem; font-weight: 700; text-align: center; }
.login-user  { display: flex; align-items: center; gap: 8px; }
.login-username { font-size: 1rem; font-weight: 600; color: var(--accent); }
.login-error { font-size: 0.85rem; color: #ff8080; text-align: center; }

/* PIN dots */
.pin-display {
  display: flex;
  gap: 16px;
  justify-content: center;
  padding: 4px 0;
}
.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  transition: background 0.1s, border-color 0.1s;
}
.pin-dot.filled { background: var(--accent); border-color: var(--accent); }

/* PIN pad */
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 260px;
}
.pin-key {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 500;
  padding: 16px;
  text-align: center;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.pin-key:active { background: var(--accent); color: #041022; border-color: var(--accent); }
.pin-key--clear { color: var(--muted); font-size: 1.1rem; }
.pin-key--submit { background: var(--accent); color: #041022; font-weight: 700; }
.pin-key--submit:active { filter: brightness(0.85); }

.change-user-form {
  display: flex;
  gap: var(--gap-sm);
  width: 100%;
}
.change-user-form input { flex: 1; }
.change-user-form .btn { flex-shrink: 0; padding: 10px 14px; }

/* ─── POM list (extend screen) ───────────────────────────────────────────── */
.pom-list { display: flex; flex-direction: column; gap: 6px; }
.pom-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.pom-item code { font-size: 0.85rem; flex: 1; }
.pom-item .badge { flex-shrink: 0; }

/* ─── log list (view screen) ─────────────────────────────────────────────── */
.log-list { display: flex; flex-direction: column; gap: var(--gap-sm); }
.log-item {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.log-item .log-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.log-item .log-ship  { font-family: monospace; font-size: 0.9rem; font-weight: 600; color: var(--accent); }
.log-item .log-type  { font-size: 0.7rem; color: var(--muted); background: var(--surface); padding: 2px 7px; border-radius: 6px; border: 1px solid var(--border); }
.log-item .log-codes { font-family: monospace; font-size: 0.8rem; color: var(--muted); }
.log-item .log-meta  { font-size: 0.72rem; color: var(--muted); display: flex; justify-content: space-between; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* ─── modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay[hidden] { display: none !important; }
.modal-box {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
}
.modal-box h3 { font-size: 1.1rem; font-weight: 600; }
.modal-box p  { font-size: 0.9rem; color: var(--muted); }
.modal-actions { display: flex; gap: var(--gap-sm); }
.modal-actions .btn { flex: 1; text-align: center; font-size: 0.85rem; padding: 12px 8px; }
.modal-actions .btn small { display: block; font-size: 0.7rem; font-weight: 400; opacity: 0.8; margin-top: 3px; }

/* ─── offline state ──────────────────────────────────────────────────────── */
.offline .badge-online { background: #4d1421; color: #ffd3d3; }

/* ─── landscape layout tweaks ────────────────────────────────────────────── */
@media (orientation: landscape) {
  .home-tiles {
    max-width: 520px;
    margin: var(--gap-lg) auto;
  }
  .home-actions { max-width: 400px; margin: 0 auto; }

  .page-wrap { padding-bottom: 100px; }

  /* Login: side-by-side on wide landscape (tablet) */
  @media (min-width: 600px) {
    .login-card { padding: 32px 36px; max-width: 380px; }
    .pin-pad { max-width: 280px; }
  }
}

/* ─── portrait: stack tiles vertically on narrow screens ────────────────── */
@media (max-width: 360px) {
  .home-tiles { grid-template-columns: 1fr; }
  .tile { flex-direction: row; padding: 16px; justify-content: flex-start; }
  .tile-icon { font-size: 1.4rem; }
}

/* ─── camera overlay ─────────────────────────────────────────────────────── */
.camera-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.camera-overlay[hidden] { display: none !important; }

.camera-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#cameraVideo {
  flex: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-label-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.55);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 10;
}
.camera-label-line {
  font-size: 0.85rem;
  color: #fff;
  font-family: monospace;
  line-height: 1.4;
}
.camera-label-line:empty { display: none; }

.camera-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(0,0,0,0.55);
  z-index: 10;
}
.camera-controls .btn { flex: 1; text-align: center; font-size: 1rem; padding: 14px; }
.camera-controls .btn.primary { font-size: 1.1rem; }