/**
 * G2 Logistics Driver App
 * Professional Utility Design System
 * Clean, functional, trustworthy
 */

/* ═══════════════════════════════════════════════════════════════
   FONTS
   ═══════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

/* ═══════════════════════════════════════════════════════════════
   CSS VARIABLES
   ═══════════════════════════════════════════════════════════════ */
:root {
  /* Brand */
  --g2-orange: #F97316;
  --g2-orange-hover: #EA580C;
  --g2-orange-light: rgba(249, 115, 22, 0.1);

  /* Backgrounds */
  --bg-page: #F8F9FA;
  --bg-white: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-muted: #F3F4F6;

  /* Text */
  --text-primary: #1A1A1A;
  --text-secondary: #4B5563;
  --text-muted: #9CA3AF;
  --text-white: #FFFFFF;

  /* Borders */
  --border-color: #E5E7EB;
  --border-light: #F3F4F6;

  /* Status */
  --success: #10B981;
  --success-light: rgba(16, 185, 129, 0.1);
  --warning: #F59E0B;
  --warning-light: rgba(245, 158, 11, 0.1);
  --danger: #EF4444;
  --danger-light: rgba(239, 68, 68, 0.1);
  --info: #3B82F6;
  --info-light: rgba(59, 130, 246, 0.1);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);

  /* Tab bar height */
  --tab-bar-height: 64px;
  --header-height: 56px;
}

/* ═══════════════════════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-page);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* App container with tab bar */
body.has-tabs {
  padding-bottom: var(--tab-bar-height);
}

body.has-header {
  padding-top: var(--header-height);
}

a {
  color: var(--g2-orange);
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
}

/* ═══════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════ */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  z-index: 100;
}

.header-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-logo {
  height: 28px;
}

.header-action {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.header-action:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════
   BOTTOM TAB BAR
   ═══════════════════════════════════════════════════════════════ */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tab-bar-height);
  background: var(--bg-white);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: stretch;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  transition: color 0.15s;
  position: relative;
}

.tab-item svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.75;
}

.tab-item.active {
  color: var(--g2-orange);
}

.tab-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  background: var(--g2-orange);
  border-radius: 0 0 3px 3px;
}

/* Badge on tab */
.tab-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 20px);
  min-width: 18px;
  height: 18px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ═══════════════════════════════════════════════════════════════
   PAGE CONTENT
   ═══════════════════════════════════════════════════════════════ */
.page-content {
  padding: var(--space-md);
  max-width: 600px;
  margin: 0 auto;
}

.page-content--full {
  max-width: none;
}

.page-section {
  margin-bottom: var(--space-lg);
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-sm);
  padding: 0 var(--space-xs);
}

/* ═══════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.card-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: var(--space-md);
}

.card-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--border-light);
  background: var(--bg-muted);
}

/* ═══════════════════════════════════════════════════════════════
   FORM ELEMENTS
   ═══════════════════════════════════════════════════════════════ */
.form-group {
  margin-bottom: var(--space-md);
}

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

.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-input,
.form-select {
  width: 100%;
  height: 48px;
  padding: 0 var(--space-md);
  font-family: inherit;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--g2-orange);
  box-shadow: 0 0 0 3px var(--g2-orange-light);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 44px;
}

.form-textarea {
  width: 100%;
  min-height: 100px;
  padding: var(--space-md);
  font-family: inherit;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--g2-orange);
  box-shadow: 0 0 0 3px var(--g2-orange-light);
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  height: 48px;
  padding: 0 var(--space-lg);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--g2-orange-hover);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border-color);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-muted);
  border-color: var(--text-muted);
}

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

.btn-danger:hover:not(:disabled) {
  background: #DC2626;
}

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

.btn-success:hover:not(:disabled) {
  background: #059669;
}

.btn-block {
  width: 100%;
}

.btn-lg {
  height: 56px;
  font-size: 16px;
}

.btn-sm {
  height: 36px;
  padding: 0 var(--space-md);
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════════
   STATUS BADGES
   ═══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-light);
  color: #B45309;
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-info {
  background: var(--info-light);
  color: var(--info);
}

.badge-muted {
  background: var(--bg-muted);
  color: var(--text-secondary);
}

.badge-orange {
  background: var(--g2-orange-light);
  color: var(--g2-orange);
}

/* ═══════════════════════════════════════════════════════════════
   JOB CARDS
   ═══════════════════════════════════════════════════════════════ */
.job-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.job-card:active {
  background: var(--bg-muted);
}

.job-card--active {
  border-color: var(--g2-orange);
  border-width: 2px;
}

.job-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.job-card__vehicle {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.job-card__reg {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
}

.job-card__route {
  display: flex;
  gap: var(--space-md);
  margin: var(--space-md) 0;
}

.job-card__point {
  flex: 1;
  position: relative;
  padding-left: 20px;
}

.job-card__point::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-color);
}

.job-card__point--from::before {
  background: var(--g2-orange);
}

.job-card__point--to::before {
  background: var(--success);
}

