/* ==========================================================================
   MK SONS LOGISTICS - DRIVER PWA HIGH CONTRAST STYLESHEET
   Designed for outdoor daylight legibility & rapid truck cabin interactions
   ========================================================================== */

:root {
  --bg-primary: #0A0E17;
  --bg-surface: #141C2E;
  --bg-surface-elevated: #1E293B;
  --border-color: #334155;
  --border-focus: #F59E0B;

  --text-primary: #FFFFFF;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;

  --accent-amber: #F59E0B;
  --accent-amber-glow: rgba(245, 158, 11, 0.25);
  --accent-green: #10B981;
  --accent-green-glow: rgba(16, 185, 129, 0.3);
  --accent-blue: #38BDF8;
  --accent-red: #EF4444;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --tap-target-min: 52px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-bottom: 90px; /* Space for sticky bottom navigation */
}

/* Header & Delhi Window Alert */
.app-header {
  background-color: var(--bg-surface);
  border-bottom: 2px solid var(--border-color);
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-amber);
  color: #000;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.brand-text span {
  font-size: 0.75rem;
  color: var(--accent-amber);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 1px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Language Switcher Button */
.btn-lang {
  background: var(--bg-surface-elevated);
  border: 1.5px solid var(--accent-amber);
  color: var(--text-primary);
  height: 40px;
  padding: 0 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.5px;
}

.btn-lang:active {
  transform: scale(0.94);
  background: rgba(245, 158, 11, 0.2);
}

.btn-icon {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
}

.btn-icon:active {
  transform: scale(0.92);
}

/* Delhi Commercial No-Entry Advisory Banner */
.no-entry-banner {
  margin-top: 10px;
  padding: 10px 12px;
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--accent-red);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
}

.no-entry-banner.warning {
  background-color: rgba(245, 158, 11, 0.15);
  border-color: var(--accent-amber);
}

.no-entry-banner.safe {
  background-color: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-green);
}

.banner-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.banner-text {
  flex: 1;
  line-height: 1.3;
}

.banner-text strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 2px;
}

/* Main Container */
.container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  flex: 1;
}

/* Scanner Section */
.scanner-card {
  background-color: var(--bg-surface);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

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

.scanner-header h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  color: var(--text-secondary);
}

.scanner-viewport-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background-color: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border-color);
}

#reader {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
}

#reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

/* Reticle Target Overlay */
.reticle-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70%;
  height: 55%;
  border: 2px dashed var(--accent-amber);
  border-radius: 12px;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
}

.reticle-overlay::after {
  content: "ALIGN BARCODE / QR";
  position: absolute;
  bottom: -28px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent-amber);
}

.scanner-controls {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.btn-secondary {
  flex: 1;
  min-height: var(--tap-target-min);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.btn-secondary:active {
  background: #334155;
}

/* Manual Barcode Fallback Input */
.manual-input-box {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.input-barcode {
  flex: 1;
  min-height: var(--tap-target-min);
  background-color: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0 14px;
  letter-spacing: 1px;
}

.input-barcode:focus {
  outline: none;
  border-color: var(--accent-amber);
  box-shadow: 0 0 0 3px var(--accent-amber-glow);
}

.btn-search {
  min-height: var(--tap-target-min);
  padding: 0 20px;
  background-color: var(--accent-amber);
  color: #000;
  font-size: 1rem;
  font-weight: 800;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-search:active {
  transform: scale(0.95);
}

/* Route Details & Summary Banner */
.route-summary-card {
  background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
  border: 2px solid var(--accent-amber);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 18px;
}

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

.run-badge {
  background: var(--accent-amber);
  color: #000;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  letter-spacing: 1px;
}

.stops-count-pill {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
}

.warehouse-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-top: 1px dashed var(--border-color);
  padding-top: 10px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Stop List Cards */
.stops-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stop-card {
  background-color: var(--bg-surface);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
  transition: all 0.25s ease;
}

.stop-card:focus-within,
.stop-card:hover {
  border-color: var(--accent-blue);
}

/* Completed Store: Greys out, shows strikethrough, moves to bottom */
.stop-card.completed {
  opacity: 0.55;
  background-color: #0c1220;
  border-color: #1e293b;
  order: 999;
}

.stop-card.completed .stop-store-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.stop-card.completed .stop-seq-badge {
  background: #334155;
  color: #94a3b8;
}

.btn-mark-done {
  min-height: 46px;
  padding: 0 14px;
  font-size: 0.88rem;
  font-weight: 800;
  border-radius: var(--radius-sm);
  border: 2px solid var(--accent-green);
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-mark-done.is-done {
  border-color: #64748b;
  background: transparent;
  color: #94a3b8;
}

.btn-mark-done:active {
  transform: scale(0.95);
}

.stop-card-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.stop-seq-badge {
  background: var(--accent-blue);
  color: #000;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 900;
  flex-shrink: 0;
}

.stop-main-info {
  flex: 1;
}

.stop-store-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: #FFFFFF;
  margin-bottom: 4px;
  line-height: 1.25;
}

.stop-address {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.35;
  margin-bottom: 8px;
}

.stop-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tag-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.tag-crates {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

.tag-window {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--accent-red);
  color: #FCA5A5;
}

.stop-actions {
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
}

.btn-stop-action {
  flex: 1;
  min-height: 46px;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
}

.btn-call {
  background: var(--bg-surface-elevated);
  color: var(--accent-blue);
  border: 1px solid var(--accent-blue);
}

.btn-nav-single {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
}

/* Unmapped WhatsApp Location Alert Pill */
.unmapped-alert-box {
  background: rgba(239, 68, 68, 0.12);
  border: 1.5px dashed var(--accent-red);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: #FCA5A5;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.unmapped-alert-box a {
  color: #fff;
  text-decoration: underline;
  font-weight: 900;
}

/* Sticky Master Navigation Bottom Bar */
.sticky-nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border-top: 2px solid var(--accent-green);
  padding: 12px 16px;
  z-index: 200;
  display: flex;
  justify-content: center;
}

.sticky-nav-bar .btn-master-nav {
  width: 100%;
  max-width: 580px;
  min-height: 56px;
  background: var(--accent-green);
  color: #000;
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  border: none;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 18px var(--accent-green-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
}

.sticky-nav-bar .btn-master-nav:active {
  transform: scale(0.97);
}

/* Loading & Empty States */
.state-container {
  text-align: center;
  padding: 36px 16px;
  background: var(--bg-surface);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 10px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

.state-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.state-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Settings Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 300;
}

.modal-content {
  background: var(--bg-surface);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 480px;
  padding: 20px;
}

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

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
}

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  min-height: 46px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 0 12px;
  font-size: 0.95rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

/* Helper Utilities */
.hidden {
  display: none !important;
}
