/* Custom theme styles for "انقل حلالك" (Livestock Transport App) */

/* Scrollbar beautification */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #FAF6EE;
}
::-webkit-scrollbar-thumb {
  background: #C29B38;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #8C6239;
}

/* Hide scrollbar for clean tab scrolling on mobile */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Tab active style */
.active-tab {
  border-bottom-color: #C29B38 !important;
  color: #C29B38 !important;
}

/* Count button states */
.count-btn {
  user-select: none;
  touch-action: manipulation;
}

/* Scale up animation for modals */
@keyframes scaleUp {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-scaleUp {
  animation: scaleUp 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Fleet size badge inside the recommendation card */
.fleet-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
  padding: 0.18rem 0.6rem;
  border-radius: 0.6rem;
  font-size: 11px;
  font-weight: 800;
  color: #A8480F;
  background: rgba(224, 107, 40, 0.12);
  border: 1px solid rgba(224, 107, 40, 0.35);
}
.fleet-badge.hidden {
  display: none;
}

/* In-app toast (voice read-aloud fallback + notices) */
#appToast {
  position: fixed;
  left: 0.85rem;
  right: 0.85rem;
  bottom: 5.75rem;
  z-index: 80;
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  background: rgba(34, 20, 10, 0.96);
  color: #FAF6EE;
  font-size: 12px;
  line-height: 1.75;
  text-align: center;
  border: 1px solid rgba(194, 155, 56, 0.45);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#appToast.toast-show {
  opacity: 1;
  transform: translateY(0);
}
@media (min-width: 768px) {
  #appToast {
    bottom: 1.5rem;
    left: 50%;
    right: auto;
    max-width: 32rem;
    transform: translate(-50%, 12px);
  }
  #appToast.toast-show {
    transform: translate(-50%, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  #appToast {
    transition: none;
  }
}

/* ==========================================
   LIVE MAP TRACKING
   ========================================== */

.map-shell {
  position: relative;
  width: 100%;
  background: #180d05;
}

.track-map {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 4;
}

#trackMapSvg text {
  font-family: Tajawal, sans-serif;
}

.city-label {
  font-size: 21px;
  font-weight: 700;
  fill: #5b3d1d;
  opacity: 0.72;
  direction: rtl;
  display: none;
}

@media (min-width: 768px) {
  .city-label {
    display: block;
  }
}

.pin-text {
  font-family: Tajawal, sans-serif;
}

/* Truck live halo pulse */
.truck-halo {
  transform-box: fill-box;
  transform-origin: center;
  animation: truckHaloPulse 1.9s ease-out infinite;
}

@keyframes truckHaloPulse {
  0%   { transform: scale(0.72); opacity: 0.42; }
  70%  { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

/* Live status dot */
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
  animation: liveDotBlink 1.3s ease-in-out infinite;
  flex: 0 0 auto;
}

.live-dot.is-idle {
  background: #8C6239;
  box-shadow: 0 0 0 3px rgba(140, 98, 57, 0.18);
  animation: none;
}

@keyframes liveDotBlink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.25; }
}

/* Speed selector */
.track-speed-btn {
  min-width: 34px;
  padding: 3px 7px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
  color: #DFCCA3;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(223, 204, 163, 0.25);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.track-speed-btn.is-active {
  background: #C29B38;
  border-color: #C29B38;
  color: #22140A;
}

/* Stage timeline */
.track-step {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 12px;
  line-height: 1.4;
  color: #8C6239;
}

.step-dot {
  width: 11px;
  height: 11px;
  border-radius: 9999px;
  background: #EDE3D2;
  border: 2px solid #C9B79A;
  flex: 0 0 auto;
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.track-step .step-text {
  transition: color 0.25s ease;
}

.track-step.done .step-dot {
  background: #059669;
  border-color: #059669;
}

.track-step.done .step-text {
  color: #4B5563;
}

.track-step.active .step-dot {
  background: #C29B38;
  border-color: #C29B38;
  box-shadow: 0 0 0 4px rgba(194, 155, 56, 0.22);
}

.track-step.active .step-text {
  color: #382211;
  font-weight: 800;
}

/* Live event log */
.track-log-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.05);
  border-inline-start: 3px solid rgba(194, 155, 56, 0.55);
  line-height: 1.55;
}

.track-log-item.is-done {
  background: rgba(16, 185, 129, 0.16);
  border-inline-start-color: #10b981;
}

.track-log-time {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  color: #C29B38;
  flex: 0 0 auto;
  padding-top: 1px;
}

.track-log-text {
  color: #F3ECE0;
}

.track-log-empty {
  font-size: 11px;
  line-height: 1.7;
  color: rgba(223, 204, 163, 0.75);
  text-align: center;
  padding: 0.75rem 0.25rem;
}

@media (prefers-reduced-motion: reduce) {
  .truck-halo,
  .live-dot {
    animation: none !important;
  }
  .step-dot,
  .track-step .step-text {
    transition: none;
  }
}

/* ==========================================
   PDF EXPORT
   ========================================== */

#pdfOverlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(24, 13, 5, 0.86);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
#pdfOverlay.is-open {
  display: flex;
}

.pdf-card {
  width: 100%;
  max-width: 22rem;
  background: #ffffff;
  color: #382211;
  border: 1px solid rgba(194, 155, 56, 0.45);
  border-radius: 1.5rem;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
  animation: scaleUp 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.pdf-title {
  font-size: 15px;
  font-weight: 900;
  color: #382211;
  margin-top: 0.65rem;
}
.pdf-sub {
  font-size: 11px;
  line-height: 1.8;
  color: #8C6239;
  margin: 0.35rem 0 0.9rem;
  word-break: break-word;
}
.pdf-icon {
  font-size: 34px;
  line-height: 1;
}

.pdf-btn-primary {
  display: block;
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: 0.85rem;
  background: linear-gradient(90deg, #C29B38, #E06B28);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  border: 0;
  cursor: pointer;
}
.pdf-btn-primary:active {
  transform: scale(0.98);
}
.pdf-btn-ghost {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 0.85rem;
  background: #FAF6EE;
  border: 2px solid #C29B38;
  color: #382211;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.pdf-btn-text {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.55rem;
  background: transparent;
  border: 0;
  color: #8C6239;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.pdf-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border-radius: 9999px;
  border: 4px solid rgba(194, 155, 56, 0.25);
  border-top-color: #C29B38;
  animation: pdfSpin 0.9s linear infinite;
}
@keyframes pdfSpin {
  to { transform: rotate(360deg); }
}

/* Wide, clean capture layout used only while rendering the PDF */
.pdf-mode {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 940px !important;
  max-width: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: #ffffff !important;
  z-index: 1;
}
.pdf-mode .pdf-unclip {
  overflow: visible !important;
}
.pdf-mode .pdf-unclip table {
  min-width: 0 !important;
}
.pdf-mode .pdf-hide {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .pdf-spinner,
  .pdf-card {
    animation: none;
  }
}

/* Print Styles for Manifest Bill of Lading */
@media print {
  body {
    background: white !important;
    color: black !important;
    padding-bottom: 0 !important;
  }
  header, footer, nav, #voiceNarrateBtn, #newOrderQuickBtn, .no-print, .tab-pane:not(#tab-manifest), #printManifestBtn, #shareManifestBtn, #exportManifestPdfBtn, #pdfOverlay {
    display: none !important;
  }
  #tab-manifest {
    display: block !important;
  }
  #manifestDocument {
    border: 1px solid #333 !important;
    box-shadow: none !important;
    max-width: 100% !important;
    padding: 15mm !important;
    margin: 0 !important;
  }
  input {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
  }
}