/* ============================================
   AMORN SERVICE PHOTO - PWA STYLESHEET
   Mobile-first responsive design
   ============================================ */

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --success: #0d9488;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ── App Shell ── */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--gray-50);
}

/* ── Header ── */
.header {
  background: var(--primary);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

.header-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-btn:active { background: rgba(255,255,255,0.3); }

/* ── Cards ── */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  margin: 12px 16px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--gray-700);
}

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

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

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

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

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

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

.btn-outline {
  background: white;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  width: auto;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Form Elements ── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  font-size: 15px;
  transition: border-color 0.2s;
  background: white;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-input-lg {
  width: 100%;
  padding: 20px 24px;
  border: 3px solid var(--gray-300);
  border-radius: 12px;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
  transition: border-color 0.2s;
  background: white;
}

.form-input-lg:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.form-input-lg::placeholder {
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

/* ── Login Screen ── */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  background: linear-gradient(135deg, var(--primary) 0%, #4285f4 100%);
}

.login-logo {
  font-size: 48px;
  margin-bottom: 8px;
}

.login-title {
  color: white;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

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

.login-card {
  background: white;
  border-radius: 16px;
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
}

.login-card .form-group:last-of-type {
  margin-bottom: 24px;
}

.login-error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

/* ── Home Screen ── */
.home-content { padding: 16px; }

.user-info-bar {
  background: white;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
}

.user-details { flex: 1; }
.user-details .name { font-weight: 600; font-size: 16px; }
.user-details .role {
  font-size: 12px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.menu-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.menu-card:active {
  transform: scale(0.97);
  border-color: var(--primary);
}

.menu-card .icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.menu-card .label {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
}

.menu-card .desc {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ── Receive Screen (2-step entry) ── */
.receive-step1 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 40px 24px;
}

.receive-step1 .icon-big {
  font-size: 64px;
  margin-bottom: 16px;
}

.receive-step1 h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.receive-step1 p {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 32px;
}

.receive-input-wrapper {
  width: 100%;
  max-width: 320px;
  margin-bottom: 20px;
}

.receive-job-banner {
  background: linear-gradient(135deg, var(--primary) 0%, #4285f4 100%);
  color: white;
  padding: 20px;
  margin: 0 16px 12px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 16px;
}

.receive-job-banner .job-num {
  font-size: 24px;
  font-weight: 700;
}

.receive-job-banner .job-info {
  font-size: 13px;
  opacity: 0.85;
  margin-top: 4px;
}

.receive-job-banner .change-btn {
  margin-left: auto;
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.receive-job-banner .change-btn:active {
  background: rgba(255,255,255,0.3);
}

/* ── Photo Capture Section ── */
.photo-section {
  padding: 0 16px 16px;
}

.photo-capture-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  background: white;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.photo-capture-area:active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.photo-capture-area .cam-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.photo-capture-area .cam-text {
  font-size: 14px;
  color: var(--gray-500);
}

.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.photo-preview-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
}

.photo-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}

.photo-preview-item .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.batch-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--primary-light);
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--primary);
}

/* ── Job List Screen ── */
.job-list-content { padding: 12px 16px; }

.quick-lookup-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.quick-lookup-card .label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.quick-lookup-row {
  display: flex;
  gap: 8px;
}

.quick-lookup-row input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  font-size: 15px;
  text-transform: uppercase;
}

.quick-lookup-row input:focus {
  outline: none;
  border-color: var(--primary);
}

.quick-lookup-row button {
  padding: 10px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.stats-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.stat-chip {
  background: white;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-chip .count {
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  background: white;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
}

.filter-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-tab {
  padding: 8px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--gray-200);
  background: white;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  color: var(--gray-600);
  transition: all 0.2s;
}

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

/* ── Job Cards ── */
.job-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
  border-left: 4px solid var(--gray-300);
}

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

.job-card.no-photo {
  border-left-color: var(--warning);
  background: #fffbeb;
}

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

.job-card .job-number {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
}

.job-card .job-detail {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 4px;
}

.job-card .job-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.job-card .photo-badge {
  font-size: 12px;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  gap: 4px;
}

.job-card .photo-badge.none { color: var(--warning); font-weight: 600; }

/* ── Status Pills ── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.status-received { background: #dbeafe; color: #1d4ed8; }
.status-repairing { background: #fef3c7; color: #92400e; }
.status-waiting-parts { background: #fce7f3; color: #9d174d; }
.status-waiting-customer { background: #ede9fe; color: #6d28d9; }
.status-completed { background: #d1fae5; color: #065f46; }

/* ── Job Detail Screen ── */
.job-detail-content { padding: 0 16px 100px; }

.job-info-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}

.job-info-card .job-number-lg {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
}

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

.info-item .label {
  font-size: 11px;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.info-item .value {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
}

/* ── Status Buttons ── */
.status-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.status-btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 2px solid var(--gray-200);
  background: white;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
  min-width: calc(50% - 4px);
  text-align: center;
}

.status-btn:active { transform: scale(0.97); }
.status-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* ── Photo Rounds ── */
.round-section {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}

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

.round-badge {
  background: var(--primary-light);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.round-date {
  font-size: 12px;
  color: var(--gray-400);
}

.round-bar {
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  margin-bottom: 12px;
  overflow: hidden;
}

.round-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s;
}

/* ── Timeline ── */
.timeline {
  padding: 0 4px;
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding-bottom: 16px;
  position: relative;
}

.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}

.timeline-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.timeline-content {
  flex: 1;
}

.timeline-status {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}

.timeline-meta {
  font-size: 12px;
  color: var(--gray-400);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-800);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.3s;
  text-align: center;
  max-width: 90%;
}

.toast.hidden { opacity: 0; pointer-events: none; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ── Lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox.hidden { display: none; }

.lightbox img {
  max-width: 95%;
  max-height: 90vh;
  border-radius: 8px;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
}

/* ── Loading Overlay ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.loading-overlay.hidden { display: none; }

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

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

.loading-overlay p {
  font-size: 14px;
  color: var(--gray-500);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .title { font-size: 16px; font-weight: 600; margin-bottom: 4px; color: var(--gray-500); }
.empty-state .desc { font-size: 13px; }

/* ── Utility ── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── Responsive ── */
@media (min-width: 481px) {
  #app {
    border-left: 1px solid var(--gray-200);
    border-right: 1px solid var(--gray-200);
  }
}
