/* --- Variables --- */
:root {
  --bg-color: #FFFFFF;
  --card-border: #E7E8EC;
  --divider: #EEF0F3;
  --text-main: #0B0B0F;
  --text-secondary: #5B6070;
  --muted: #8A8F9C;
  --primary-blue: #5D75E6;
  --primary-blue-hover: #4A62D1;
  --dark-button: #0B0B0F;
  --input-fill: #DCDCDF;
  --input-border-focus: #5D75E6;
  
  --chip-green-bg: #DDF5E5;
  --chip-green-text: #1E8E4E;
  --chip-amber-bg: #FFF8E6;
  --chip-amber-text: #8A5A00;
  --amber-border: #F59E0B;
  
  --tag-purple-bg: #EFEBFE;
  --tag-purple-text: #6A4BE0;
  --tag-blue-bg: #E8EEFD;
  --tag-blue-text: #3D63DD;
  --tag-yellow-bg: #FDF2C9;
  --tag-yellow-text: #A8731A;
  
  --font-heading: 'Poppins', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Base & Reset --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--text-main);
  background-color: var(--bg-color);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input { font-family: inherit; }

/* --- Layout --- */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 48px;
  display: grid;
  grid-template-columns: 40% 1fr;
  gap: 64px;
}

.left-col {
  position: sticky;
  top: 40px;
  height: fit-content;
}

