/* ============================================================
   Wilsons Systems — Employee App
   Dark theme, mobile-first, large tap targets
   ============================================================ */

:root {
  --bg:        #141414;
  --surface:   #1f1f1f;
  --surface2:  #2a2a2a;
  --border:    #333;
  --red:       #e63946;
  --red-dark:  #b02a34;
  --text:      #f0f0f0;
  --muted:     #888;
  --success:   #2ecc71;
  --warning:   #f39c12;
  --radius:    10px;
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---- Layout ---- */
.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
header h1 { font-size: 18px; font-weight: 700; flex: 1; }
.logo { color: var(--red); font-weight: 900; font-size: 20px; letter-spacing: -0.5px; }

main { flex: 1; padding: 16px; overflow-y: auto; }

/* ---- Back button ---- */
.btn-back {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 4px;
}
.card-value { font-size: 15px; }

/* ---- Buttons ---- */
.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--red); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-success { background: var(--success); color: #fff; }
.btn + .btn { margin-top: 10px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- Inputs ---- */
input, select, textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  font-family: var(--font);
  padding: 12px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--red); }
select option { background: var(--surface2); }
textarea { resize: vertical; min-height: 180px; }

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  margin-top: 14px;
}
label:first-child { margin-top: 0; }

/* ---- Login screen ---- */
.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  gap: 20px;
}
.login-logo { font-size: 28px; font-weight: 900; color: var(--red); letter-spacing: -1px; }
.login-sub { color: var(--muted); font-size: 14px; margin-top: -12px; }
.login-form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }

/* PIN pad */
.pin-display {
  text-align: center;
  font-size: 32px;
  letter-spacing: 12px;
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 60px;
  line-height: 1.2;
}
.pin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.pin-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  padding: 18px;
  cursor: pointer;
  transition: background 0.1s;
}
.pin-btn:active { background: var(--border); }
.pin-btn.delete { font-size: 18px; color: var(--muted); }

/* ---- Search ---- */
.search-box {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.search-box input { flex: 1; }
.search-box button {
  background: var(--red);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 18px;
  padding: 0 16px;
  cursor: pointer;
}

.result-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.result-item:active { border-color: var(--red); }
.result-name { font-weight: 600; font-size: 15px; }
.result-meta { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* ---- Job detail ---- */
.job-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 20px 0 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.labour-item, .stock-item {
  font-size: 14px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.labour-item:last-child, .stock-item:last-child { border-bottom: none; }
.empty-note { color: var(--muted); font-size: 14px; font-style: italic; }

/* ---- Description card (job detail tap-to-edit) ---- */
.desc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  transition: border-color 0.15s;
}
.desc-card:active { border-color: var(--red); }
.desc-card-text {
  font-size: 14px;
  line-height: 1.6;
  flex: 1;
  white-space: pre-wrap;   /* preserve line breaks from plain text */
  word-break: break-word;
}
.desc-card-hint {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  padding-top: 2px;
}

/* ---- Description editor ---- */
.preview-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 10px;
  min-height: 120px;
}
.toggle-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.toggle-row button {
  flex: 1;
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}
.toggle-row button.active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--red);
}

/* ---- Parts matching ---- */
.part-match {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
}
.part-match-name { font-weight: 600; font-size: 14px; }
.part-match-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.part-match-actions { display: flex; gap: 8px; margin-top: 10px; }
.part-match-actions button {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.part-match-actions button.confirmed { background: var(--success); border-color: var(--success); color: #fff; }
.part-match-actions button.rejected { background: var(--surface2); color: var(--muted); }

/* ---- Toast notifications ---- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 14px;
  white-space: nowrap;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
#toast.show { opacity: 1; }
#toast.success { border-color: var(--success); color: var(--success); }
#toast.error { border-color: var(--red); color: var(--red); }

/* ---- Loading spinner ---- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Hours quick-select ---- */
.hours-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.hours-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 6px;
  cursor: pointer;
  text-align: center;
}
.hours-btn.selected { background: var(--red); border-color: var(--red); color: #fff; }

/* ---- Utility ---- */
.mt { margin-top: 14px; }
.text-muted { color: var(--muted); font-size: 13px; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-complete { background: #1a3a2a; color: var(--success); }
.badge-progress { background: #2a2a1a; color: var(--warning); }
