/* MediGuard AI - Senior-Friendly Styles */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* Base styles */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Senior-friendly font sizes */
.text-small { font-size: 0.9rem; }
.text-medium { font-size: 1rem; }
.text-large { font-size: 1.125rem; }
.text-extra-large { font-size: 1.25rem; }

/* Apply font size scaling */
html.text-small { font-size: 90%; }
html.text-medium { font-size: 100%; }
html.text-large { font-size: 112.5%; }
html.text-extra-large { font-size: 125%; }

/* High contrast theme */
html.theme-high-contrast {
  filter: contrast(150%);
}

html.theme-high-contrast .bg-white { background-color: #ffffff !important; }
html.theme-high-contrast .text-gray-900 { color: #000000 !important; }
html.theme-high-contrast .text-gray-600 { color: #333333 !important; }
html.theme-high-contrast .text-gray-500 { color: #404040 !important; }
html.theme-high-contrast .border-gray-200 { border-color: #666666 !important; }

/* Force better text contrast and visibility */
.text-gray-900 { 
  color: #1f2937 !important; 
  font-weight: 500;
}

.text-gray-800 { 
  color: #374151 !important; 
  font-weight: 500;
}

.text-gray-700 { 
  color: #4b5563 !important; 
}

.text-gray-600 { 
  color: #6b7280 !important; 
}

.text-gray-500 { 
  color: #9ca3af !important; 
}

/* Ensure white backgrounds are fully opaque */
.bg-white {
  background-color: #ffffff !important;
  opacity: 1 !important;
}

/* Make sure cards have proper contrast */
.bg-gray-50 {
  background-color: #f9fafb !important;
}

/* Fix button visibility */
button {
  opacity: 1 !important;
  font-weight: 600 !important;
}

/* Fix loading states to be more visible */
.animate-pulse {
  background-color: #e5e7eb !important;
}

/* Ensure text is always visible */
p, h1, h2, h3, h4, h5, h6, span, div {
  color: inherit;
  opacity: 1 !important;
}

/* Force navbar text to be visible */
nav h1, nav button, nav i {
  opacity: 1 !important;
  color: inherit !important;
}

/* Force main content text to be dark and visible */
main .text-gray-900, main .text-gray-800, main .text-gray-700 {
  color: #1f2937 !important;
  font-weight: 500 !important;
}

main .text-gray-600 {
  color: #4b5563 !important;
}

main .text-gray-500 {
  color: #6b7280 !important;
}

/* Ensure gradient text stays white */
.bg-gradient-to-r h2, .bg-gradient-to-r p {
  color: white !important;
}

/* Make sure stat numbers are bold and dark */
.text-2xl.font-bold {
  color: #1f2937 !important;
  font-weight: 700 !important;
}

/* Dark theme */
html.theme-dark {
  background-color: #1a1a1a;
  color: #ffffff;
}

html.theme-dark .bg-white { background-color: #2a2a2a !important; }
html.theme-dark .bg-gray-50 { background-color: #1a1a1a !important; }
html.theme-dark .text-gray-900 { color: #ffffff !important; }
html.theme-dark .text-gray-700 { color: #e0e0e0 !important; }
html.theme-dark .text-gray-600 { color: #c0c0c0 !important; }
html.theme-dark .text-gray-500 { color: #a0a0a0 !important; }
html.theme-dark .border-gray-200 { border-color: #404040 !important; }

/* Enhanced focus visibility for accessibility */
button:focus,
input:focus,
select:focus,
textarea:focus,
a:focus {
  outline: 3px solid #3b82f6 !important;
  outline-offset: 2px !important;
}

/* High contrast focus for accessibility */
html.theme-high-contrast button:focus,
html.theme-high-contrast input:focus,
html.theme-high-contrast select:focus,
html.theme-high-contrast textarea:focus,
html.theme-high-contrast a:focus {
  outline: 4px solid #000000 !important;
  outline-offset: 3px !important;
  background-color: #ffff00 !important;
  color: #000000 !important;
}

/* Larger touch targets for mobile/tablet */
@media (max-width: 768px) {
  button, 
  a.button,
  input[type="button"],
  input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 20px;
  }
  
  input,
  select,
  textarea {
    min-height: 44px;
    padding: 12px 16px;
    font-size: 1rem;
  }
}

/* Enhanced button styles */
.btn-primary {
  background-color: #2563eb;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.btn-primary:hover {
  background-color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background-color: #10b981;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background-color: #059669;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Card styles with better visual hierarchy */
.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  border: 1px solid #e5e7eb;
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

/* Medication reminder cards */
.reminder-card {
  border-left: 4px solid #3b82f6;
  padding: 16px;
  margin-bottom: 12px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.reminder-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.reminder-card.overdue {
  border-left-color: #ef4444;
  background-color: #fef2f2;
}

.reminder-card.upcoming {
  border-left-color: #f59e0b;
  background-color: #fffbeb;
}

/* Health log icons with better visibility */
.health-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 600;
}

.health-icon.vital { background: #fee2e2; color: #dc2626; }
.health-icon.symptom { background: #fef3c7; color: #d97706; }
.health-icon.mood { background: #d1fae5; color: #059669; }
.health-icon.pain { background: #fed7aa; color: #ea580c; }
.health-icon.sleep { background: #e0e7ff; color: #6366f1; }
.health-icon.exercise { background: #dbeafe; color: #2563eb; }

/* Insight severity indicators */
.insight-info { border-left: 4px solid #3b82f6; }
.insight-warning { border-left: 4px solid #f59e0b; }
.insight-critical { border-left: 4px solid #ef4444; }

/* Gamification elements */
.streak-badge {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: white;
  padding: 8px 16px;
  border-radius: 50px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
}

.badge.success { background: #dcfce7; color: #166534; }
.badge.warning { background: #fef3c7; color: #92400e; }
.badge.error { background: #fee2e2; color: #991b1b; }
.badge.info { background: #dbeafe; color: #1e40af; }

/* Loading animations */
.loading-pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.loading-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Chat interface */
.chat-container {
  max-height: 400px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.chat-message {
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-message.user .chat-bubble {
  background: #2563eb;
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message.ai .chat-bubble {
  background: #f3f4f6;
  color: #374151;
  border-bottom-left-radius: 4px;
}

.chat-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.4;
  word-wrap: break-word;
}

/* Progress indicators */
.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring circle {
  fill: transparent;
  stroke: #e5e7eb;
  stroke-width: 8;
}

.progress-ring .progress {
  stroke: #3b82f6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

/* Medication scanner overlay */
.scanner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.scanner-frame {
  width: 280px;
  height: 280px;
  border: 3px solid #3b82f6;
  border-radius: 12px;
  position: relative;
  background: rgba(255, 255, 255, 0.1);
}

.scanner-corners {
  position: absolute;
  width: 30px;
  height: 30px;
}

.scanner-corners.top-left { top: -3px; left: -3px; border-top: 6px solid #3b82f6; border-left: 6px solid #3b82f6; }
.scanner-corners.top-right { top: -3px; right: -3px; border-top: 6px solid #3b82f6; border-right: 6px solid #3b82f6; }
.scanner-corners.bottom-left { bottom: -3px; left: -3px; border-bottom: 6px solid #3b82f6; border-left: 6px solid #3b82f6; }
.scanner-corners.bottom-right { bottom: -3px; right: -3px; border-bottom: 6px solid #3b82f6; border-right: 6px solid #3b82f6; }

/* Notification styles */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  max-width: 400px;
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  font-weight: 500;
}

.notification.show {
  transform: translateX(0);
}

.notification.success { background: #10b981; color: white; }
.notification.error { background: #ef4444; color: white; }
.notification.warning { background: #f59e0b; color: white; }
.notification.info { background: #3b82f6; color: white; }

/* Responsive design improvements */
@media (max-width: 640px) {
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }
  
  .card {
    margin-bottom: 16px;
  }
  
  .btn-primary,
  .btn-secondary {
    width: 100%;
    margin-bottom: 12px;
  }
  
  .grid-cols-mobile {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .text-mobile-lg {
    font-size: 1.25rem;
  }
  
  .p-mobile {
    padding: 16px;
  }
}

/* High contrast mode improvements */
@media (prefers-contrast: high) {
  .card {
    border: 2px solid #000000;
  }
  
  button {
    border: 2px solid #000000;
  }
  
  input, select, textarea {
    border: 2px solid #000000;
  }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }
  
  .card {
    break-inside: avoid;
    border: 1px solid #000000;
    box-shadow: none;
  }
  
  body {
    font-size: 12pt;
    line-height: 1.4;
  }
  
  h1, h2, h3 {
    page-break-after: avoid;
  }
}

/* Voice UI indicators */
.voice-active {
  background: linear-gradient(45deg, #ef4444, #f97316);
  animation: voice-pulse 1.5s ease-in-out infinite;
}

@keyframes voice-pulse {
  0%, 100% { 
    transform: scale(1);
    opacity: 1;
  }
  50% { 
    transform: scale(1.1);
    opacity: 0.8;
  }
}

/* Floating action button */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.fab:hover {
  background: #2563eb;
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5);
}

.fab:active {
  transform: scale(0.95);
}

/* Emergency contact styles */
.emergency-contact {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: block;
}

.emergency-contact:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
  color: white;
}

/* Accessibility improvements */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #000000;
  color: white;
  padding: 8px;
  text-decoration: none;
  z-index: 10000;
  border-radius: 4px;
}

.skip-link:focus {
  top: 6px;
}

/* Custom scrollbar for chat */
.chat-container::-webkit-scrollbar {
  width: 6px;
}

.chat-container::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.chat-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Medication adherence visual indicators */
.adherence-excellent { color: #059669; }
.adherence-good { color: #3b82f6; }
.adherence-needs-attention { color: #f59e0b; }
.adherence-poor { color: #ef4444; }

/* Status indicators */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

.status-dot.active { background: #10b981; }
.status-dot.inactive { background: #6b7280; }
.status-dot.pending { background: #f59e0b; }
.status-dot.overdue { background: #ef4444; }