/* AlZham Consignment System - Mobile-first styles */

:root {
  --blue: #1a56db;
  --blue-dark: #1e40af;
  --blue-light: #dbeafe;
  --green: #16a34a;
  --green-light: #dcfce7;
  --red: #dc2626;
  --red-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;
  --gray-900: #111827;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
}

*, *::before, *::after { 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);
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* Header */
.app-header {
  background: var(--blue);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}
.app-header h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: -.02em; }
.app-header .nav-links { display: flex; gap: 4px; }
.app-header .nav-btn {
  background: none; border: none; color: rgba(255,255,255,.75);
  padding: 6px 12px; border-radius: 6px; font-size: .85rem; cursor: pointer;
  transition: all .15s;
}
.app-header .nav-btn.active, .app-header .nav-btn:hover { background: rgba(255,255,255,.15); color: #fff; }

/* Main content */
main { max-width: 560px; margin: 0 auto; padding: 16px; }

/* Cards */
.card {
  background: #fff; border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-title {
  font-size: .9rem; font-weight: 600; color: var(--gray-700);
  margin-bottom: 12px; display: flex; align-items: center; gap: 6px;
}

/* Screens */
.screen { display: none; }
.screen.active { display: block; }

/* Tab panels */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Camera Section */
.camera-container {
  position: relative; width: 100%; border-radius: var(--radius);
  overflow: hidden; background: #000; margin-bottom: 12px;
  aspect-ratio: 4/3;
}
.camera-container video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-container canvas { display: none; }
.camera-preview {
  width: 100%; border-radius: var(--radius); margin-bottom: 12px;
  display: none; max-height: 320px; object-fit: contain; background: #000;
}
.camera-preview.visible { display: block; }
.camera-preview.hidden { display: none; }
.camera-overlay {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px;
}

/* OCR Panel */
.ocr-panel { display: none; margin-bottom: 12px; }
.ocr-panel.active { display: block; }
.ocr-textarea {
  width: 100%; min-height: 120px; padding: 12px; border: 2px solid var(--gray-300);
  border-radius: var(--radius); font-size: .9rem; line-height: 1.5;
  resize: vertical; font-family: inherit; margin-bottom: 8px;
}
.ocr-textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-light); }
.ocr-status {
  font-size: .8rem; color: var(--gray-500); margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border: none; border-radius: 8px; font-size: .9rem;
  font-weight: 600; cursor: pointer; transition: all .15s;
  font-family: inherit; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-outline {
  background: #fff; color: var(--gray-700); border: 2px solid var(--gray-300);
}
.btn-outline:hover { border-color: var(--gray-400); background: var(--gray-50); }
.btn-sm { padding: 6px 12px; font-size: .8rem; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: .8rem; font-weight: 600; color: var(--gray-600);
  margin-bottom: 4px;
}
.form-label .required { color: var(--red); margin-left: 2px; }
.form-input, .form-select {
  width: 100%; padding: 10px 12px; border: 2px solid var(--gray-300);
  border-radius: 8px; font-size: .9rem; font-family: inherit;
  background: #fff; color: var(--gray-800); transition: border-color .15s;
  -webkit-appearance: none; appearance: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-light);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-input.error, .form-select.error { border-color: var(--red); background: #fef2f2; }
.form-hint { font-size: .75rem; color: var(--gray-400); margin-top: 2px; }
.form-error { font-size: .75rem; color: var(--red); margin-top: 2px; display: none; }
.form-error.visible { display: block; }

/* Result Card */
.result-card { text-align: center; padding: 24px 16px; }
.result-icon { font-size: 3rem; margin-bottom: 8px; }
.result-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.result-subtitle { color: var(--gray-500); font-size: .85rem; margin-bottom: 16px; }
.result-tracking {
  background: var(--blue-light); color: var(--blue-dark); padding: 8px 16px;
  border-radius: 8px; font-size: 1.1rem; font-weight: 700; margin-bottom: 16px;
  display: inline-block; letter-spacing: .02em;
}

/* History list */
.history-list { list-style: none; }
.history-item {
  padding: 14px 16px; border-bottom: 1px solid var(--gray-200);
  cursor: pointer; transition: background .15s;
}
.history-item:hover { background: var(--gray-50); }
.history-item:last-child { border-bottom: none; }
.history-top {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
}
.history-name { font-weight: 600; font-size: .9rem; }
.history-date { font-size: .75rem; color: var(--gray-400); white-space: nowrap; }
.history-addr { font-size: .8rem; color: var(--gray-500); margin-top: 2px; }
.history-tracking { font-size: .8rem; color: var(--blue); margin-top: 4px; font-weight: 600; }

/* Empty state */
.empty-state {
  text-align: center; padding: 40px 16px; color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 8px; }
.empty-state p { font-size: .9rem; }

/* Toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--gray-800); color: #fff; padding: 12px 24px;
  border-radius: 8px; font-size: .85rem; z-index: 999;
  box-shadow: var(--shadow-lg); transition: opacity .3s, transform .3s; pointer-events: none;
}
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(20px); }

/* Loading spinner */
.spinner {
  display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-dark { border-color: rgba(0,0,0,.1); border-top-color: var(--blue); }

/* Tabs */
.tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 2px solid var(--gray-200); }
.tab-btn {
  flex: 1; padding: 10px; text-align: center; background: none; border: none;
  border-bottom: 2px solid transparent; font-size: .85rem; font-weight: 600;
  color: var(--gray-500); cursor: pointer; margin-bottom: -2px; font-family: inherit;
  transition: all .15s;
}
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }

/* PDF viewer modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.active { display: flex; }
.modal-content {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 560px;
  max-height: 90dvh; overflow: auto; box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 { font-size: 1rem; }
.modal-body { padding: 16px; }
.modal-body embed { width: 100%; height: 70dvh; border: none; }

/* Utility */
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.text-center { text-align: center; }
.text-sm { font-size: .8rem; }
.text-gray { color: var(--gray-500); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.font-bold { font-weight: 700; }
