/* Custom Styles for MEIARC - Medical Education Theme */
/* Version 1.0 - Extends Tailwind CSS */

/* CSS Variables for Easy Theming */
:root {
  --primary-color: #13136e; /* Indigo-600: Trustworthy blue */
  --accent-color: #10B981; /* Emerald-500: Health green */
  --bg-light: #0754a1; /* Gray-50: Soft background */
  --text-primary: #1F2937; /* Gray-800: Dark text */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --border-radius: 0.75rem; /* 12px: Rounded corners */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* Smooth easing */
}

/* Reset and Global Styles */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-light);
  color: var(--text-primary);
  line-height: 1.6;
  scroll-behavior: smooth;
  margin: 0;
  padding: 0;
}

/* Reduce padding on small screens for more content space */
@media (max-width: 768px) {
  body {
    padding: 0.5rem;
  }
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* Header Enhancements */
header {
  background: linear-gradient(135deg, white 0%, #0967c4 100%); /* Subtle gradient */
  box-shadow: var(--shadow-md);
  border-bottom: 1px solid #e5e7eb;
}

header h1 {
  background: linear-gradient(135deg, var(--primary-color), #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
  border-bottom: none !important;
}

/* Navigation Buttons */
.nav-btn {
  position: relative;
  color: #6b7280; /* Gray-500 */
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  transition: var(--transition);
}


.nav-btn:hover {
  color: var(--primary-color);
  background: rgba(79, 70, 229, 0.1); /* Same transparent purple */
  transform: translateY(-1px); /* Subtle lift */
}

.nav-btn.active-nav {
  color: var(--primary-color);
  font-weight: 600;
}

.nav-btn.active-nav::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 2px;
  background: var(--primary-color);
  border-radius: 1px;
}


/* Main Content Sections */
.content-section {
  animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.bg-white {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid #f3f4f6; /* Subtle border */
}

.bg-white:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px); /* Lift on hover for cards */
  transition: var(--transition);
}

/* Headings */
h1, h2, h3 {
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.2;
}

h2 {
  font-size: 2.25rem; /* Larger for impact */
  margin-bottom: 1.5rem;
}

/* Cards (Library Topics, Meds, Q-Bank) */
.topic-card,
.bg-white.p-6.rounded-xl { /* Target cards */
  border-left: 4px solid var(--accent-color); /* Green accent border */
  transition: var(--transition);
}

.topic-card:hover,
.bg-white.p-6.rounded-xl:hover {
  border-left-color: var(--primary-color);
  transform: scale(1.02); /* Slight zoom */
}

/* Read More Button */
.read-topic-btn,
.text-indigo-500 {
  color: var(--primary-color) !important;
  font-weight: 500;
  text-decoration: none;
}

.read-topic-btn:hover,
.text-indigo-500:hover {
  color: #3730a3 !important; /* Darker indigo */
  text-decoration: underline;
}

/* Search Inputs */
input[type="text"] {
  border-radius: 9999px; /* Full pill shape */
  border: 2px solid #d1d5db; /* Gray-300 */
  padding: 1rem 1.5rem;
  font-size: 1rem;
  transition: var(--transition);
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); /* Glow ring */
  transform: scale(1.01); /* Subtle expand */
}

/* Search Dropdown */
.search-dropdown {
  border: 1px solid #e5e7eb;
  box-shadow: var(--shadow-md);
  max-height: 240px; /* 60 * 4 for better sizing */
}

.search-dropdown div {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.search-dropdown div:hover {
  background-color: #f3f4f6; /* Gray-100 */
  color: var(--primary-color);
}

/* Detail Views (Topic/Med) */
#topic-view-section,
#med-list div.bg-white { /* Target detail containers */
  animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

img {
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  max-width: 100%;
  height: auto;
}

/* Back Buttons */
#back-to-library-btn,
#med-back-btn {
  color: var(--primary-color);
  font-weight: 500;
  padding: 0.5rem 0;
  border-bottom: 1px solid transparent;
  transition: var(--transition);
}

#back-to-library-btn:hover,
#med-back-btn:hover {
  border-bottom-color: var(--primary-color);
  color: #3730a3;
}