/* Left Column Styling */
.logo-area { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.logo-text { font-weight: 600; font-size: 16px; }
.headline {
  font-family: var(--font-heading);
  font-size: 60px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}
.intro-text { color: var(--text-secondary); font-size: 16px; max-width: 400px; }

/* Right Column Styling */
.top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
  gap: 16px;
  flex-wrap: wrap;
}
.inputs-group { display: flex; gap: 16px; flex: 1; }
.input-wrapper { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.input-wrapper label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.input-wrapper input {
  background: var(--input-fill);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-main);
  transition: all 0.2s;
}
.input-wrapper input:focus {
  background: var(--bg-color);
  border-color: var(--input-border-focus);
  outline: none;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border-radius: 999px;
  font-weight: 600; font-size: 14px; transition: background 0.2s, color 0.2s;
  gap: 8px; text-decoration: none;
  white-space: nowrap; /* Forces text to stay on one line */
}
.btn-dark { background: var(--dark-button); color: white; }
.btn-dark:hover { background: #333; }
.btn-blue { background: var(--primary-blue); color: white; }
.btn-blue:hover { background: var(--primary-blue-hover); }
.btn-outline { background: transparent; border: 1px solid var(--card-border); color: var(--text-main); }
.btn-outline:hover { background: var(--divider); }
.btn-text { color: var(--text-secondary); font-size: 14px; font-weight: 500; white-space: nowrap; }
.btn-text:hover { color: var(--text-main); }
.btn-link { color: var(--muted); font-size: 12px; text-decoration: underline; background: none; border: none; cursor: pointer; white-space: nowrap; }
.btn-link:hover { color: var(--text-main); }

/* Cards & Sections */
#sections-container { display: flex; flex-direction: column; gap: 24px; margin-bottom: 24px; }
.section-card {
  background: var(--bg-color);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 32px;
}
.section-header { margin-bottom: 24px; position: relative; }
.tag-pill {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600; text-transform: uppercase;
  margin-bottom: 12px;
}
.tag-purple { background: var(--tag-purple-bg); color: var(--tag-purple-text); }
.tag-blue { background: var(--tag-blue-bg); color: var(--tag-blue-text); }
.tag-yellow { background: var(--tag-yellow-bg); color: var(--tag-yellow-text); }

.section-title { font-size: 20px; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 12px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 500; white-space: nowrap; }
.badge-amber { background: var(--chip-amber-bg); color: var(--chip-amber-text); }
.section-desc { font-size: 14px; color: var(--text-secondary); }
.divider { height: 1px; background: var(--divider); margin: 24px 0; }

/* Sliders */
.slider-row {
  margin-bottom: 32px;
  padding: 16px;
  border-radius: 12px;
  border-left: 3px solid transparent;
  transition: background 0.3s, border-color 0.3s;
}
.slider-row:last-child { margin-bottom: 0; }
.slider-row.highlight-unanswered {
  background: var(--chip-amber-bg);
  border-left-color: var(--amber-border);
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 16px;
}
.side-label { display: flex; flex-direction: column; }
.side-label.right { text-align: right; }
.label-title { font-size: 14px; font-weight: 500; color: var(--text-secondary); transition: color 0.2s, font-weight 0.2s; display: flex; align-items: center; gap: 6px; }
.side-label.right .label-title { justify-content: flex-end; }
.label-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Active label states */
.label-title.active { font-weight: 600; color: var(--text-main); }
.label-title.inactive { color: var(--muted); }
.dot-indicator { width: 6px; height: 6px; border-radius: 50%; background: var(--primary-blue); display: none; }
.label-title.active .dot-indicator { display: inline-block; }

.chip {
  font-family: var(--font-mono); font-size: 11px; padding: 4px 10px; border-radius: 999px;
  background: var(--divider); color: var(--text-secondary); text-align: center;
  white-space: nowrap; /* Forces text to stay on one line */
}
.chip-amber { background: var(--chip-amber-bg); color: var(--chip-amber-text); }
.chip-green { background: var(--chip-green-bg); color: var(--chip-green-text); }

/* Track Redesign - Segmented Buttons */
.track-bg {
  display: flex;
  width: 100%;
  height: 24px;
  background: var(--bg-color);
  border: 1px solid var(--muted); /* Updated from previous step */
  border-radius: 12px;
  overflow: hidden;
}
.segment {
  flex: 1;
  background: transparent;
  border: none;
  border-right: 1px solid var(--muted); /* Updated from previous step */
  cursor: pointer;
  transition: background 0.2s;
}
.segment:last-child { border-right: none; }
.segment:hover { background: var(--divider); }
.segment.active { background: var(--primary-blue); }
.segment:focus-visible {
  outline: 3px solid var(--primary-blue-hover);
  outline-offset: -3px;
  position: relative;
  z-index: 10;
}

/* Progress Card */
.progress-card {
  background: var(--bg-color); border: 1px solid var(--card-border);
  border-radius: 16px; padding: 24px 32px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: nowrap; /* Forces everything to stay on one line */
  gap: 16px;
}
.progress-info { 
  display: flex; align-items: center; gap: 16px; 
  white-space: nowrap; 
  flex-wrap: nowrap;
}
.progress-title { font-weight: 600; font-size: 16px; }
.progress-actions { 
  display: flex; align-items: center; gap: 16px; 
  flex-shrink: 0; /* Prevents the buttons from getting squished */
}
.progress-info { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.progress-title { font-weight: 600; font-size: 16px; white-space: nowrap; }
.progress-actions { display: flex; align-items: center; gap: 16px; }

/* Dropdown */
.dropdown-wrapper { position: relative; }
.dropdown-menu {
  position: absolute; bottom: 110%; right: 0; background: var(--bg-color);
  border: 1px solid var(--card-border); border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  list-style: none; padding: 8px 0; min-width: 160px; z-index: 100;
}
.dropdown-menu.hidden { display: none; }
.dropdown-menu button {
  width: 100%; text-align: left; padding: 8px 16px; font-size: 14px; color: var(--text-main); white-space: nowrap;
}
.dropdown-menu button:hover { background: var(--divider); }

/* Modal */
dialog {
  margin: auto; padding: 32px; border: none; border-radius: 16px;
  max-width: 480px; width: 90%; box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
dialog::backdrop { background: rgba(11, 11, 15, 0.4); backdrop-filter: blur(2px); }
.modal-content h2 { font-size: 20px; margin-bottom: 8px; }
.modal-content p { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }
.unanswered-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; max-height: 200px; overflow-y: auto; }
.unanswered-chip {
  background: var(--chip-amber-bg); color: var(--chip-amber-text);
  font-size: 12px; font-weight: 500; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--amber-border); cursor: pointer; transition: background 0.2s; white-space: nowrap;
}
.unanswered-chip:hover { background: #FDE68A; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* Toasts */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast {
  background: var(--text-main); color: white; padding: 12px 20px;
  border-radius: 8px; font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: slideIn 0.3s ease-out;
}
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Print Summary (Hidden on screen) */
#print-summary { display: none; }

/* Responsive */
@media (max-width: 1024px) {
  .container { grid-template-columns: 1fr; padding: 32px; gap: 48px; }
  .left-col { position: static; }
  .headline { font-size: 48px; }
}
@media (max-width: 640px) {
  .container { padding: 20px; }
  .headline { font-size: 40px; }
  .inputs-group { flex-direction: column; width: 100%; }
  .top-row { flex-direction: column; align-items: stretch; }
  .section-card { padding: 20px; }
  
  .slider-header { flex-direction: row; text-align: left; }
  .side-label.right { text-align: right; }
  
  .progress-card {
    position: fixed; bottom: 0; left: 0; right: 0;
    border-radius: 16px 16px 0 0; padding: 16px 20px; padding-bottom: calc(16px + env(safe-area-inset-bottom));
    flex-direction: column; gap: 16px; align-items: stretch; z-index: 50;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
  }
  .progress-info { flex-direction: column; gap: 4px; align-items: center; }
  .progress-actions { justify-content: space-between; }
  #app { padding-bottom: 120px; }
}

/* Print Styles */
@media print {
  body { background: white; color: black; }
  #app { display: none !important; }
  #print-summary { display: block; padding: 20px; font-family: 'Inter', sans-serif; }
  .print-header { margin-bottom: 30px; border-bottom: 2px solid black; padding-bottom: 10px; }
  .print-title { font-family: 'Poppins', sans-serif; font-size: 24px; margin-bottom: 5px; }
  .print-meta { font-size: 14px; color: #555; }
  .print-section { margin-bottom: 30px; }
  .print-section-title { font-size: 18px; font-weight: bold; margin-bottom: 15px; color: #333; }
  .print-row { display: grid; grid-template-columns: 1fr minmax(150px, 300px) 1fr; align-items: center; gap: 16px; margin-bottom: 15px; font-size: 12px; }
  .print-label { font-weight: bold; }
  .print-label.right { text-align: right; }
  
  /* Print Segment Styles */
  .print-track-bg {
    display: flex; height: 16px; width: 100%;
    border: 1px solid #ccc; border-radius: 8px; overflow: hidden;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .print-segment { flex: 1; border-right: 1px solid #ccc; background: transparent; }
  .print-segment:last-child { border-right: none; }
  .print-segment.active { background: #5D75E6 !important; } /* Force print background */
  
  .print-interpretation { grid-column: 1 / -1; text-align: center; font-style: italic; color: #666; font-size: 11px; margin-top: -5px; }
  .print-unanswered .print-interpretation { color: red; font-weight: bold; }
  @page { margin: 1.5cm; }
}