/* CSS Variables */
:root {
  --primary: #007AFF;
  --primary-dark: #0056b3;
  --success: #34C759;
  --warning: #FF9500;
  --danger: #FF3B30;
  --purple: #AF52DE;
  --indigo: #5856D6;
  --gray: #8E8E93;
  --gray-light: #C7C7CC;
  --background: #F2F2F7;
  --card-background: #FFFFFF;
  --text-primary: #000000;
  --text-secondary: #6C6C70;
  --border-color: #E5E5EA;
  --nav-height: 83px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  background: var(--background);
  color: var(--text-primary);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom));
  -webkit-font-smoothing: antialiased;
}

/* App Container */
#app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
}

/* Loading Spinner */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 50vh;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

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

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--card-background);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding-top: 8px;
  padding-bottom: var(--safe-area-bottom);
  z-index: 1000;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--gray);
  font-size: 10px;
  padding: 4px 16px;
  transition: color 0.2s;
}

.nav-item.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 24px;
  margin-bottom: 2px;
}

.nav-label {
  font-weight: 500;
}

/* Header */
.header {
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  background: var(--card-background);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 28px;
  font-weight: 700;
}

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

/* Stats Cards */
.stats-container {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.stat-card {
  flex-shrink: 0;
  background: var(--card-background);
  padding: 12px 16px;
  border-radius: 12px;
  min-width: 80px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stat-count {
  font-size: 24px;
  font-weight: 700;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Filter Chips */
.filter-container {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.filter-chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 20px;
  border: none;
  background: var(--gray-light);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-chip.active {
  background: var(--primary);
  color: white;
}

.filter-chip .badge {
  display: inline-block;
  background: var(--danger);
  color: white;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 4px;
}

/* Search Bar */
.search-container {
  padding: 0 16px 12px;
}

.search-input {
  width: 100%;
  padding: 12px 16px;
  padding-left: 40px;
  border: none;
  border-radius: 10px;
  background: var(--card-background);
  font-size: 16px;
  outline: none;
}

.search-input::placeholder {
  color: var(--gray);
}

/* Job Cards */
.job-list {
  padding: 0 16px 16px;
}

.job-card {
  background: var(--card-background);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.job-card:active {
  transform: scale(0.98);
}

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

.job-address {
  font-size: 17px;
  font-weight: 600;
}

.job-aka {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.job-owner {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.job-time {
  font-size: 12px;
  color: var(--gray);
  margin-top: 8px;
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-CLIENT_PENDING { background: #E5E5EA; color: #636366; }
.status-INTAKE_RECEIVED { background: #FFE5CC; color: #CC5500; }
.status-SCHEDULED { background: #CCE5FF; color: #0055CC; }
.status-INSPECTED { background: #CCF2FF; color: #007799; }
.status-LAB_PENDING { background: #FFF5CC; color: #997A00; }
.status-READY_TO_FILE { background: #D4EDDA; color: #155724; }
.status-DRAFTED { background: #E8DAEF; color: #6B2D87; }
.status-SUBMITTED { background: #D6D6F5; color: #3D3D99; }
.status-COMPLETED { background: #E5E5EA; color: #636366; }
.status-CLIENT_UPDATED { background: #FFD6D6; color: #CC0000; }
.status-ERROR { background: #FFD6D6; color: #CC0000; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  border: none;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn:active {
  transform: scale(0.98);
}

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

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

.btn-secondary {
  background: var(--gray-light);
  color: var(--text-primary);
}

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

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.form-input, .form-select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 17px;
  background: var(--card-background);
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus {
  border-color: var(--primary);
}

/* Detail View */
.detail-header {
  background: var(--card-background);
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.detail-title {
  font-size: 22px;
  font-weight: 700;
}

.detail-subtitle {
  font-size: 17px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.detail-section {
  background: var(--card-background);
  margin: 16px;
  border-radius: 12px;
  overflow: hidden;
}

.detail-section-header {
  padding: 12px 16px;
  background: var(--background);
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.detail-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
}

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

.detail-label {
  color: var(--text-secondary);
}

.detail-value {
  font-weight: 500;
  text-align: right;
  max-width: 60%;
}

/* Review Queue */
.review-progress {
  padding: 16px;
  background: var(--card-background);
  border-bottom: 1px solid var(--border-color);
}

.progress-bar {
  height: 6px;
  background: var(--gray-light);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s;
}

.progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text-secondary);
}

.review-card {
  background: var(--card-background);
  margin: 16px;
  border-radius: 12px;
  padding: 20px;
}

.review-actions {
  display: flex;
  gap: 12px;
  padding: 16px;
}

.review-actions .btn {
  flex: 1;
}

/* Material Toggle */
.material-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.material-info {
  flex: 1;
}

.material-name {
  font-weight: 500;
}

.material-samples {
  font-size: 13px;
  color: var(--text-secondary);
}

.toggle-group {
  display: flex;
  gap: 8px;
}

.toggle-btn {
  padding: 6px 16px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn.active-no {
  border-color: var(--success);
  background: var(--success);
  color: white;
}

.toggle-btn.active-yes {
  border-color: var(--danger);
  background: var(--danger);
  color: white;
}

/* Back Button */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 17px;
  cursor: pointer;
  padding: 8px 0;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 20px + var(--safe-area-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 15px;
  z-index: 2000;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Responsive */
@media (min-width: 768px) {
  .job-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .job-card {
    margin-bottom: 0;
  }
}

/* Login Page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  margin-bottom: 32px;
  color: white;
}

.login-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.login-logo h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 16px;
  opacity: 0.9;
}

.login-card {
  background: var(--card-background);
  border-radius: 20px;
  padding: 32px 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-card h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.login-card > p {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 24px;
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 24px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: white;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.google-btn:hover {
  background: #f8f8f8;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.google-btn:active {
  transform: scale(0.98);
}

.google-icon {
  flex-shrink: 0;
}

.login-note {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.login-footer {
  margin-top: 32px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
}

.login-footer .version {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 4px;
}