.job-card__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.job-card__address {
  font-size: 14px;
  color: var(--text-primary);
  margin-top: 2px;
}

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

.job-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-light);
}

.job-card__id {
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
}

/* ═══════════════════════════════════════════════════════════════
   CHECK ITEMS
   ═══════════════════════════════════════════════════════════════ */
.check-list {
  list-style: none;
}

.check-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
}

.check-item:last-child {
  border-bottom: none;
}

.check-item__text {
  font-size: 15px;
  color: var(--text-primary);
  flex: 1;
}

.check-item__actions {
  display: flex;
  gap: var(--space-sm);
}

.check-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  background: var(--bg-white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.check-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.5;
}

.check-btn--pass {
  color: var(--text-muted);
}

.check-btn--pass.active,
.check-btn--pass:hover {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.check-btn--fail {
  color: var(--text-muted);
}

.check-btn--fail.active,
.check-btn--fail:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

/* ═══════════════════════════════════════════════════════════════
   SIGNATURE PAD
   ═══════════════════════════════════════════════════════════════ */
.signature-area {
  background: var(--bg-white);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.signature-area canvas {
  width: 100%;
  height: 150px;
  touch-action: none;
}

.signature-area__placeholder {
  color: var(--text-muted);
  font-size: 14px;
  position: absolute;
  pointer-events: none;
}

.signature-area.has-signature .signature-area__placeholder {
  display: none;
}

.signature-clear {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg-muted);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ═══════════════════════════════════════════════════════════════
   LIST ITEMS
   ═══════════════════════════════════════════════════════════════ */
.list-item {
  display: flex;
  align-items: center;
  padding: var(--space-md);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
}

.list-item:first-child {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.list-item:last-child {
  border-bottom: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.list-item:only-child {
  border-radius: var(--radius-lg);
}

.list-item__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  margin-right: var(--space-md);
  flex-shrink: 0;
}

.list-item__content {
  flex: 1;
  min-width: 0;
}

.list-item__title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.list-item__subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.list-item__arrow {
  color: var(--text-muted);
  margin-left: var(--space-sm);
}

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATES
   ═══════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
}

.empty-state__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-md);
  background: var(--bg-muted);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.empty-state__title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.empty-state__text {
  font-size: 14px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════
   LOADING
   ═══════════════════════════════════════════════════════════════ */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-color);
  border-top-color: var(--g2-orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  z-index: 1000;
}

.loading-text {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-white);
}

.login-header {
  padding: var(--space-xl) var(--space-md);
  text-align: center;
}

.login-logo {
  height: 48px;
  margin-bottom: var(--space-md);
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.login-form {
  flex: 1;
  padding: var(--space-md) var(--space-lg);
}

.login-footer {
  padding: var(--space-md);
  text-align: center;
}

.login-footer__text {
  font-size: 12px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════
   VEHICLE SELECTION
   ═══════════════════════════════════════════════════════════════ */
.vehicle-preview {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--g2-orange-light);
  border-radius: var(--radius-md);
  margin-top: var(--space-md);
}

.vehicle-preview__icon {
  width: 48px;
  height: 48px;
  background: var(--g2-orange);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.vehicle-preview__info {
  flex: 1;
}

.vehicle-preview__reg {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

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

/* ═══════════════════════════════════════════════════════════════
   JOB PREVIEW (on vehicle selection page)
   ═══════════════════════════════════════════════════════════════ */
.jobs-preview {
  margin-top: var(--space-lg);
}

.jobs-preview__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.jobs-preview__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.job-preview-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
}

.job-preview-item__route {
  flex: 1;
}

.job-preview-item__route span {
  color: var(--text-muted);
}

.job-preview-item__time {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   PROFILE PAGE
   ═══════════════════════════════════════════════════════════════ */
.profile-header {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--g2-orange-light);
  color: var(--g2-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  margin: 0 auto var(--space-md);
}

.profile-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.profile-email {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.profile-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--space-sm);
  font-size: 13px;
  font-weight: 500;
}

.profile-status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.profile-status--on .profile-status__dot {
  background: var(--success);
}

.profile-status--off .profile-status__dot {
  background: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════
   MESSAGES (PLACEHOLDER)
   ═══════════════════════════════════════════════════════════════ */
.messages-placeholder {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

/* ═══════════════════════════════════════════════════════════════
   ALERTS / TOASTS
   ═══════════════════════════════════════════════════════════════ */
.alert {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}

.alert-success {
  background: var(--success-light);
  border: 1px solid var(--success);
  color: #065F46;
}

.alert-warning {
  background: var(--warning-light);
  border: 1px solid var(--warning);
  color: #92400E;
}

.alert-danger {
  background: var(--danger-light);
  border: 1px solid var(--danger);
  color: #991B1B;
}

.alert-info {
  background: var(--info-light);
  border: 1px solid var(--info);
  color: #1E40AF;
}

/* ═══════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════ */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 13px; }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.hidden { display: none !important; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
