/* ==========================================================================
   Pediatric OSCE - Clean Minimal Stylesheet
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-muted: #f1f5f9;
  --bg-accent-subtle: #f1f5f9;
  
  --border-subtle: #e2e8f0;
  --border-hover: #cbd5e1;
  --border-strong: #94a3b8;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-50: #eff6ff;
  --primary-200: #bfdbfe;
  
  --accent-emerald: #059669;
  --accent-emerald-bg: #d1fae5;
  --accent-rose: #e11d48;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08);
  
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  
  --transition-fast: 150ms ease;
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --bg-muted: #334155;
  --bg-accent-subtle: #334155;
  
  --border-subtle: #334155;
  --border-hover: #475569;
  --border-strong: #64748b;
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  
  --primary-600: #38bdf8;
  --primary-700: #0284c7;
  --primary-50: #1e293b;
  --primary-200: #0369a1;
  
  --accent-emerald-bg: #064e3b44;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
}

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

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* Header */
.site-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-primary);
}

.brand-icon {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--primary-600);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background-color: var(--bg-muted);
  color: var(--text-primary);
}

/* Clean Top Controls Section */
.top-controls-section {
  padding: 1.25rem 1.25rem 0.5rem;
}

.controls-container {
  max-width: 1000px;
  margin: 0 auto;
}

.search-input-group {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 0.75rem;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  width: 1.1rem;
  height: 1.1rem;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.65rem 0.85rem 0.65rem 2.5rem;
  font-size: 0.9rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}

.search-input:focus {
  border-color: var(--primary-600);
}

.category-filter-bar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.category-btn {
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.category-btn:hover {
  background-color: var(--bg-muted);
  color: var(--text-primary);
}

.category-btn.active {
  background-color: var(--primary-600);
  color: #ffffff;
  border-color: var(--primary-600);
}

/* Main Content & Clean Grid */
.main-content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
  width: 100%;
  flex: 1;
}

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 0.75rem;
}

.topic-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  transition: all var(--transition-fast);
}

.topic-card:hover {
  border-color: var(--primary-600);
  background-color: var(--bg-card-hover);
  transform: translateY(-1px);
}

.topic-card-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.topic-icon-wrap {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-md);
  background-color: var(--bg-accent-subtle);
  color: var(--primary-600);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topic-icon-wrap svg {
  width: 1.25rem;
  height: 1.25rem;
}

.topic-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topic-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.topic-chevron {
  width: 1.1rem;
  height: 1.1rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.topic-card:hover .topic-chevron {
  color: var(--primary-600);
}

/* ==========================================================================
   Practice View (topic.html)
   ========================================================================== */

.practice-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.65rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.practice-top-bar {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
}

.back-btn:hover {
  background-color: var(--bg-muted);
  color: var(--text-primary);
}

.topic-heading-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1rem;
}

.topic-heading-inline svg {
  width: 1.15rem;
  height: 1.15rem;
  color: var(--primary-600);
}

/* Timer */
.timer-widget {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background-color: var(--bg-muted);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.timer-digits {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 3.2rem;
  text-align: center;
}

.timer-digits.urgent {
  color: var(--accent-rose);
}

.timer-btn {
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.timer-btn:hover {
  color: var(--text-primary);
}

/* Practice Container */
.practice-container {
  max-width: 900px;
  margin: 1rem auto;
  padding: 0 1.25rem;
  flex: 1;
  width: 100%;
}

.station-pills-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0.25rem 0 0.75rem;
  scrollbar-width: thin;
  margin-bottom: 0.75rem;
}

.station-pill {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.station-pill:hover {
  border-color: var(--primary-600);
  color: var(--primary-600);
}

.station-pill.active {
  background-color: var(--primary-600);
  border-color: var(--primary-600);
  color: #ffffff;
}

.station-pill.reviewed {
  border-color: var(--accent-emerald);
  background-color: var(--accent-emerald-bg);
  color: var(--accent-emerald);
}

/* Station Card */
.station-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.station-badge-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border-subtle);
}

.station-id-tag {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-600);
  background-color: var(--primary-50);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

[data-theme="dark"] .station-id-tag {
  background-color: rgba(56, 189, 248, 0.1);
}

.station-progress-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Station Body */
.station-body {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
}

.station-body p {
  margin-bottom: 0.85rem;
}

.station-body p > strong:first-child {
  color: var(--primary-600);
  font-weight: 700;
  margin-right: 0.25rem;
}

.station-body ol, .station-body ul {
  margin: 0.5rem 0 1rem 1.5rem;
}

.station-body li {
  margin-bottom: 0.4rem;
  line-height: 1.6;
}

/* OSCE Images */
.osce-image-wrapper {
  margin: 1rem 0;
  text-align: center;
}

.osce-img {
  max-width: 100%;
  max-height: 480px;
  object-fit: contain;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  cursor: zoom-in;
  background-color: #ffffff;
}

.osce-img-caption {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

th, td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

th {
  background-color: var(--bg-muted);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: none;
}

/* Answer Accordion */
.answer-section {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 1rem;
}

.toggle-ans-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background-color: var(--bg-muted);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.toggle-ans-btn:hover {
  background-color: var(--primary-600);
  color: #ffffff;
  border-color: var(--primary-600);
}

.toggle-ans-btn svg {
  width: 1rem;
  height: 1rem;
}

.answer-box {
  display: none;
  margin-top: 0.85rem;
  padding: 1.25rem 1.5rem;
  background-color: var(--bg-muted);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-emerald);
  border-radius: var(--radius-md);
  font-size: 0.925rem;
  line-height: 1.7;
}

.answer-box.open {
  display: block;
}

.answer-box p {
  margin-bottom: 0.75rem;
}

.answer-box p:last-child {
  margin-bottom: 0;
}

.answer-box p > strong:first-child {
  color: var(--accent-emerald);
  font-weight: 700;
  margin-right: 0.25rem;
}

.answer-box ul, .answer-box ol {
  margin: 0.4rem 0 0.85rem 1.5rem;
}

.answer-box li {
  margin-bottom: 0.35rem;
  line-height: 1.6;
}

.answer-header-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-emerald);
  margin-bottom: 0.85rem;
}

/* Nav Bar */
.practice-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.btn-nav:hover:not(:disabled) {
  background-color: var(--bg-muted);
  border-color: var(--border-hover);
}

.btn-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-nav-primary {
  background-color: var(--primary-600);
  color: #ffffff;
  border-color: var(--primary-600);
}

.btn-nav-primary:hover:not(:disabled) {
  background-color: var(--primary-700);
  color: #ffffff;
}

.mark-reviewed-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.mark-reviewed-wrapper input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent-emerald);
}

/* Lightbox Modal */
.lightbox-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.lightbox-modal.open {
  display: flex;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  text-align: center;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius-md);
  background-color: #fff;
}

.lightbox-caption {
  color: #f8fafc;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.lightbox-close {
  position: absolute;
  top: -2.25rem;
  right: 0;
  color: #ffffff;
  font-size: 1.75rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
}

/* Footer */
.site-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 1.25rem;
  margin-top: auto;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-container {
  max-width: 1000px;
  margin: 0 auto;
}

/* Responsive */
@media (max-width: 640px) {
  .topics-grid {
    grid-template-columns: 1fr;
  }
  .station-card {
    padding: 1rem;
  }
}
