/**
 * Medical Content Styles
 * EXACT UWorld Medical Library styling
 * Clean, professional, readable
 */

/* Base Styles */
.article-content {
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #212529;
}

/* Paragraphs */
.article-content p {
  margin: 0 0 16px 0;
  line-height: 1.6;
}

/* Headings */
.article-content h1 {
  font-size: 24px;
  font-weight: 700;
  color: #212529;
  margin: 24px 0 16px 0;
  line-height: 1.3;
}

.article-content h2 {
  font-size: 20px;
  font-weight: 700;
  color: #212529;
  margin: 20px 0 12px 0;
  line-height: 1.3;
}

.article-content h3 {
  font-size: 18px;
  font-weight: 600;
  color: #212529;
  margin: 18px 0 12px 0;
  line-height: 1.3;
}

.article-content h4 {
  font-size: 16px;
  font-weight: 600;
  color: #212529;
  margin: 16px 0 10px 0;
  line-height: 1.3;
}

.article-content h5 {
  font-size: 14px;
  font-weight: 600;
  color: #212529;
  margin: 14px 0 8px 0;
  line-height: 1.3;
}

.article-content h6 {
  font-size: 14px;
  font-weight: 600;
  color: #6c757d;
  margin: 12px 0 8px 0;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Emphasis */
.article-content strong,
.article-content b {
  font-weight: 700;
  color: #212529;
}

.article-content em,
.article-content i {
  font-style: italic;
}

.article-content u {
  text-decoration: underline;
}

/* Links */
.article-content a {
  color: #2c7be5;
  text-decoration: none;
  cursor: pointer;
}

.article-content a:hover {
  color: #1e5fb8;
  text-decoration: underline;
}

/* Lists */
.article-content ul,
.article-content ol {
  margin: 0 0 16px 0;
  padding-left: 32px;
}

.article-content li {
  margin-bottom: 8px;
  line-height: 1.6;
}

.article-content ul ul,
.article-content ol ul,
.article-content ul ol,
.article-content ol ol {
  margin-top: 8px;
  margin-bottom: 8px;
}

/* Tables */
.article-content table {
  width: 100%;
  margin: 16px 0;
  border-collapse: collapse;
  border: 1px solid #dee2e6;
  background: #ffffff;
}

.article-content thead {
  background: #f8f9fa;
}

.article-content th {
  padding: 12px;
  font-weight: 700;
  text-align: left;
  border: 1px solid #dee2e6;
  color: #212529;
  font-size: 14px;
}

.article-content td {
  padding: 12px;
  border: 1px solid #dee2e6;
  color: #212529;
  font-size: 14px;
}

.article-content tbody tr:nth-child(even) {
  background: #f8f9fa;
}

.article-content tbody tr:hover {
  background: #e9ecef;
}

/* Images */
.article-content img {
  max-width: 100%;
  height: auto;
  margin: 16px 0;
  border-radius: 4px;
  border: 1px solid #dee2e6;
}

/* Figures */
.article-content figure {
  margin: 24px 0;
  text-align: center;
}

.article-content figcaption {
  font-size: 12px;
  color: #6c757d;
  margin-top: 8px;
  font-style: italic;
}

/* Blockquotes */
.article-content blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 4px solid #2c7be5;
  background: #f8f9fa;
  color: #495057;
  font-style: italic;
}

.article-content blockquote p {
  margin: 0;
}

/* Code */
.article-content code {
  background: #f8f9fa;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: #e83e8c;
}

.article-content pre {
  background: #f8f9fa;
  padding: 16px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid #dee2e6;
}

.article-content pre code {
  background: none;
  padding: 0;
  color: #212529;
}

/* Horizontal Rule */
.article-content hr {
  border: none;
  border-top: 2px solid #dee2e6;
  margin: 24px 0;
}

/* Subscript & Superscript */
.article-content sub,
.article-content sup {
  font-size: 11px;
  line-height: 0;
}

/* Definitions */
.article-content dl {
  margin: 16px 0;
}

