/* === Waterloo SECURE Logistics — Shared Design System === */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:wght@400;500;600&display=swap');

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

:root {
  --burnt-orange: #BF5700;
  --burnt-orange-dark: #8f4000;
  --burnt-orange-light: #d96b00;
  --dark-brown: #382E2D;
  --dark-brown-mid: #4a3c3a;
  --dark-brown-light: #5c4e4c;
  --gold: #C09600;
  --gold-light: #d4a500;
  --white: #f4f4f2;
  --gray: #8a8482;
  --black: #000000;
  --red: #c0392b;
  --green: #27ae60;
  --blue: #2980b9;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--dark-brown);
  color: var(--white);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
}

a { color: var(--burnt-orange); text-decoration: none; }
a:hover { color: var(--burnt-orange-light); }

/* === APP HEADER === */
.app-header {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 100;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(56, 46, 45, 0.95);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(192, 150, 0, 0.15);
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--white);
}

.app-logo-icon {
  width: 32px;
  height: 32px;
  border: 2px solid var(--burnt-orange);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--burnt-orange);
}

.app-logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-logo-text span { color: var(--burnt-orange); }

.app-nav {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.app-nav a {
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gray);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: all 0.2s;
}

.app-nav a:hover {
  color: var(--white);
  background: rgba(191, 87, 0, 0.15);
}

.app-nav a.active {
  color: var(--burnt-orange);
  background: rgba(191, 87, 0, 0.1);
}

/* === MAIN CONTENT === */
.app-main {
  padding: 6rem 2rem 3rem;
  max-width: 1000px;
  margin: 0 auto;
}

.page-title {
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--burnt-orange);
  margin-bottom: 0.75rem;
}

.page-heading {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 600;
  margin-bottom: 2rem;
  line-height: 1.2;
}

/* === FORMS === */
.form-section {
  background: var(--dark-brown-mid);
  border: 1px solid rgba(192, 150, 0, 0.12);
  border-radius: 6px;
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.form-section-title {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(192, 150, 0, 0.12);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-row.full {
  grid-template-columns: 1fr;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: var(--gray);
  text-transform: uppercase;
}

.form-group label .required {
  color: var(--burnt-orange);
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--dark-brown);
  border: 1px solid rgba(192, 150, 0, 0.2);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--burnt-orange);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--dark-brown-light);
}

.form-group select option {
  background: var(--dark-brown);
  color: var(--white);
}

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

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 2rem;
  border: none;
  border-radius: 4px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background: var(--burnt-orange-light);
}

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

.btn-secondary {
  background: transparent;
  color: var(--gold);
  border: 1px solid rgba(192, 150, 0, 0.4);
}

.btn-secondary:hover {
  background: rgba(192, 150, 0, 0.1);
}

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

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
}

/* === CARDS === */
.card {
  background: var(--dark-brown-mid);
  border: 1px solid rgba(192, 150, 0, 0.12);
  border-radius: 6px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  transition: border-color 0.2s;
}

.card:hover {
  border-color: rgba(192, 150, 0, 0.3);
}

/* === STATUS BADGES === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.3rem 0.75rem;
  border-radius: 3px;
  font-weight: 600;
}

.badge-requested { background: rgba(41, 128, 185, 0.2); color: #5dade2; }
.badge-confirmed { background: rgba(192, 150, 0, 0.2); color: var(--gold-light); }
.badge-dispatched { background: rgba(191, 87, 0, 0.2); color: var(--burnt-orange-light); }
.badge-picked_up { background: rgba(191, 87, 0, 0.3); color: var(--burnt-orange-light); }
.badge-in_transit { background: rgba(191, 87, 0, 0.2); color: var(--burnt-orange-light); }
.badge-delivered { background: rgba(39, 174, 96, 0.2); color: #58d68d; }
.badge-cancelled { background: rgba(192, 57, 43, 0.2); color: #e74c3c; }

.badge-critical { background: rgba(192, 57, 43, 0.25); color: #e74c3c; }
.badge-urgent { background: rgba(191, 87, 0, 0.25); color: var(--burnt-orange-light); }
.badge-standard { background: rgba(192, 150, 0, 0.2); color: var(--gold-light); }
.badge-scheduled { background: rgba(41, 128, 185, 0.2); color: #5dade2; }

/* === STAT CARDS === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--dark-brown-mid);
  border: 1px solid rgba(192, 150, 0, 0.12);
  border-radius: 6px;
  padding: 1.25rem;
  text-align: center;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--burnt-orange);
}

.stat-label {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gray);
  margin-top: 0.25rem;
}

/* === TIMELINE === */
.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(192, 150, 0, 0.2);
}

.timeline-item {
  position: relative;
  padding-bottom: 1.5rem;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -2rem;
  top: 0.2rem;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--dark-brown);
  border: 2px solid var(--gold);
  z-index: 1;
}

.timeline-item.active .timeline-dot {
  background: var(--burnt-orange);
  border-color: var(--burnt-orange);
}

.timeline-item.completed .timeline-dot {
  background: var(--green);
  border-color: var(--green);
}

.timeline-time {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--gray);
  margin-bottom: 0.25rem;
}

.timeline-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.timeline-desc {
  font-size: 0.85rem;
  color: var(--gray);
}

.timeline-meta {
  font-size: 0.75rem;
  color: var(--dark-brown-light);
  margin-top: 0.25rem;
}

