/* Stewart Industrial — Service Operations Webapp
   Mobile-first. Single stylesheet.
   Colors from HOM_Document_Design_System.md */

:root {
  --primary-blue: #2196F3;
  --accent-red: #B91C1C;
  --dark-bg: #0A0A0A;
  --light-gray: #F5F5F5;
  --border-gray: #CCCCCC;
  --white: #FFFFFF;
  --text-dark: #1A1A1A;
  --text-muted: #666666;
  --status-complete: #16A34A;
  --status-blocked: #B91C1C;
  --status-progress: #2196F3;
  --status-pending: #666666;
  --status-waiting: #D97706;
}

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

body {
  font-family: 'Inter', 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--light-gray);
  color: var(--text-dark);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---- HEADER ---- */
.app-header {
  background: var(--dark-bg);
  color: var(--white);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.app-header .user-badge {
  font-size: 13px;
  background: var(--primary-blue);
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 500;
}

/* ---- NAV BAR ---- */
.nav-bar {
  background: var(--white);
  border-bottom: 1px solid var(--border-gray);
  display: flex;
  overflow-x: auto;
  padding: 0;
}

.nav-bar a {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  min-width: 70px;
}

.nav-bar a.active {
  color: var(--primary-blue);
  border-bottom-color: var(--primary-blue);
  font-weight: 600;
}

/* ---- MAIN CONTENT ---- */
.main-content {
  padding: 16px;
  max-width: 800px;
  margin: 0 auto;
}

/* ---- CARDS ---- */
.card {
  background: var(--white);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- STATUS BADGES ---- */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-INTAKE { background: #DBEAFE; color: #1E40AF; }
.status-JOB_OPEN { background: #FEF3C7; color: #92400E; }
.status-PARTS_IN { background: #FDE68A; color: #78350F; }
.status-WORK_START { background: #BFDBFE; color: #1E3A8A; }
.status-WORK_COMPLETE { background: #D1FAE5; color: #065F46; }
.status-QC_APPROVED { background: #A7F3D0; color: #064E3B; }
.status-RELEASED { background: #D1D5DB; color: #374151; }

/* ---- FORMS ---- */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-gray);
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  background: var(--white);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  width: 100%;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary-blue);
  color: var(--white);
}

.btn-primary:hover { background: #1976D2; }
.btn-primary:disabled { background: #90CAF9; cursor: not-allowed; }

.btn-danger {
  background: var(--accent-red);
  color: var(--white);
}

.btn-secondary {
  background: var(--white);
  color: var(--text-dark);
  border: 1px solid var(--border-gray);
}

/* ---- SCANNER ---- */
.scanner-container {
  background: var(--dark-bg);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
  position: relative;
  aspect-ratio: 1;
  max-height: 400px;
}

.scanner-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  border: 3px solid var(--primary-blue);
  border-radius: 12px;
  pointer-events: none;
}

.scan-result {
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-weight: 500;
}

.scan-result.accepted {
  background: #D1FAE5;
  color: #065F46;
  border-left: 4px solid var(--status-complete);
}

.scan-result.rejected {
  background: #FEE2E2;
  color: #991B1B;
  border-left: 4px solid var(--accent-red);
}

/* ---- DASHBOARD ---- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--white);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary-blue);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.job-list {
  list-style: none;
}

.job-item {
  background: var(--white);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
}

.job-item:hover {
  border-left: 3px solid var(--primary-blue);
}

.job-info h3 {
  font-size: 15px;
  font-weight: 600;
}

.job-info p {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- TABLES ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  background: var(--primary-blue);
  color: var(--white);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-gray);
}

.data-table tr:nth-child(even) {
  background: var(--light-gray);
}

/* ---- ALERTS / NOTIFICATIONS ---- */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 14px;
}

.alert-info { background: #DBEAFE; color: #1E40AF; }
.alert-success { background: #D1FAE5; color: #065F46; }
.alert-warning { background: #FEF3C7; color: #92400E; }
.alert-error { background: #FEE2E2; color: #991B1B; }

/* ---- LOGIN ---- */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--dark-bg);
}

.login-box {
  background: var(--white);
  border-radius: 12px;
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-box h1 {
  font-size: 20px;
  margin-bottom: 8px;
}

.login-box p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.pin-input {
  letter-spacing: 12px;
  font-size: 24px;
  text-align: center;
  font-weight: 700;
}

/* ---- LOADING ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-gray);
  border-top-color: var(--primary-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-dark);
}

/* ---- STATUS SHARE (read-only customer page) ---- */
.status-share {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px;
}

.status-share .company-header {
  text-align: center;
  margin-bottom: 24px;
}

.status-timeline {
  position: relative;
  padding-left: 28px;
}

.timeline-item {
  position: relative;
  padding-bottom: 24px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -22px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border-gray);
}

.timeline-item.complete::before {
  background: var(--status-complete);
}

.timeline-item.current::before {
  background: var(--primary-blue);
  box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.2);
}

.timeline-item::after {
  content: '';
  position: absolute;
  left: -17px;
  top: 18px;
  width: 2px;
  height: calc(100% - 14px);
  background: var(--border-gray);
}

.timeline-item:last-child::after {
  display: none;
}

/* ---- RESPONSIVE ---- */
@media (min-width: 600px) {
  .main-content { padding: 24px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .form-row { grid-template-columns: 1fr 1fr 1fr; }
}