.article-content dt {
  font-weight: 700;
  margin-top: 12px;
}

.article-content dd {
  margin: 4px 0 12px 24px;
}

/* Highlights (for future highlighting feature) */
.article-content .highlight {
  background: #fff3cd;
  padding: 2px 0;
  border-radius: 2px;
}

.article-content .highlight.yellow {
  background: #fff3cd;
}

.article-content .highlight.green {
  background: #d4edda;
}

.article-content .highlight.blue {
  background: #d1ecf1;
}

.article-content .highlight.pink {
  background: #f8d7da;
}

/* Special Medical Content Classes */
.article-content .clinical-pearl {
  background: #e8f4ff;
  border-left: 4px solid #2c7be5;
  padding: 16px;
  margin: 16px 0;
  border-radius: 4px;
}

.article-content .warning {
  background: #fff3cd;
  border-left: 4px solid #ffc107;
  padding: 16px;
  margin: 16px 0;
  border-radius: 4px;
}

.article-content .note {
  background: #f8f9fa;
  border-left: 4px solid #6c757d;
  padding: 16px;
  margin: 16px 0;
  border-radius: 4px;
}

/* Flashcard Content Styles - Override poor contrast colors */
.flashcard-content strong,
.flashcard-content b {
  color: #58a6ff !important; /* Bright blue for dark mode */
  font-weight: 700;
}

.flashcard-content em,
.flashcard-content i {
  color: #ffa657 !important; /* Orange for emphasis */
  font-style: italic;
}

.flashcard-content u {
  color: #79c0ff !important; /* Light blue for underline */
  text-decoration: underline;
}

/* Override any inline blue colors that have poor contrast */
.flashcard-content [style*='color: blue'],
.flashcard-content [style*='color: rgb(0, 0, 255)'],
.flashcard-content [style*='color:#0000FF'] {
  color: #58a6ff !important;
}

/* Make sure all text in flashcards is readable */
.flashcard-content {
  color: var(--text-primary);
}

.flashcard-content p {
  color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
  .article-content {
    font-size: 14px;
  }

  .article-content h1 {
    font-size: 22px;
  }

  .article-content h2 {
    font-size: 18px;
  }

  .article-content h3 {
    font-size: 16px;
  }

  .article-content table {
    font-size: 13px;
  }

  .article-content th,
  .article-content td {
    padding: 8px;
  }
}

/* ========================================
   CRITICAL MOBILE VIEWPORT FIXES
   ======================================== */

/* Force mobile viewport - prevent desktop view on phones */
* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden; /* Prevent page-level horizontal scroll */
  position: relative;
}

/* Mobile-specific fixes */
@media screen and (max-width: 768px) {
  /* Force all elements to respect viewport width */
  * {
    max-width: 100vw;
  }

  /* Prevent page-level horizontal scroll only */
  body {
    overflow-x: hidden !important;
  }

  /* Ensure article content is mobile-friendly */
  .article-content {
    font-size: 14px;
    line-height: 1.6;
    max-width: 100%;
    overflow-x: hidden;
  }

  .article-content img {
    max-width: 100% !important;
    height: auto !important;
    display: block;
  }

  .article-content table {
    font-size: 12px;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  /* Flashcard mobile optimizations */
  .flashcard-content {
    font-size: 14px;
    line-height: 1.5;
    max-width: 100%;
  }

  .flashcard-content img {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Quiz interface mobile optimizations */
  .quiz-content {
    font-size: 14px;
    max-width: 100%;
  }

  .quiz-content img {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Ensure inputs don't cause zoom on iOS */
  input,
  textarea,
  select,
  button {
    font-size: 16px !important;
  }

  /* Prevent horizontal scroll from any source */
  .overflow-x-auto {
    max-width: 100vw;
  }
}

/* Extra small devices (phones in portrait, less than 576px) */
@media screen and (max-width: 575px) {
  html {
    font-size: 14px;
  }

  body {
    font-size: 14px;
  }

  /* Ensure all content fits on small screens */
  * {
    max-width: 100vw !important;
  }
}
