/* 
  PharmX Drug Pronunciation - Design System & Styles
  Modern, accessible, and robust.
*/

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

:root {
  /* Color Palette - Professional Healthcare Neutral */
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-text-main: #0f172a;
  --color-text-muted: #64748b;
  --color-primary: #0284c7; /* Sky 600 */
  --color-primary-dark: #0369a1; /* Sky 700 */
  --color-primary-light: #e0f2fe; /* Sky 100 */
  --color-border: #e2e8f0;
  --color-focus-ring: rgba(2, 132, 199, 0.4);
  --color-error: #ef4444;
  
  /* Spacing Scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Typography */
  --font-family: 'Figtree', system-ui, -apple-system, sans-serif;
  --font-size-base: 1rem;
  --font-size-sm: 0.875rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-medium: 250ms ease;

  /* Shadows */
  --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);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layout */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* Header */
.site-header {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--color-border);
  width: 100%;
  background: rgba(255, 255, 255, 0.8);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(5px);
}

.nav {
  width: 100%;
  max-width: 1200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
  text-decoration: none;
  color: var(--color-text-main);
  font-size: 1.5rem;
}

/* Hero Section */
.hero {
  padding: var(--space-3xl) 0 var(--space-2xl);
  text-align: center;
}

.hero-title {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-lg);
  color: var(--color-text-main);
}

.hero-subtitle {
  font-size: var(--font-size-lg);
  color: var(--color-text-muted);
  max-width: 600px;
  margin: 0 auto var(--space-xl);
}

/* Search Component */
.search-container {
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: var(--space-lg);
  color: var(--color-text-muted);
  pointer-events: none;
  width: 20px;
  height: 20px;
}

.search-input {
  width: 100%;
  padding: var(--space-lg) var(--space-lg) var(--space-lg) 3rem;
  font-size: var(--font-size-lg);
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  background-color: var(--color-surface);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-focus-ring);
}

.search-status {
  margin-top: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  min-height: 1.5em;
}

/* Drug Grid */
.drug-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-md);
  padding-bottom: var(--space-3xl);
}

/* Drug Card */
.drug-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: var(--space-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.drug-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.drug-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-focus-ring);
  border-color: var(--color-primary);
}

.drug-name {
  font-weight: 600;
  font-size: var(--font-size-lg);
  color: var(--color-text-main);
  text-transform: capitalize;
}

.play-icon {
  color: var(--color-primary);
  opacity: 0.8;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}

.drug-card:hover .play-icon {
  opacity: 1;
}

/* Playing State */
.drug-card.is-playing {
  background-color: var(--color-primary-light);
  border-color: var(--color-primary);
}

.drug-card.is-playing .play-icon {
  animation: pulse 1.5s infinite;
}

/* Loading State */
.drug-card.is-loading {
  cursor: wait;
  opacity: 0.7;
}

/* Error State */
.drug-card.is-error {
  border-color: var(--color-error);
  background-color: #fef2f2;
}

.drug-card.is-error .play-icon {
  color: var(--color-error);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) 0;
  color: var(--color-text-muted);
  grid-column: 1 / -1;
  display: none;
}

.empty-state.is-visible {
  display: block;
}

/* Footer */
.site-footer {
  margin-top: auto;
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-xl) 0;
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

/* Animations */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

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

/* Responsive */
.desktop-only {
  display: none;
}

@media (min-width: 640px) {
  .desktop-only {
    display: inline;
  }
}

@media (max-width: 640px) {
  :root {
    --font-size-3xl: 1.75rem;
  }
  
  .hero {
    padding: var(--space-xl) 0;
  }
  
  .drug-grid {
    grid-template-columns: 1fr;
  }
}

/* 404 Error Page */
.error-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  text-align: center;
}

.error-container {
  max-width: 400px;
}

.error-code {
  font-size: 6rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1;
  margin-bottom: var(--space-md);
}

.error-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.error-message {
  color: var(--color-text-muted);
  margin-bottom: var(--space-xl);
}

.error-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  background-color: var(--color-primary);
  color: white;
  text-decoration: none;
  border-radius: 0.75rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.error-button:hover {
  background-color: var(--color-primary-dark);
  transform: translateY(-1px);
}
