/**
 * TIMSS Farm Investigation Lab — Unified Dark Navy Design System Stylesheet
 * Aligned with Official TIMSS E-Assessment Dark Navy UI Standards
 */

:root {
  --primary-hue: 158;
  --primary: #10B981;
  --primary-hover: #059669;
  --primary-light: rgba(16, 185, 129, 0.16);
  --primary-glow: rgba(16, 185, 129, 0.25);

  --secondary-hue: 217;
  --secondary: #3B82F6;
  --secondary-light: rgba(59, 130, 246, 0.16);

  --accent-gold: #F59E0B;
  --accent-gold-light: rgba(245, 158, 11, 0.16);
  --danger: #EF4444;
  --danger-light: rgba(239, 68, 68, 0.16);
  --success: #10B981;
  --success-light: rgba(16, 185, 129, 0.2);

  --bg-main: #0c1524;
  --bg-surface: #132238;
  --bg-card: #182b47;
  --bg-card-light: #20375a;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #cbd5e1;

  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-focus: #10B981;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);

  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;

  --header-height: 72px;
  --actions-height: 74px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Cairo', 'Alexandria', 'IBM Plex Sans Arabic', 'Inter', system-ui, -apple-system, sans-serif;
  direction: rtl;
  text-align: right;
  background-color: var(--bg-main);
  background-image:
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.12) 0px, transparent 45%),
    radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.1) 0px, transparent 45%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  line-height: 1.65;
}

/* ==========================================================================
   Header & Sticky Top Bar
   ========================================================================== */
.lab-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--header-height);
  background: rgba(19, 34, 56, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow-sm);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #10B981, #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #f8fafc;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: #94a3b8;
}

.header-center-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 300px;
}

.progress-info-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.82rem;
  color: #cbd5e1;
  font-weight: 700;
}

.header-progress-track {
  width: 100%;
  height: 7px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.header-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10B981, #3B82F6);
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.track-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
}

.badge-learning {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-measurement {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-tool {
  background: #182b47;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  height: 40px;
  min-width: 40px;
  padding: 0 12px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.92rem;
  font-family: inherit;
  transition: all 0.15s ease;
}

.btn-tool:hover {
  background: #20375a;
  color: #f8fafc;
  transform: translateY(-1px);
}

.dropdown-menu-content {
  display: none;
  position: absolute;
  left: 0;
  top: 48px;
  background: #132238;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  min-width: 240px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  z-index: 1100;
  padding: 8px;
}

.dropdown-menu-content.show {
  display: block;
}

.dropdown-item,
.experiment-switcher-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 10px;
  transition: background 0.15s ease;
}

.dropdown-item:hover,
.experiment-switcher-item:hover {
  background: #182b47;
  color: #f8fafc;
}

.dropdown-item.danger {
  color: #f87171;
}

.dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
}

.experiment-switcher-item.active-lab {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  font-weight: 800;
}

/* ==========================================================================
   Main Layout & Track Modal
   ========================================================================== */
.lab-main-container {
  flex: 1;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
  padding: 16px 24px;
  max-width: 1720px;
  margin: 0 auto;
  width: 100%;
}

.track-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(6, 11, 20, 0.82);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.track-modal-overlay.hidden {
  display: none !important;
}

.track-modal-dialog {
  background: #132238;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  max-width: 840px;
  width: 100%;
  padding: 36px 40px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.track-modal-header {
  text-align: center;
}

.track-modal-icon {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: linear-gradient(135deg, #10B981, #059669);
  color: #FFFFFF;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.28);
}

.track-modal-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #f8fafc;
}

.track-modal-subtitle {
  font-size: 0.95rem;
  color: #cbd5e1;
  margin-top: 6px;
}

.track-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.track-card {
  background: #182b47;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 24px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.track-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: var(--shadow-md);
}

.track-card.selected {
  border-color: #10B981;
  background: rgba(16, 185, 129, 0.12);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.track-card.card-measurement.selected {
  border-color: #3B82F6;
  background: rgba(59, 130, 246, 0.14);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.track-card-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
}

.track-card-badge.official {
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
}

.track-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}

.track-card-icon.learning {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
}

.track-card-icon.measurement {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
}

.track-card-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: #f8fafc;
}

.track-card-desc {
  font-size: 0.9rem;
  color: #cbd5e1;
  line-height: 1.6;
}

.track-card-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.track-card-features li {
  font-size: 0.84rem;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.track-card-features li i {
  color: #10B981;
}

.track-select-status {
  margin-top: 12px;
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(12, 21, 36, 0.65);
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.track-card.selected .track-select-status {
  background: #10B981;
  color: #FFFFFF;
}

.track-card.card-measurement.selected .track-select-status {
  background: #3B82F6;
  color: #FFFFFF;
}

.track-modal-actions {
  display: flex;
  justify-content: center;
}

.btn-start-track {
  background: linear-gradient(135deg, #10B981, #059669);
  color: #FFFFFF;
  border: none;
  padding: 14px 36px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  transition: all 0.15s ease;
}

.btn-start-track:hover {
  transform: translateY(-2px);
}

/* Sleek Floating Calculator */
.floating-calculator {
  position: fixed;
  top: 90px;
  left: 24px;
  width: 280px;
  background: #132238;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  box-shadow: 0 20px 40px -8px rgba(0, 0, 0, 0.6);
  z-index: 1500;
  padding: 16px;
  display: none;
  direction: ltr;
}

.floating-calculator.open {
  display: block;
}

.calc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.88rem;
  font-weight: 800;
  color: #f8fafc;
  direction: rtl;
}

.calc-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #182b47;
  border: none;
  color: #94a3b8;
  cursor: pointer;
}

.calc-display {
  background: #0c1524;
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 10px 14px;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.4rem;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 10px;
}

.calc-keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.calc-key {
  height: 42px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #182b47;
  color: #f8fafc;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.calc-key.op { background: rgba(59, 130, 246, 0.18); color: #93c5fd; border-color: rgba(59, 130, 246, 0.35); }
.calc-key.clear { background: rgba(239, 68, 68, 0.18); color: #fca5a5; border-color: rgba(239, 68, 68, 0.35); }
.calc-key.equals { background: linear-gradient(135deg, #10B981, #059669); color: #FFFFFF; border: none; }