/* === TABLE === */
.table-wrap {
  overflow-x: auto;
  border-radius: 6px;
  border: 1px solid rgba(192, 150, 0, 0.12);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: var(--dark-brown-mid);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(192, 150, 0, 0.15);
  white-space: nowrap;
}

td {
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(192, 150, 0, 0.08);
  white-space: nowrap;
}

tr:hover td {
  background: rgba(191, 87, 0, 0.05);
}

/* === TRACKING LOOKUP === */
.track-lookup {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
  max-width: 500px;
}

.track-lookup input {
  flex: 1;
  background: var(--dark-brown-mid);
  border: 1px solid rgba(192, 150, 0, 0.25);
  border-radius: 4px;
  padding: 0.85rem 1.25rem;
  color: var(--white);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.track-lookup input:focus {
  outline: none;
  border-color: var(--burnt-orange);
}

.track-lookup input::placeholder {
  color: var(--dark-brown-light);
  text-transform: none;
  letter-spacing: normal;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
}

/* === STATUS PROGRESS BAR === */
.status-progress {
  display: flex;
  justify-content: space-between;
  margin: 2rem 0;
  position: relative;
}

.status-progress::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(192, 150, 0, 0.15);
}

.status-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}

.status-step-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--dark-brown);
  border: 2px solid rgba(192, 150, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
  transition: all 0.3s;
}

.status-step.done .status-step-dot {
  background: var(--green);
  border-color: var(--green);
}

.status-step.current .status-step-dot {
  background: var(--burnt-orange);
  border-color: var(--burnt-orange);
  box-shadow: 0 0 12px rgba(191, 87, 0, 0.4);
}

.status-step-dot svg {
  width: 14px;
  height: 14px;
  fill: var(--white);
}

.status-step-label {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray);
  white-space: nowrap;
}

.status-step.done .status-step-label,
.status-step.current .status-step-label {
  color: var(--white);
}

/* === DELIVERY DETAIL GRID === */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.detail-section {
  background: var(--dark-brown-mid);
  border: 1px solid rgba(192, 150, 0, 0.12);
  border-radius: 6px;
  padding: 1.5rem;
}

.detail-section-title {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 1rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(192, 150, 0, 0.06);
}

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

.detail-label {
  font-size: 0.8rem;
  color: var(--gray);
}

.detail-value {
  font-size: 0.9rem;
  font-weight: 500;
  text-align: right;
}

/* === SIGNATURE PAD === */
.signature-container {
  background: var(--dark-brown);
  border: 1px solid rgba(192, 150, 0, 0.25);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.signature-container canvas {
  width: 100%;
  height: 200px;
  background: rgba(244, 244, 242, 0.03);
  border-radius: 4px;
  cursor: crosshair;
  touch-action: none;
}

.signature-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* === CAMERA CAPTURE === */
.camera-container {
  background: var(--dark-brown);
  border: 1px solid rgba(192, 150, 0, 0.25);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.camera-container video,
.camera-container img {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  display: block;
}

.camera-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
}

/* === ALERTS === */
.alert {
  padding: 1rem 1.5rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.alert-success {
  background: rgba(39, 174, 96, 0.15);
  border: 1px solid rgba(39, 174, 96, 0.3);
  color: #58d68d;
}

.alert-error {
  background: rgba(192, 57, 43, 0.15);
  border: 1px solid rgba(192, 57, 43, 0.3);
  color: #e74c3c;
}

.alert-info {
  background: rgba(41, 128, 185, 0.15);
  border: 1px solid rgba(41, 128, 185, 0.3);
  color: #5dade2;
}

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--gray);
}

.empty-state h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--white);
}

/* === LOADING === */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem;
  color: var(--gray);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(192, 150, 0, 0.2);
  border-top-color: var(--burnt-orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* === MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--dark-brown-mid);
  border: 1px solid rgba(192, 150, 0, 0.2);
  border-radius: 8px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h3 {
  margin-bottom: 1.5rem;
}

/* === FOOTER === */
.app-footer {
  padding: 2rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--gray);
  border-top: 1px solid rgba(192, 150, 0, 0.08);
  margin-top: 3rem;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .app-header { padding: 0.75rem 1rem; }
  .app-nav { gap: 0; }
  .app-nav a { padding: 0.4rem 0.5rem; font-size: 0.7rem; }
  .app-main { padding: 5rem 1rem 2rem; }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .status-progress { overflow-x: auto; padding-bottom: 0.5rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .app-logo-text { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .track-lookup { flex-direction: column; }
}

/* Mobile table improvements - scroll indicator */
@media (max-width: 768px) {
  .table-wrap {
    position: relative;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap::after {
    content: '← Scroll →';
    position: absolute;
    bottom: 0;
    right: 0;
    padding: 4px 8px;
    background: rgba(59, 46, 45, 0.9);
    color: var(--gold);
    font-size: 0.65rem;
    border-radius: 4px 0 0 0;
    pointer-events: none;
  }
  table {
    min-width: 600px; /* Ensure minimum width for scroll */
  }
  th, td {
    padding: 0.6rem 0.5rem;
    font-size: 0.8rem;
  }
  /* Larger touch targets for action buttons */
  .btn-sm {
    padding: 0.5rem 0.75rem;
    min-height: 36px;
    min-width: 44px;
  }
}