/* Loading States */
.text-center.text-gray-500 {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

/* Simple Spinner for Loading */
.loading-spinner {
  border: 4px solid #f3f4f6;
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Q-Bank Specific (if implemented) */
#qbank-content .card {
  background: linear-gradient(135deg, white 0%, #f0f9ff 100%); /* Light blue tint */
}

/* Footer Enhancements */
footer {
  background: linear-gradient(135deg, white 0%, #f8fafc 100%);
  border-top: 1px solid #e5e7eb;
}

footer a {
  color: #6b7280;
  text-decoration: none;
  transition: var(--transition);
}

footer a:hover {
  color: var(--primary-color);
  text-shadow: 0 0 4px rgba(79, 70, 229, 0.3); /* Glow on hover */
}

footer ul {
  list-style: none;
  padding: 0;
}

footer li {
  margin-bottom: 0.5rem;
}

/* Prose (for content like About/Topics) */
.prose {
  color: #4b5563; /* Gray-600 */
  max-width: none;
}

.prose h3 {
  color: var(--primary-color);
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.prose ul {
  padding-left: 1.5rem;
}

.prose li {
  margin-bottom: 0.5rem;
}

/* Mobile-Specific Tweaks */
@media (max-width: 640px) {
  .nav-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }
  
  h2 {
    font-size: 1.875rem;
  }
  
  .grid-cols-1 {
    gap: 1rem;
  }
}

/* High Contrast Mode Support (Accessibility) */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #1e40af; /* Darker for contrast */
    --text-primary: #000;
  }
  
  .bg-white {
    border: 2px solid #000;
  }
}

/* Home Page Adaptations */
#home-section .bg-indigo-600 {
  background: linear-gradient(135deg, var(--primary-color) 0%, #3730A3 100%);
}

#home-section blockquote {
  transition: var(--transition);
}

#home-section blockquote:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

#home-section ul li, #home-section ol li {
  padding-left: 0.5rem;
}

/* Stats Loading State */
#home-section #library-count:empty,
#home-section #med-count:empty {
  color: var(--text-primary);
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  #home-section h1 { font-size: 2.5rem; line-height: 1.1; }
  #home-section h2 { font-size: 2rem; }
  #home-section .grid { gap: 1rem; }
  #home-section button { min-height: 44px; } /* Touch-friendly */
}


/* Medcribe Card Enhancements */
#med-list .bg-white {
  min-height: 200px; /* Minimum card height to prevent "small" short cards */
}

#med-list h3 {
  line-height: 1.3; /* Better spacing for long drug names */
  word-break: break-word; /* Handles long names without overflow */
}

#med-list p {
  line-height: 1.5; /* More readable text */
}

/* Mobile-Specific: Larger Touch Targets & Padding */
@media (max-width: 640px) { /* Tailwind 'sm' breakpoint */
  #med-list {
    gap: 1rem; /* Tighter but not cramped */
  }
  
  #med-list .p-6 {
    padding: 1.25rem; /* Slightly larger on mobile */
  }
  
  #med-list h3 {
    font-size: 1.25rem; /* Bigger on small screens */
  }
  
  #med-list .text-base {
    font-size: 1rem; /* Ensure text doesn't shrink */
  }
}

/* Tablet/Desktop: Spacious Layout */
@media (min-width: 768px) { /* Tailwind 'md' */
  #med-list {
    gap: 1.5rem;
  }
  
  #med-list .bg-white {
    min-height: 250px; /* Taller on larger screens */
  }
}

/* Loading Spinner (If Needed for Medcribe) */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #4F46E5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
/* Loading Spinner (For Navigation Overlay) */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #4F46E5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Medcribe Cards Larger (Responsive) */
#med-list .bg-white {
  min-height: 200px; /* Prevents small cards */
}

#med-list h3 {
  line-height: 1.3;
  word-break: break-word;
}

#med-list p {
  line-height: 1.5;
}

/* Mobile: Larger Padding/Touch */
@media (max-width: 640px) {
  #med-list {
    gap: 1rem;
  }
  #med-list .p-6 {
    padding: 1.25rem;
  }
  #med-list h3 {
    font-size: 1.25rem;
  }
}

/* Desktop: Spacious */
@media (min-width: 768px) {
  #med-list {
    gap: 1.5rem;
  }
  #med-list .bg-white {
    min-height: 250px;
  }
}
/* Library Layout */
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}

.topic-card {
  background: #fff;
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.topic-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: #f9fafb;
  border-right: 1px solid #e5e7eb;
  padding: 1rem;
}
.sidebar h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.sidebar ul {
  list-style: none;
  padding: 0;
}
.sidebar ul li a {
  color: #374151;
  text-decoration: none;
  display: block;
  padding: 0.25rem 0;
}
.sidebar ul li a:hover {
  color: #4f46e5;
}

/* Main Content */
.main-content {
  flex-grow: 1;
  padding: 2rem;
}
.no-content {
  color: #6b7280;
  font-style: italic;
}
.disclaimer {
  margin-top: 2rem;
  font-size: 0.875rem;
  color: #6b7280;
  border-top: 1px solid #e5e7eb;
  padding-top: 1rem;
}
