/**
 * style.css
 * Responsive, Mobile- and Tablet-First Medical Radiology UI Design System.
 * Taibah University Brand Palette: Deep Medical Blue (#003366, #005A9C), Gold Accent (#FDB813, #E5A800), Teal (#2A9D8F), Crimson (#E63946).
 */

:root {
  --primary: #003366;
  --primary-light: #005A9C;
  --primary-dark: #001F3F;
  --accent: #FDB813;
  --accent-hover: #E5A800;
  --success: #28a745;
  --success-bg: #e8f5e9;
  --warning: #f39c12;
  --warning-bg: #fff8e1;
  --danger: #e63946;
  --danger-bg: #ffebee;
  --info: #0288d1;
  --info-bg: #e1f5fe;
  
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --border-focus: #005A9C;
  
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-inverse: #ffffff;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --font-sans: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;
  --header-height: 64px;
}

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

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

a {
  color: var(--primary-light);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-dark);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--primary);
  font-weight: 700;
  line-height: 1.3;
}

h1 { font-size: 1.85rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

/* Layout & Container */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
}

/* App Header & Navbar */
.main-header,
.app-header {
  min-height: var(--header-height);
  background: linear-gradient(135deg, #001F3F 0%, #003366 60%, #005A9C 100%) !important;
  color: #ffffff !important;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 14px rgba(0, 31, 63, 0.25);
  padding: 10px 24px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #ffffff !important;
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
}

.brand-logo {
  font-size: 1.8rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff !important;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.8rem;
  color: #cbd5e1 !important;
  font-weight: 500;
  margin-top: 2px;
}

.brand-badge {
  background-color: var(--accent);
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.user-nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.12);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
}

.user-role-badge {
  background: var(--accent);
  color: var(--primary-dark);
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  min-height: 42px;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--primary-light);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.btn-accent {
  background-color: var(--accent);
  color: var(--primary-dark);
}
.btn-accent:hover {
  background-color: var(--accent-hover);
}

.btn-secondary {
  background-color: var(--surface);
  color: var(--text-main);
  border-color: var(--border);
}
.btn-secondary:hover {
  background-color: var(--surface-alt);
  border-color: var(--border-focus);
}

.btn-danger {
  background-color: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  min-height: 32px;
}

.btn-block {
  width: 100%;
}

/* Cards & Surfaces */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 20px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
  margin-bottom: 16px;
}

/* Overview Statistics Grid & Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-top: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.07);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-top: 4px solid #2563eb;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.1);
}

.stat-card:nth-child(1) { border-top-color: #2563eb; }
.stat-card:nth-child(2) { border-top-color: #0891b2; }
.stat-card:nth-child(3) { border-top-color: #059669; }
.stat-card:nth-child(4) { border-top-color: #d97706; }
.stat-card:nth-child(5) { border-top-color: #7c3aed; }

.stat-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
  margin-bottom: 6px;
  font-family: 'JetBrains Mono', monospace, -apple-system, sans-serif;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Form Elements */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--surface);
  color: var(--text-main);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0, 90, 156, 0.15);
}

/* 12-Lab Modular Grid */
.labs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin: 24px 0;
}

.lab-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.lab-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-light), var(--accent));
}

.lab-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.lab-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.week-badge {
  background: rgba(0, 90, 156, 0.1);
  color: var(--primary-light);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.clo-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.lab-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.lab-topic {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  min-height: 40px;
}

.progress-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 0.75rem;
  flex-wrap: wrap;
}

.pill {
  padding: 4px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.pill.completed {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(40, 167, 69, 0.3);
}

/* Tabbed Lab Workspace: 6-Stage Step Navigation */
.tab-nav-bar,
.tabs-nav {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  background: var(--surface-alt);
  padding: 8px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab-nav-bar.arm-control {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 10px 12px;
  min-height: 70px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.tab-btn:hover {
  background: #ffffff;
  border-color: #93c5fd;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
}

.tab-btn.active {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 3px 12px -2px rgba(0, 51, 102, 0.18);
}

.tab-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
}

.tab-btn.locked {
  opacity: 0.65;
  cursor: not-allowed;
  background: rgba(241, 245, 249, 0.7);
  border-color: #e2e8f0;
  box-shadow: none;
}

.tab-btn.locked:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  transform: none;
  box-shadow: none;
}

.tab-btn-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 4px;
  margin-bottom: 6px;
}

.tab-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 51, 102, 0.08);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace, sans-serif;
  flex-shrink: 0;
}

.tab-btn.active .tab-num {
  background: var(--primary);
  color: #ffffff;
}

.tab-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.25;
  word-break: normal;
  overflow-wrap: break-word;
  width: 100%;
}

