@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+Devanagari:wght@400;500;600;700&display=swap");

* {
  font-family: "Inter", "Noto Sans Devanagari", sans-serif;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-top: calc(64px + env(safe-area-inset-top, 0px));
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

#mainContainer {
  padding-top: 0;
  /* Handled by body padding */
}

/* Navbar Highlighting & Hover Effects */
.nav-btn {
  position: relative;
  padding: 8px 16px;
  border-radius: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn:hover {
  background: rgba(147, 51, 234, 0.05);
  /* Very subtle purple tint */
  transform: translateY(-1px);
}

.nav-btn.active-nav {
  color: #9333ea !important;
  font-weight: 700 !important;
  background: rgba(147, 51, 234, 0.08);
  /* Slightly more visible pill for active */
}

/* Red special case for Emergency */
.nav-btn[data-nav="emergency"]:hover {
  background: rgba(239, 68, 68, 0.05);
  color: #dc2626 !important;
}

.nav-btn[data-nav="emergency"].active-nav {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626 !important;
}

/* Centered Underline Expansion */
.nav-btn::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: #9333ea;
  border-radius: 99px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateX(-50%);
}

.nav-btn[data-nav="emergency"]::after {
  background: #dc2626;
}

.nav-btn:hover::after,
.nav-btn.active-nav::after {
  width: calc(100% - 32px);
  /* Matches padding */
}

/* Mobile Bottom Nav Highlighting */
#mobileBottomNav button.active-nav {
  color: #9333ea !important;
}

#mobileBottomNav button.active-nav i {
  color: #9333ea;
  transform: scale(1.1);
}

#mobileBottomNav button.active-nav span {
  font-weight: 700;
}

/* Exception for AI button which is already special */
#mobileBottomNav button[data-nav="ai-assistant"].active-nav div {
  background: #7e22ce;
  box-shadow: 0 0 15px rgba(147, 51, 234, 0.4);
}

@keyframes slide-in {
  from {
    width: 0;
    left: 50%;
  }

  to {
    width: 100%;
    left: 0;
  }
}

/* Mobile specific top margin for bezel clearance */
@media (max-width: 768px) {
  body {
    padding-top: calc(64px + env(safe-area-inset-top, 0px));
  }

  /* Ensure navbar stays sticky but has some breathing room if needed */
  nav {
    margin-top: 0;
    padding-top: env(safe-area-inset-top, 0px);
  }

  /* Move main content down slightly to avoid overlap with bottom nav */
  #mainContainer {
    padding-bottom: 80px;
  }

  /* Safe Flush Fill: Bridge the gap behind navbar without touching content */
  #mainContainer {
    padding-top: 0 !important;
    margin-top: 0 !important;
    padding-bottom: 100px;
    position: relative;
  }

  .section.active::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(64px + env(safe-area-inset-top, 0px));
    z-index: 1000;
    /* Behind navbar (2000) */
    pointer-events: none;
  }

  /* Section-Specific Gap Colors */
  #home.active::before {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  }

  #medassist.active::before {
    background: linear-gradient(to bottom right, #4f46e5, #9333ea, #4f46e5);
  }

  #emergency.active::before {
    background: #dc2626;
  }

  #medicine-analyzer.active::before {
    background: #9333ea;
  }

  #pharmacy-finder.active::before {
    background: #2563eb;
  }

  #medicine.active::before {
    background: #eab308;
  }

  #diet.active::before {
    background: #16a34a;
  }

  /* Reset Section Spacing */
  .section {
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
  }

  footer {
    display: none;
  }

  /* Fix Leaflet attribution overlap with mobile nav */
  .leaflet-control-attribution {
    margin-bottom: 70px !important;
  }
}

