/* ==========================================================================
   Hippox Premium Design System
   ========================================================================== */

:root {
  /* --- Typography --- */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* --- Color Palette (Medical/Science) --- */
  /* Primary: Trustworthy Blue */
  --color-primary-50: #eff6ff;
  --color-primary-100: #dbeafe;
  --color-primary-500: #3b82f6;
  --color-primary-600: #2563eb;
  --color-primary-700: #1d4ed8;

  /* Secondary: Teal/Emerald (Clinical) */
  --color-secondary-50: #ecfdf5;
  --color-secondary-500: #10b981;
  --color-secondary-600: #059669;

  /* Backgrounds & Glass */
  --bg-app: #f8fafc;
  /* Slate-50 */
  --bg-surface: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);

  /* Text */
  --text-main: #0f172a;
  /* Slate-900 */
  --text-muted: #64748b;
  /* Slate-500 */

  /* --- Shadow Depth --- */
  --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);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
}

/* Base Reset & Typography */
body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

/* Glassmorphism Classes */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--glass-shadow);
}

/* --- Premium Chat Bubbles --- */
.chat-message-user {
  background: linear-gradient(135deg, var(--color-primary-600), var(--color-primary-500));
  color: white;
  border-radius: 1rem 1rem 0 1rem;
  box-shadow: var(--shadow-md);
  padding: 1rem 1.25rem;
}

.chat-message-assistant {
  background: var(--bg-surface);
  border: 1px solid var(--color-primary-100);
  border-radius: 1rem 1rem 1rem 0;
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.25rem;
  transition: all 0.3s ease;
}

.chat-message-assistant:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary-500);
}

/* --- Typography Improvements --- */
h1,
h2,
h3,
h4,
h5,
h6 {
  letter-spacing: -0.025em;
  font-weight: 700;
  color: var(--text-main);
}

p {
  line-height: 1.6;
  color: #334155;
}

/* --- Citation Styles --- */
.citation-link {
  color: var(--color-primary-600);
  font-weight: 600;
  text-decoration: none;
  background: var(--color-primary-50);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  transition: all 0.2s;
  cursor: pointer;
}

.citation-link:hover {
  background: var(--color-primary-100);
  transform: translateY(-1px);
}

/* Quartile Badges - Modern */
.quartile-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Citation Popover (Hover Card) --- */
.citation-popover {
  position: absolute;
  z-index: 9999;
  /* Top layer */
  width: 320px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  border: 1px solid #e2e8f0;
  padding: 16px;
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  /* Initially non-interactive */
}

.citation-popover.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.citation-popover h4 {
  margin: 0 0 8px 0;
  font-size: 1rem;
  line-height: 1.4;
  color: #1e293b;
}

.citation-popover .meta {
  font-size: 0.8rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.citation-popover .journal-name {
  font-weight: 600;
  color: #0f172a;
}

.citation-popover .snippet {
  font-size: 0.85rem;
  color: #475569;
  border-left: 3px solid #e2e8f0;
  padding-left: 8px;
  margin: 0;
  font-style: italic;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

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

/* --- Animations --- */
@keyframes fadeInSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

.animate-fade-in {
  animation: fadeInSlide 0.4s ease-out forwards;
}

/* --- Print Styles --- */
@media screen {
  #print-container {
    display: none;
  }
}

@media print {
  body>*:not(#print-container) {
    display: none !important;
  }

  #print-container {
    display: block !important;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    margin: 0;
    padding: 20px;
    background: white;
    color: black;
  }

  /* Print specific styling */
  .print-header {
    border-bottom: 2px solid #eee;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
  }

  .print-header .logo {
    font-size: 24px;
    font-weight: bold;
    color: #2563eb;
  }

  .print-header .meta {
    color: #666;
    font-size: 14px;
  }

  .print-section {
    margin-bottom: 2rem;
  }

  .print-section h2 {
    font-size: 18px;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    color: #333;
  }

  .source-item {
    margin-bottom: 0.5rem;
    font-size: 12px;
  }

  .print-footer {
    margin-top: 4rem;
    border-top: 1px solid #eee;
    padding-top: 1rem;
    text-align: center;
    font-size: 10px;
    color: #999;
  }
}