/* ===== SCS Warehouse — Design System ===== */
:root {
  --bg: #111827;
  --card: #1F2937;
  --card-hover: #273449;
  --border: #374151;
  --text: #F9FAFB;
  --text-secondary: #E5E7EB;
  --muted: #9CA3AF;
  --primary: #F59E0B;
  --primary-hover: #D97706;
  --primary-soft: rgba(245, 158, 11, 0.15);
  --success: #10B981;
  --success-hover: #059669;
  --success-soft: rgba(16, 185, 129, 0.15);
  --danger: #EF4444;
  --danger-hover: #DC2626;
  --secondary: #4B5563;
  --secondary-hover: #6B7280;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --header-h: 72px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

body {
  margin: 0;
  padding-top: var(--header-h);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-secondary);
  background: var(--bg);
  letter-spacing: 0.01em;
  line-height: 1.5;
}

a { color: inherit; }

/* ===== Fixed Header ===== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  box-shadow: var(--shadow);
}

.app-header-inner {
  max-width: 1100px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--primary);
  line-height: 1.1;
}

.brand-sub {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
}

.page-heading {
  min-width: 0;
  text-align: center;
}

.page-title {
  margin: 0;
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-sub {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn:hover {
  background: var(--card-hover);
  border-color: var(--primary);
  color: var(--text);
  transform: translateY(-1px);
}

.icon-btn:active { transform: translateY(0); }

/* Legacy home button — hide if still present */
.home-btn { display: none !important; }

/* ===== Layout ===== */
.page-content,
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Legacy header blocks inside container pages */
.header { display: none; }
.app-title, .app-sub { display: none; }

.container > h1:first-child { display: none; }

/* ===== Home Dashboard ===== */
.home-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.home-welcome {
  margin-bottom: 28px;
}

.home-welcome h1 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  color: var(--text);
}

.home-welcome p {
  margin: 0;
  color: var(--muted);
}

.home-badge {
  display: inline-block;
  margin-left: 10px;
  padding: 2px 8px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--bg);
  background: var(--primary);
  border-radius: 999px;
  vertical-align: middle;
}

.dash-section { margin-bottom: 32px; }
.dash-section:last-child { margin-bottom: 0; }

.dash-section-title {
  margin: 0 0 14px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.dash-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  min-height: 140px;
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.dash-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  background: var(--card-hover);
}

.dash-card:active { transform: translateY(-1px); }

.dash-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
}

.dash-icon svg {
  width: 24px;
  height: 24px;
}

.dash-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.dash-card-desc {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.45;
}

.home-footer {
  margin-top: 40px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Admin / category link lists */
.menu-category-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-category-links .dash-card,
.menu-category-links .home-link {
  min-height: auto;
}

.home-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 700;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.home-link:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  background: var(--card-hover);
}

/* ===== Progress Bar ===== */
.progress-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  opacity: 0.45;
  transition: opacity 0.2s ease;
}

.progress-step.is-active,
.progress-step.is-done { opacity: 1; }

.progress-dot {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--muted);
  transition: all 0.2s ease;
}

.progress-step.is-active .progress-dot {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--bg);
}

.progress-step.is-done .progress-dot {
  border-color: var(--success);
  background: var(--success);
  color: var(--bg);
}

.progress-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-step.is-active .progress-label { color: var(--text); }

/* ===== Forms ===== */
label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin: 16px 0 8px;
  color: var(--text);
}

input, select, textarea {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--bg);
  outline: none;
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder { color: var(--muted); }

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.status {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-error { color: var(--danger); }

/* ===== Buttons ===== */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  color: var(--bg);
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  color: var(--text);
  background: var(--secondary);
  border-color: var(--secondary);
}

.btn-secondary:hover {
  background: var(--secondary-hover);
  transform: translateY(-1px);
}

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

.btn-success:hover {
  background: var(--success-hover);
  transform: translateY(-1px);
}

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

.btn-danger:hover {
  background: var(--danger-hover);
  transform: translateY(-1px);
}

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

.btn-ghost:hover {
  background: var(--bg);
  border-color: var(--muted);
}

.btn-block { width: 100%; }

button:active, .btn:active { transform: translateY(0); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.actions-stack {
  flex-direction: column;
}

.actions-stack .btn,
.actions-stack button { width: 100%; }

/* ===== Summary / Confirm Cards ===== */
.summary-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg);
  margin-bottom: 16px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.summary-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.summary-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  word-break: break-word;
}

.summary-value-pre {
  white-space: pre-line;
  text-align: right;
}

.text-error { color: var(--danger); }

.config-block {
  margin: 12px 0;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  line-height: 1.6;
  white-space: pre-line;
}

/* ===== Result Screens ===== */
.result-screen {
  text-align: center;
  padding: 24px 0;
}

.result-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-icon svg {
  width: 36px;
  height: 36px;
}

.result-icon-success {
  background: var(--success-soft);
  color: var(--success);
}

.result-icon-error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.result-title {
  margin: 0 0 8px;
  font-size: 1.35rem;
  color: var(--text);
}

.result-message {
  margin: 0 0 20px;
  color: var(--muted);
}

/* ===== Combo Dropdown ===== */
.combo-wrap {
  position: relative;
}

.combo-wrap input {
  padding-right: 48px;
}

.combo-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-secondary);
  cursor: pointer;
}

.combo-list {
  position: absolute;
  z-index: 100;
  left: 0;
  right: 0;
  margin-top: 6px;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: var(--shadow);
}

.combo-list[hidden] { display: none; }

.combo-option {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s ease;
}

.combo-option:last-child { border-bottom: none; }
.combo-option:hover,
.combo-option.is-highlight { background: var(--card-hover); }

/* ===== Tables ===== */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  margin-top: 16px;
}

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.table-toolbar input {
  flex: 1 1 220px;
  margin: 0;
}

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

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  color: var(--text);
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.02); }
tbody tr:hover { background: var(--primary-soft); }
tbody tr:last-child td { border-bottom: none; }

td.pre-line { white-space: pre-line; }

/* ===== Camera / Scan ===== */
.scan-card {
  margin: 16px 0;
}

.scan-frame {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  border: 2px solid var(--success);
  background: #000;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-frame video {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.scan-placeholder {
  color: var(--muted);
  padding: 40px;
}

.scan-placeholder svg {
  width: 48px;
  height: 48px;
}

.scan-hint {
  margin: 12px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

video {
  width: 100%;
  max-width: 360px;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #000;
}

/* Bay grid (location assignment) */
.bay-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.bay-grid button {
  min-height: 52px;
}

/* ===== Utilities ===== */
.fade-in {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mt-5 { margin-top: 32px; }
.center { text-align: center; }
.hidden { display: none !important; }

details pre {
  white-space: pre-wrap;
  opacity: 0.75;
  font-size: 0.85em;
  background: var(--bg);
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  :root { --header-h: 64px; }

  .app-header-inner {
    grid-template-columns: auto 1fr auto;
    padding: 0 12px;
    gap: 10px;
  }

  .brand-sub { display: none; }

  .page-sub { display: none; }

  .dash-grid {
    grid-template-columns: 1fr;
  }

  .progress-label { display: none; }

  .summary-row {
    flex-direction: column;
    gap: 4px;
  }

  .summary-value { text-align: left; }
}