/* Family Dashboard Redesign Styles */
.glass-panel {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.health-ring-container {
  position: relative;
  width: 60px;
  height: 60px;
}

.health-ring-svg {
  transform: rotate(-90deg);
}

.health-ring-circle {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease-out;
}

.animate-card-entry {
  animation: slideInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stagger-1 {
  animation-delay: 0.1s;
}

.stagger-2 {
  animation-delay: 0.2s;
}

.stagger-3 {
  animation-delay: 0.3s;
}

.stagger-4 {
  animation-delay: 0.4s;
}

.gradient-pink,
.bg-gradient-pink {
  background: linear-gradient(135deg, #ec4899 0%, #be185d 100%) !important;
}

.avatar-ring {
  padding: 3px;
  background: linear-gradient(45deg, #ec4899, #8b5cf6);
  border-radius: 9999px;
}

.gradient-text {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glass-effect {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.pulse-animation {
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

.typing-indicator span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #667eea;
  border-radius: 50%;
  animation: typing 1.4s infinite;
  margin: 0 2px;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

.feature-card {
  transition: all 0.3s ease;
}

.feature-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.chat-message {
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #f59e0b;
  color: white;
  text-align: center;
  padding: 8px;
  z-index: 9999;
  display: none;
}

.sos-button {
  animation: emergency-pulse 2s infinite;
}

@keyframes emergency-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }

  70% {
    box-shadow: 0 0 0 20px rgba(239, 68, 68, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.wave-bg {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  position: relative;
  overflow: hidden;
}

.wave-bg::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle,
      rgba(255, 255, 255, 0.1) 1px,
      transparent 1px);
  background-size: 20px 20px;
  animation: move 20s linear infinite;
}

@keyframes move {
  0% {
    transform: translate(0, 0);
  }

  100% {
    transform: translate(50px, 50px);
  }
}

.scroll-hidden::-webkit-scrollbar {
  display: none;
}

.scroll-hidden {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.no-scroll {
  overflow: hidden !important;
  height: 100% !important;
}

.medicine-card {
  transition: all 0.3s;
}

.medicine-card.taken {
  opacity: 0.6;
  background: #d1fae5;
}

#map {
  height: 400px;
  width: 100%;
  border-radius: 12px;
}

/* Map Customizations */
.user-marker-icon {
  background-color: #3b82f6;
  border: 3px solid white;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  border-radius: 50%;
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
  }

  70% {
    box-shadow: 0 0 0 15px rgba(59, 130, 246, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

.hospital-marker-icon {
  background-color: #ef4444;
  color: white;
  border: 2px solid white;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  border-radius: 50%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  padding: 0;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0;
  width: 280px !important;
}

.popup-header {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: white;
  padding: 12px 16px;
  font-weight: bold;
}

.popup-body {
  padding: 12px 16px;
}

.popup-btn {
  display: block;
  width: 100%;
  background-color: #eff6ff;
  color: #2563eb;
  text-align: center;
  padding: 8px;
  border-radius: 6px;
  margin-top: 8px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s;
}

.popup-btn:hover {
  background-color: #dbeafe;
}

/* Fix for language selection dropdown options visibility */
#aiLanguageSelect option {
  color: #1f2937 !important;
  /* text-gray-800 */
  background-color: white !important;
}

#aiLanguageSelect {
  cursor: pointer;
}

/* Loading Screen Styles */
#loadingScreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loader-container {
  position: relative;
  margin-bottom: 2rem;
}

.loader-heartbeat {
  font-size: 4rem;
  color: white;
  animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {

  0%,
  100% {
    transform: scale(1);
  }

  25% {
    transform: scale(1.1);
  }

  35% {
    transform: scale(1.2);
  }
}

.pulse-line {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
}

.pulse-path {
  stroke-dasharray: 500;
  stroke-dashoffset: 500;
  animation: pulse-draw 3s linear infinite;
}

@keyframes pulse-draw {
  to {
    stroke-dashoffset: 0;
  }
}

.loading-text .gradient-text {
  background: none;
  -webkit-text-fill-color: white;
  color: white;
}

#loadingScreen.fade-out {
  opacity: 0;
  transition: opacity 0.5s ease;
}

/* Enhanced Hybrid AI Assistant Styles */
.progress-bar {
  width: 100%;
  background-color: #f3f4f6;
  border-radius: 999px;
  margin-top: 1rem;
  overflow: hidden;
  height: 12px;
}

#download-progress {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #9333ea, #a855f7);
  transition: width 0.2s ease-out;
}

.response-container {
  margin-top: 1.5rem;
  padding: 0;
}

.prose p {
  margin-bottom: 1rem;
  line-height: 1.7;
}

.prose strong {
  color: #7c3aed;
  font-weight: 700;
}

/* Medicine Analyzer Custom Styles */
#medicine-upload-area {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(147, 51, 234, 0.02);
}

#medicine-upload-area:hover {
  background: rgba(147, 51, 234, 0.05);
  transform: translateY(-2px);
  border-color: #a855f7;
}

#analyzer-loading i {
  animation: scan 2s ease-in-out infinite;
}

@keyframes scan {

  0%,
  100% {
    transform: translateY(0) scale(1.1);
    color: #9333ea;
  }

  50% {
    transform: translateY(-15px) scale(0.9);
    color: #c084fc;
  }
}

/* Pharmacy Finder Styles */
.pharmacy-marker-icon {
  background-color: #3b82f6;
  color: white;
  border: 2px solid white;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  border-radius: 50%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

#pharmacy-list::-webkit-scrollbar {
  width: 6px;
}

#pharmacy-list::-webkit-scrollbar-track {
  background: transparent;
}