.tab-btn.active .tab-title {
  color: var(--primary);
  font-weight: 700;
}

.tab-btn.locked .tab-title {
  color: #94a3b8;
}

.tab-lock-badge {
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 10px;
  background: #f1f5f9;
  color: #64748b;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
}

.tab-btn.locked .tab-lock-badge {
  background: #fee2e2;
  color: #ef4444;
}

.tab-btn.unlocked-paired {
  border: 1.5px dashed var(--primary-light);
}

@media (max-width: 900px) {
  .tab-nav-bar,
  .tabs-nav {
    grid-template-columns: repeat(6, minmax(130px, 1fr));
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }
  .tab-nav-bar.arm-control {
    grid-template-columns: repeat(5, minmax(130px, 1fr));
  }
}

.excel-dropzone {
  border: 2px dashed #0284c7;
  background: #f0f9ff;
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.excel-dropzone:hover {
  background: #e0f2fe;
  border-color: #0369a1;
}

.evaluation-card,
.ai-evaluation-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-top: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-top: 20px;
  box-shadow: 0 4px 16px -2px rgba(0, 51, 102, 0.10);
}

.rubric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.9rem;
}

.rubric-row:last-child {
  border-bottom: none;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.25s ease-in-out;
}

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

/* Quiz & MCQ View */
.quiz-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 20px;
}

.question-item {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.question-item:last-child {
  border-bottom: none;
}

.question-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.92rem;
}

.option-label:hover {
  background: #eef5fc;
  border-color: var(--primary-light);
}

.option-label input[type="radio"] {
  accent-color: var(--primary-light);
  width: 18px;
  height: 18px;
}

.option-label.selected {
  background: #e1effe;
  border-color: var(--primary-light);
  font-weight: 600;
}

.option-label.correct {
  background: var(--success-bg);
  border-color: var(--success);
  color: #1e4620;
}

.option-label.incorrect {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: #5c181f;
}

.explanation-box {
  background: #f8fafc;
  border-left: 4px solid var(--info);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  font-size: 0.88rem;
}

/* Simulation Canvas & Workstation */
.sim-container {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 960px) {
  .sim-container {
    grid-template-columns: 1fr;
  }
}

.sim-canvas-wrapper {
  background: #0f172a;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.sim-canvas {
  width: 100%;
  height: 100%;
  min-height: 420px;
  display: block;
}

.sim-control-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
}

.slider-val {
  color: var(--primary-light);
  font-family: var(--font-mono);
  font-weight: 700;
}

input[type="range"] {
  accent-color: var(--primary-light);
  height: 6px;
  border-radius: 4px;
  cursor: pointer;
}

/* Instructor Dashboard & Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
}

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

.data-table th, .data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--surface-alt);
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.data-table tr:hover {
  background: rgba(0, 90, 156, 0.03);
}

/* Footer */
.app-footer {
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ============================================================
   Lab Quality & Usability Improvements (Wave 1–4)
   ============================================================ */

/* Issue 3.4: Responsive simulation workbench grid
   Applied when JS renders: style="display:grid; grid-template-columns: 1fr 340px"
   Override via class at narrow viewports */
.simulation-workbench-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}

@media (max-width: 960px) {
  .simulation-workbench-grid {
    grid-template-columns: 1fr;
  }
}

/* Progress bar animation for colony scoring phases */
@keyframes progress-fill {
  from { width: 0%; }
  to   { width: 100%; }
}

.exposure-progress-bar {
  height: 6px;
  border-radius: 4px;
  background: var(--primary-light);
  animation: progress-fill linear forwards;
}

/* Worksheet field validation highlight */
.ws-field.invalid {
  border-color: var(--danger) !important;
  background: var(--danger-bg) !important;
}

/* Inline notification banners (replaces alert() dialogs) */
.inline-notice {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.inline-notice.error {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  color: #7f1d1d;
}

.inline-notice.success {
  background: var(--success-bg);
  border: 1px solid var(--success);
  color: #14532d;
}

.inline-notice.warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  color: #78350f;
}

.inline-notice.info {
  background: var(--info-bg);
  border: 1px solid var(--info);
  color: #0c4a6e;
}

/* Unanswered question highlight */
.question-item.unanswered {
  border: 2px solid var(--danger) !important;
  background: var(--danger-bg) !important;
  border-radius: var(--radius-md);
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Progress step indicator in lab header */
.lab-progress-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.lab-progress-step {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.lab-progress-step.done {
  color: var(--success);
}

.lab-progress-step.active {
  color: var(--primary);
}

.lab-progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}

.lab-progress-dot.done {
  background: var(--success);
}

.lab-progress-dot.active {
  background: var(--primary);
}

