@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Readex+Pro:wght@400;500;600;700&display=swap');

:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --brand-primary: #059669;
  --brand-dark: #064e3b;
  --brand-light: #ecfdf5;
  --brand-border: #a7f3d0;
  --danger: #e11d48;
  --warning: #d97706;
  --border-subtle: #e2e8f0;
}

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

body {
  font-family: 'IBM Plex Sans Arabic', 'Readex Pro', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .font-display {
  font-family: 'Readex Pro', 'IBM Plex Sans Arabic', sans-serif;
  letter-spacing: -0.01em;
}

/* Prevent iOS Safari zoom on input focus by ensuring at least 16px on small screens */
@media (max-width: 640px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Subtle Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Desktop Navigation Styling */
.app-nav-item {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border-bottom: 2px solid transparent;
  color: #475569;
}
.app-nav-item:hover {
  color: #0f172a;
  background-color: #f1f5f9;
}
.app-nav-item.active {
  color: #059669;
  border-bottom-color: #059669;
  background-color: #ecfdf5;
  font-weight: 600;
}

/* Mobile Bottom Nav Active State */
.mobile-nav-btn {
  color: #64748b;
  transition: all 0.18s ease;
}
.mobile-nav-btn.active {
  color: #059669;
  font-weight: 700;
}

/* Allergen Filter Pill */
.profile-pill {
  transition: all 0.18s ease;
  user-select: none;
}
.profile-pill.active {
  background-color: #064e3b;
  color: #ffffff;
  border-color: #064e3b;
  box-shadow: 0 2px 6px rgba(6, 78, 59, 0.2);
}

/* Camera Viewfinder & Laser */
.camera-viewport {
  position: relative;
  background: #090d16;
  overflow: hidden;
}

@keyframes scanLineMove {
  0% {
    top: 12%;
    opacity: 0.85;
  }
  50% {
    top: 86%;
    opacity: 1;
  }
  100% {
    top: 12%;
    opacity: 0.85;
  }
}

.camera-laser-line {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, #10b981 20%, #34d399 50%, #10b981 80%, transparent 100%);
  box-shadow: 0 0 12px 2px rgba(16, 185, 129, 0.65);
  animation: scanLineMove 2.4s ease-in-out infinite;
  pointer-events: none;
  z-index: 25;
}

.viewfinder-frame {
  position: absolute;
  inset: 14%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  pointer-events: none;
  z-index: 20;
}

.vf-corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border-color: #10b981;
  border-style: solid;
}
.vf-tl { top: -2px; left: -2px; border-width: 3px 0 0 3px; border-top-left-radius: 16px; }
.vf-tr { top: -2px; right: -2px; border-width: 3px 3px 0 0; border-top-right-radius: 16px; }
.vf-bl { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; border-bottom-left-radius: 16px; }
.vf-br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; border-bottom-right-radius: 16px; }

/* Verified Green Checkmark Badge Animation */
@keyframes checkScaleIn {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.verified-badge-card {
  animation: checkScaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Custom Leaflet HTML Marker Pin */
.custom-madinah-marker {
  background: transparent;
  border: none;
}

.madinah-pin-bubble {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  color: #0f172a;
  border: 2px solid #059669;
  border-radius: 9999px;
  padding: 5px 11px;
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.22);
  transform: translate(-50%, -50%);
  transition: all 0.2s ease;
  cursor: pointer;
}
.madinah-pin-bubble:hover,
.madinah-pin-bubble.selected {
  background: #047857;
  color: #ffffff;
  border-color: #064e3b;
  transform: translate(-50%, -55%) scale(1.08);
  z-index: 500;
}
.madinah-pin-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: #10b981;
  flex-shrink: 0;
}
.madinah-pin-bubble.selected .madinah-pin-dot,
.madinah-pin-bubble:hover .madinah-pin-dot {
  background: #ffffff;
}

/* Pulsing User Location Pin on Map */
@keyframes gpsPulseRing {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0.85;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.3);
    opacity: 0;
  }
}

.user-gps-marker-wrap {
  position: relative;
  width: 32px;
  height: 32px;
}

.user-gps-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  background: rgba(37, 99, 235, 0.35);
  animation: gpsPulseRing 1.8s ease-out infinite;
  pointer-events: none;
}

.user-gps-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #1d4ed8;
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 9999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.4);
}

/* Leaflet Popup RTL Styling */
.leaflet-popup-content-wrapper {
  border-radius: 16px !important;
  padding: 2px !important;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18) !important;
  direction: rtl;
  text-align: right;
  font-family: 'IBM Plex Sans Arabic', sans-serif !important;
}

.leaflet-popup-content {
  margin: 12px 14px !important;
  line-height: 1.5 !important;
}

/* Medical Card Wallet Design */
.medical-wallet-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.06), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  position: relative;
  overflow: hidden;
}

/* Official Certificate Styling */
.official-certificate {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 2px solid #065f46;
  outline: 6px double #a7f3d0;
  outline-offset: -12px;
}

/* Leaflet RTL Fix */
.leaflet-container {
  font-family: 'IBM Plex Sans Arabic', sans-serif !important;
  z-index: 10;
  background-color: #e2e8f0;
}

/* Audio Equalizer Pulse */
@keyframes eqPulse {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}
.eq-bar {
  width: 3px;
  height: 14px;
  background-color: currentColor;
  border-radius: 99px;
  display: inline-block;
  transform-origin: bottom;
}
.is-speaking .eq-bar:nth-child(1) { animation: eqPulse 0.5s infinite 0s; }
.is-speaking .eq-bar:nth-child(2) { animation: eqPulse 0.5s infinite 0.15s; }
.is-speaking .eq-bar:nth-child(3) { animation: eqPulse 0.5s infinite 0.3s; }
.is-speaking .eq-bar:nth-child(4) { animation: eqPulse 0.5s infinite 0.1s; }

/* Print Styles */
@media print {
  body * {
    visibility: hidden;
  }
  .printable-area, .printable-area * {
    visibility: visible;
  }
  .printable-area {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    box-shadow: none !important;
    border: 1px solid #cbd5e1 !important;
  }
  .no-print {
    display: none !important;
  }
}