#pharmacy-list::-webkit-scrollbar-thumb {
  background: #e5e7eb;
  border-radius: 10px;
}

#pharmacy-list::-webkit-scrollbar-thumb:hover {
  background: #d1d5db;
}

/* Range Input Styling */
input[type="range"] {
  height: 6px;
  border-radius: 5px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  background: #3b82f6;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

@keyframes pulse-purple {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(147, 51, 234, 0.7);
  }

  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 15px rgba(147, 51, 234, 0);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(147, 51, 234, 0);
  }
}

.listening-glow {
  animation: pulse-purple 2s infinite !important;
  background-color: #f3e8ff !important;
}

#voiceRecognizedText {
  min-height: 4rem;
  background: #f9fafb;
  padding: 1.5rem;
  font-style: italic;
  color: #4b5563;
  width: 100%;
  border-radius: 1rem;
  margin-top: 1rem;
  border: 1px dashed #e5e7eb;
}

/* --- Voice Assistant Animations --- */
.voice-listening {
  background-color: #ef4444 !important;
  /* Red-500 */
  color: white !important;
  animation: voice-pulse 1.5s infinite;
}

@keyframes voice-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }

  70% {
    box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* --- Pregnancy Companion Styles --- */
.preg-gradient-bg {
  background: linear-gradient(135deg, #9333ea 0%, #ec4899 100%);
}

.preg-glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.preg-card {
  background: white;
  border-radius: 20px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

.preg-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.1);
}

.preg-metric-card {
  background: #fdf2f8;
  border-left: 4px solid #ec4899;
}

.preg-weekly-circle {
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: conic-gradient(#ec4899 var(--preg-progress, 0%), #f3f4f6 0%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preg-weekly-circle::before {
  content: "";
  position: absolute;
  width: 130px;
  height: 130px;
  background: white;
  border-radius: 50%;
}

.preg-weekly-content {
  position: relative;
  text-align: center;
  z-index: 1;
}

.preg-progress-container {
  height: 10px;
  background: #f1f5f9;
  border-radius: 99px;
  overflow: hidden;
}

.preg-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #9333ea, #ec4899);
  transition: width 0.5s ease;
}

/* Fetal Development Styles */
.fetal-metric-box {
  background: white;
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid #f1f5f9;
}

.fetal-organ-bar {
  height: 6px;
  background: #f1f5f9;
  border-radius: 99px;
  margin-top: 4px;
}

.fetal-organ-progress {
  height: 100%;
  border-radius: 99px;
}

/* AI Floating Panel */
#pregnancy-ai-panel {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 420px;
  max-width: calc(100vw - 40px);
  height: 620px;
  z-index: 5500;
  /* Higher than nav but lower than profile */
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.2);
  border-radius: 24px;
  overflow: hidden;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom right;
  animation: preg-panel-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#pregnancy-ai-panel.preg-panel-expanded {
  bottom: 20px;
  right: 20px;
  width: min(88vw, 720px);
  height: 85vh;
  border-radius: 24px;
}

@keyframes preg-panel-pop {
  0% {
    opacity: 0;
    transform: scale(0.5) translateY(20px);
  }

  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

#pregnancy-ai-panel.hidden {
  display: none;
  opacity: 0;
  transform: scale(0.9) translateY(10px);
  pointer-events: none;
}

.preg-ai-header {
  background: linear-gradient(135deg, #9333ea, #ec4899);
  padding: 1.25rem;
  color: white;
}

.preg-ai-chat {
  flex: 1;
  background: white;
  overflow-y: auto;
  padding: 1rem;
}

.preg-ai-input {
  background: white;
  padding: 1rem;
  border-top: 1px solid #f1f5f9;
}

@media (max-width: 768px) {
  #pregnancy-ai-panel {
    bottom: 80px;
    right: 10px;
    left: 10px;
    width: auto;
    height: 80vh;
  }

  #pregnancy-ai-panel.preg-panel-expanded {
    bottom: 10px;
    right: 10px;
    left: 10px;
    width: auto;
    height: 92vh;
  }
}

/* Pregnancy AI message formatting */
.preg-ai-message ul {
  list-style: none;
  padding: 0;
  margin: 6px 0;
}

.preg-ai-message ul li {
  padding: 3px 0 3px 16px;
  position: relative;
  line-height: 1.5;
}

.preg-ai-message ul li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #ec4899;
  font-weight: bold;
}

.preg-ai-message strong {
  color: #7c3aed;
  font-weight: 700;
}

.preg-ai-message h3,
.preg-ai-message h4 {
  color: #9333ea;
  font-weight: 700;
  margin: 8px 0 4px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preg-ai-message p {
  margin-bottom: 6px;
  line-height: 1.6;
}