/* public/css/style.css */
/* Tvasta Spares Site App V2 - Clean, high-contrast, sunlight-readable UI */
/* Tokens as CSS variables only. Neutral ramp, one accent, status colors only for life. */

:root {
  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --text-sm: 14px;
  --text-base: 17px;
  --text-lg: 20px;
  --text-xl: 28px;
  --weight-regular: 400;
  --weight-semibold: 600;

  /* Neutral Ramp (Light Theme default) */
  --bg-canvas: #f9fafb;
  --bg-surface: #ffffff;
  --bg-subtle: #f3f4f6;
  --bg-muted: #e5e7eb;
  
  --border-hairline: #e5e7eb;
  --border-strong: #d1d5db;

  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-tertiary: #6b7280;

  /* Single Accent for Primary Action */
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-subtle: #eff6ff;
  --accent-contrast: #ffffff;

  /* Status Colors ONLY for Life & Critical Alerts */
  --life-green: #15803d;
  --life-green-bg: #dcfce7;
  --life-amber: #b45309;
  --life-amber-bg: #fef3c7;
  --life-red: #b91c1c;
  --life-red-bg: #fee2e2;

  /* Sizing & Touch Targets */
  --tap-min-height: 56px;
  --tile-size: 56px;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-pill: 9999px;
  --spacing-unit: 8px;
}

/* Optional Dark Theme */
[data-theme="dark"] {
  color-scheme: dark; /* native dropdowns, scrollbars and inputs follow the dark theme */
  --bg-canvas: #111827;
  --bg-surface: #1f2937;
  --bg-subtle: #374151;
  --bg-muted: #4b5563;
  --border-hairline: #374151;
  --border-strong: #4b5563;
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --text-tertiary: #9ca3af;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-subtle: #1e3a8a;
  --life-green: #22c55e;
  --life-green-bg: #14532d;
  --life-amber: #f59e0b;
  --life-amber-bg: #78350f;
  --life-red: #ef4444;
  --life-red-bg: #7f1d1d;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  color: var(--text-primary);
  background-color: var(--bg-canvas);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* Screen Transitions */
.view-screen {
  display: none;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

.view-screen.active {
  display: block;
}

/* Header & Navigation Bar */
.site-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-hairline);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.site-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.site-switcher-select {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  min-height: 40px;
}

.header-user-badge {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Status Pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-hairline);
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.status-pill.synced {
  color: var(--life-green);
  border-color: var(--life-green);
  background: var(--life-green-bg);
}

.status-pill.syncing {
  color: var(--life-amber);
  border-color: var(--life-amber);
  background: var(--life-amber-bg);
}

.status-pill.queued, .status-pill.offline {
  color: var(--text-secondary);
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

/* Lucide Line Icons */
.lucide-icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Buttons (Tap targets >= 56px on site screens) */
.btn-primary, .btn-secondary, .btn-outline, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  min-height: var(--tap-min-height);
  padding: 12px 20px;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover, .btn-primary:active {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-hairline);
}

.btn-secondary:hover, .btn-secondary:active {
  background: var(--bg-muted);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}

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

.btn-block {
  width: 100%;
}

.btn-icon-square {
  min-width: var(--tap-min-height);
  min-height: var(--tap-min-height);
  padding: 0;
}

/* Screen Headers & Title */
.screen-heading {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

.screen-subheading {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin-bottom: 8px;
}

.screen-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

/* Part Photo Tile (Same 56x56 size everywhere) */
.part-photo-tile {
  width: var(--tile-size);
  height: var(--tile-size);
  min-width: var(--tile-size);
  min-height: var(--tile-size);
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  overflow: hidden;
}

.part-photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.part-photo-tile .lucide-icon {
  width: 28px;
  height: 28px;
}

/* Printer Section (NO nested cards: section with header and hairline-separated rows) */
.printer-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  overflow: hidden;
}

.printer-section.highlighted {
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.printer-header {
  padding: 14px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.printer-title-group {
  display: flex;
  flex-direction: column;
}

.printer-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.printer-meta {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* Today Strip */
.today-strip {
  padding: 10px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.today-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.shift-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  border: 1px solid var(--border-hairline);
  background: var(--bg-surface);
  color: var(--text-primary);
}

.shift-chip.logged {
  background: var(--life-green-bg);
  border-color: var(--life-green);
  color: var(--life-green);
}

.shift-chip.pending {
  background: var(--life-amber-bg);
  border-color: var(--life-amber);
  color: var(--life-amber);
}

/* Slot Rows (separated by hairlines) */
.slot-rows {
  display: flex;
  flex-direction: column;
}

.slot-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 14px;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--bg-surface);
}

.slot-row:last-child {
  border-bottom: none;
}

.slot-info {
  flex: 1;
  min-width: 0;
}

.slot-name-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.slot-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
}

.slot-part-id {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

.slot-part-name {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Life Bar & Badges */
.life-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.life-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--bg-muted);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.life-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 200ms ease;
}

.life-bar-fill.green {
  background: var(--life-green);
}

.life-bar-fill.amber {
  background: var(--life-amber);
}

.life-bar-fill.red {
  background: var(--life-red);
}

.life-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.life-badge-over {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--life-red-bg);
  border: 1px solid var(--life-red);
  color: var(--life-red);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

/* Inputs & Form Elements */
.input-big-number {
  width: 100%;
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  padding: 14px 16px;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  min-height: var(--tap-min-height);
  text-align: right;
}
/* Text fields and dropdowns reuse the big-input size but read left-to-right in the normal font */
select.input-big-number,
input[type="text"].input-big-number,
input[type="email"].input-big-number,
input[type="url"].input-big-number,
input:not([inputmode]).input-big-number {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular, 400);
  text-align: left;
}

.input-big-number:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  margin-bottom: 8px;
}

.form-help {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Guard Prompt Card */
.guard-banner {
  background: var(--life-amber-bg);
  border: 1px solid var(--life-amber);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guard-message {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--life-amber);
}

.guard-actions {
  display: flex;
  gap: 10px;
}

.guard-btn {
  flex: 1;
  min-height: 48px;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
}

.guard-btn.yes {
  background: var(--life-amber);
  color: #ffffff;
}

.guard-btn.no {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* Service Screen Checkbox Rows */
.service-slot-row {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 14px;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--bg-surface);
  cursor: pointer;
  min-height: var(--tap-min-height);
}

.service-checkbox {
  width: 24px;
  height: 24px;
  cursor: pointer;
}

.slot-selection-panel {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-hairline);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Stepper for Qty Slots */
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stepper-btn {
  width: var(--tap-min-height);
  height: var(--tap-min-height);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}

.stepper-value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  min-width: 48px;
  text-align: center;
}

/* Stock Picker Modal / Drawer */
.stock-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--bg-surface);
  cursor: pointer;
  min-height: var(--tap-min-height);
}

.stock-item:hover {
  background: var(--bg-subtle);
}

.stock-item.selected {
  border-left: 4px solid var(--accent);
  background: var(--accent-subtle);
}

/* Keypad for Not In List */
.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.keypad-key {
  min-height: var(--tap-min-height);
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.keypad-key:active {
  background: var(--bg-subtle);
}

/* Confirm Card */
.confirm-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.confirm-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-hairline);
}

.confirm-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.confirm-side {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.confirm-arrow {
  color: var(--text-tertiary);
}

/* History / Logs Screen */
.log-group {
  margin-bottom: 24px;
}

.log-group-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-hairline);
  min-height: var(--tap-min-height);
  gap: 12px;
}

.log-item:first-child {
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.log-item:last-child {
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  border-bottom: none;
}

.btn-undo {
  min-height: 48px;
  padding: 8px 16px;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
}

.btn-undo:hover {
  background: var(--bg-muted);
}

/* Admin Screens */
.admin-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-hairline);
  margin-bottom: 20px;
  overflow-x: auto;
}

.admin-tab {
  padding: 12px 16px;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.admin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.admin-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

/* Global Toast */
.toast-msg {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  color: var(--bg-surface);
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 250ms ease;
  z-index: 1000;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

.toast-msg.show {
  transform: translateX(-50%) translateY(0);
}

/* Language Selector */
.lang-picker-group {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.lang-btn {
  flex: 1;
  min-height: 48px;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
}

.lang-btn.active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 12px;
  }
  .site-meta {
    justify-content: space-between;
  }
  .header-actions {
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 6px;
  }
  /* Phone: one compact row - icon-only buttons, labels kept for screen readers via aria-label */
  .header-actions button > span[data-i18n],
  #sync-text { display: none; }
  .header-actions button { min-width: 56px; padding: 0 12px; justify-content: center; }
  #header-lang-picker { flex: 1; min-width: 0; }
  .view-screen {
    padding: 12px 10px;
  }
}

@media (min-width: 768px) {
  .view-screen {
    padding: 24px 20px;
  }
}

/* Extra shift + shift editor + ID entry (2026-11-16) */
.shift-chip.extra { border-style: dashed; }
.btn-extra-shift { min-height: 36px; padding: 4px 12px; font-size: var(--text-sm); display: inline-flex; align-items: center; gap: 6px; }
.field-label { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-secondary); }
.shift-edit-row { display: grid; grid-template-columns: 1fr 104px 104px 44px; gap: 8px; align-items: center; }
.shift-edit-row input { min-height: 44px; padding: 6px 10px; border: 1px solid var(--border-strong, var(--border-hairline)); border-radius: var(--radius-sm); background: var(--bg-surface, transparent); color: var(--text-primary); font: inherit; min-width: 0; }
.shift-edit-row .btn-secondary { min-height: 44px; padding: 0; display: flex; align-items: center; justify-content: center; }
@media (max-width: 600px) { .shift-edit-row { grid-template-columns: 1fr 1fr 44px; } .shift-edit-row .shift-name { grid-column: 1 / -1; } }
.id-prefix-btn { min-height: 48px; font-family: var(--font-mono); font-size: var(--text-lg); }
.id-check { font-size: var(--text-sm); min-height: 20px; margin-top: 6px; }
.id-check.ok { color: var(--status-success, #1e8e3e); } .id-check.new { color: var(--status-warning, #b26a00); }
