/* =============================================================================
   AnketWeb - Modern CSS with Theme Support
   ============================================================================= */

:root {
  /* LIGHT MODE VARIABLES */
  --bg-color: #f6f8fa;
  /* Light gray background */
  --card-bg: #ffffff;
  /* White card */
  --text-color: #24292f;
  /* Dark text */
  --primary-color: #0969da;
  /* Blue button */
  --primary-hover: #0550ae;
  --secondary-color: #57606a;
  /* Muted text */
  --success-color: #1a7f37;
  /* Green */
  --border-color: #d0d7de;
  /* Light borders */
  --shadow-color: rgba(31, 35, 40, 0.12);
  --input-bg: #ffffff;
  /* White inputs */
}

[data-theme="dark"] {
  /* DARK MODE VARIABLES (GitHub Dark Palette) */
  --bg-color: #161b22;
  /* Page Background */
  --card-bg: #21262d;
  /* Card Background */
  --text-color: #c9d1d9;
  /* Main Text */
  --primary-color: #1f6feb;
  /* Bright Blue Button/Links */
  --primary-hover: #388bfd;
  --secondary-color: #8b949e;
  /* Muted Text */
  --success-color: #238636;
  /* Green */
  --border-color: #30363d;
  /* Borders */
  --shadow-color: rgba(1, 4, 9, 0.8);
  --input-bg: #0d1117;
  /* Input fields darker than card */
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color 0.3s, color 0.3s;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* MAIN CONTAINER */
main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  /* Changed from center to flex-start for top alignment */
  padding: 2rem 1rem;
  /* Increased top padding */
}

.container {
  width: 100%;
  max-width: 800px;
  /* Increased from 600px for wider card view */
  background-color: var(--card-bg);
  border-radius: 6px;
  /* Slightly squarer corners like screenshot */
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 24px var(--shadow-color);
  padding: 2.5rem;
  box-sizing: border-box;
  /* Ensure padding doesn't affect width */
}

.container.survey-wide {
  max-width: 936px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.logo-container {
  padding: 0.35rem;
  border-radius: 10px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 24px var(--shadow-color);
}

.logo-container.logo-placeholder {
  visibility: hidden;
  pointer-events: none;
}

.top-logo {
  height: 52px;
  width: auto;
  display: block;
}

.theme-toggle {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: linear-gradient(180deg, var(--card-bg) 0%, var(--input-bg) 100%);
  color: var(--text-color);
  font-size: 1.4rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px var(--shadow-color);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: theme-toggle-pulse 2.8s ease-in-out infinite;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: var(--primary-color);
  box-shadow: 0 10px 26px rgba(31, 111, 235, 0.28);
}

.theme-toggle:active {
  transform: translateY(0);
}

@keyframes theme-toggle-pulse {
  0% {
    box-shadow: 0 8px 24px var(--shadow-color);
  }

  50% {
    box-shadow: 0 8px 24px var(--shadow-color), 0 0 0 6px rgba(31, 111, 235, 0.12);
  }

  100% {
    box-shadow: 0 8px 24px var(--shadow-color);
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle {
    animation: none;
  }
}

/* STEPS / WIZARD */
.step {
  display: none;
  /* Hidden by default */
  animation: fadeIn 0.5s ease-in-out;
}

.step.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

h3 {
  margin-top: 0;
  color: var(--primary-color);
}

p {
  font-size: 14px;
  line-height: 1.5;
}

/* FORMS */
.form-group {
  margin-bottom: 1rem;
  /* Tighter spacing */
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-color);
}

/* Common Input Styles */
input[type="text"],
input[type="email"],
input[type="tel"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--input-bg);
  color: var(--text-color);
  font-size: 0.95rem;
  line-height: 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  /* CRITICAL for alignment */
}

input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.3);
}

.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.85rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

/* BUTTONS */
.btn {
  padding: 0.75rem 1.25rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.3, 0, 0.5, 1);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 1px solid transparent;
  /* Prepare for border */
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.btn-primary {
  background: linear-gradient(180deg, #1f6feb 0%, #0969da 100%);
  /* Gradient effect */
  color: white;
  width: 100%;
  /* Default full width for login, overriden in actions */
  box-shadow: 0 0 0 0 rgba(31, 111, 235, 0.4);
  /* Prepare for glow */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #388bfd 0%, #1f6feb 100%);
  box-shadow: 0 0 20px rgba(31, 111, 235, 0.5), 0 0 40px rgba(31, 111, 235, 0.3);
  /* Glow effect */
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 0 10px rgba(31, 111, 235, 0.4);
}

.btn-secondary {
  background-color: var(--input-bg);
  /* Use theme variable */
  border: 1px solid var(--border-color);
  color: var(--text-color);
  width: 100%;
}

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

/* Dark mode specific overrides for secondary button */
[data-theme="dark"] .btn-secondary {
  background-color: #21262d;
  border-color: var(--border-color);
}

[data-theme="dark"] .btn-secondary:hover:not(:disabled) {
  background-color: #30363d;
  border-color: #8b949e;
}

/* SURVEY ITEMS */
.survey-header {
  text-align: left;
  margin-bottom: 2rem;
}

.survey-header-top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

#progress-text,
#question-category {
  margin: 0;
}

.progress-bar {
  height: 6px;
  background-color: var(--border-color);
  border-radius: 3px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--primary-color);
  width: 0%;
  transition: width 0.3s ease;
}

.slider-container {
  margin-bottom: 2rem;
  padding: 1rem;
  background-color: rgba(0, 0, 0, 0.02);
  border-radius: 8px;
}

#level-info {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
  width: 100%;
}

.level-option-box {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: 0 2px 12px var(--shadow-color);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, background-color 0.2s;
  white-space: normal;
  cursor: pointer;
  user-select: none;
}

.level-option-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(31, 111, 235, 0.15);
  border-color: var(--primary-color);
}

.level-option-box.selected {
  border-color: var(--primary-color);
  background-color: rgba(31, 111, 235, 0.08);
  box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.35), 0 4px 16px rgba(31, 111, 235, 0.15);
}

.level-option-box.selected .level-score {
  background: var(--primary-color);
  color: #ffffff;
}

.level-score {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary-color);
  background: rgba(31, 111, 235, 0.1);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  min-width: 24px;
  text-align: center;
  flex-shrink: 0;
  transition: background-color 0.2s, color 0.2s;
}

.level-text {
  font-size: 0.95rem;
  color: var(--text-color);
  line-height: 1.4;
  align-self: center;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-weight: bold;
}

.slider-label.current {
  color: var(--primary-color);
}

.slider-label.target {
  color: var(--success-color);
}

input[type="range"] {
  width: 100%;
  margin-bottom: 1rem;
  cursor: pointer;
  background: linear-gradient(to right,
      var(--primary-color) 0%,
      var(--primary-color) var(--range-progress, 0%),
      var(--border-color) var(--range-progress, 0%),
      var(--border-color) 100%);
  border-radius: 3px;
  /* Fix for dark mode track */
  -webkit-appearance: none;
  appearance: none;
  /* Standard property for compatibility */
}

/* Webkit Track */
input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: transparent;
  border-radius: 3px;
}

/* Webkit Thumb */
input[type="range"]::-webkit-slider-thumb {
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -5px;
  /* Centers thumb */
}


/* Firefox Track */
input[type="range"]::-moz-range-track {
  height: 6px;
  background: var(--border-color);
  border: none;
  border-radius: 3px;
}

/* Firefox Filled Progress */
input[type="range"]::-moz-range-progress {
  height: 6px;
  background: var(--primary-color);
  border: none;
  border-radius: 3px;
}

/* Firefox Thumb */
input[type="range"]::-moz-range-thumb {
  height: 16px;
  width: 16px;
  border-radius: 50%;
  border: none;
  background: var(--primary-color);
  cursor: pointer;
}


#slider-target {
  accent-color: var(--success-color);
  background: linear-gradient(to right,
      var(--success-color) 0%,
      var(--success-color) var(--range-progress, 0%),
      var(--border-color) var(--range-progress, 0%),
      var(--border-color) 100%);
}

#slider-target::-webkit-slider-thumb {
  background: var(--success-color);
}



#slider-target::-moz-range-progress {
  background: var(--success-color);
}

#slider-target::-moz-range-thumb {
  background: var(--success-color);
}


/* RESULT REPORT */
.report-shell {
  padding: 1.4rem;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0) 100%);
  box-sizing: border-box;
  max-width: 100%;
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.9rem;
  padding-bottom: 0.95rem;
  border-bottom: 1px solid rgba(31, 111, 235, 0.45);
  margin-bottom: 1.1rem;
}

.report-title {
  margin: 0;
  font-size: 1.95rem;
  color: var(--text-color);
  letter-spacing: -0.01em;
}

.report-subline {
  margin: 0.35rem 0 0;
  font-size: 1rem;
  color: var(--secondary-color);
}

.report-logo {
  width: 136px;
  max-width: 35%;
  border-radius: 4px;
}

.report-grid-top {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.95rem;
  margin-bottom: 0.95rem;
}

.report-panel {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.95rem;
  background: rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
  max-width: 100%;
}

.report-panel-title {
  margin: 0 0 0.7rem;
  color: var(--primary-color);
  text-align: left;
  font-size: 1.45rem;
}

.radar-wrap {
  width: 100%;
  min-height: 310px;
  height: 310px;
  position: relative;
}

#radarChart {
  width: 100% !important;
  height: 100% !important;
}

.score-panel {
  border-radius: 12px;
  border: 1px solid #1f6feb;
  background: linear-gradient(180deg, #0f4ca8 0%, #1081c9 100%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 0.95rem 0.9rem;
  box-sizing: border-box;
  max-width: 100%;
}

.score-label {
  margin: 0;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-size: 0.95rem;
}

.score-value {
  margin: 0.3rem 0 0.2rem;
  font-size: 3.85rem;
  font-weight: 800;
  line-height: 1;
}

.score-target {
  margin: 0;
  font-weight: 700;
  font-size: 1.02rem;
  opacity: 0.95;
}

.result-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.result-item {
  border-left: 4px solid #ef5350;
  border-radius: 10px;
  padding: 0.72rem;
  background: rgba(255, 255, 255, 0.02);
  text-align: left;
}

.result-item-title {
  margin: 0 0 0.3rem;
  color: var(--text-color);
  font-weight: 700;
  font-size: 1.01rem;
}

.result-item-text {
  margin: 0;
  color: var(--secondary-color);
  line-height: 1.38;
  font-size: 0.94rem;
}

.strategy-panel {
  margin-top: 0.95rem;
  border-left: 4px solid #00b1ff;
}

.summary-table-panel {
  margin-top: 0.95rem;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.98rem;
  table-layout: fixed;
}

.report-table thead tr {
  background: #2f72d7;
}

.report-table th {
  color: #ffffff;
  padding: 0.55rem 0.7rem;
  text-align: left;
  font-weight: 700;
}

.report-table th:nth-child(2),
.report-table th:nth-child(3),
.report-table td:nth-child(2),
.report-table td:nth-child(3) {
  text-align: center;
  width: 120px;
}

.report-table td {
  padding: 0.62rem 0.7rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-color);
}

.report-table th:first-child,
.report-table td:first-child {
  width: 62%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.strategy-text {
  margin: 0;
  white-space: pre-line;
  text-align: left;
  line-height: 1.5;
  font-size: 0.99rem;
  color: var(--text-color);
}

.legal-note {
  margin-top: 0.95rem;
  border: 1px solid rgba(239, 83, 80, 0.35);
  border-radius: 10px;
  padding: 0.68rem 0.72rem;
  background: rgba(239, 83, 80, 0.07);
}

.legal-title {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  color: #ff8a80;
  font-weight: 700;
  letter-spacing: 0.03em;
}

#legal-text {
  margin: 0;
  font-size: 0.64rem;
  line-height: 1.35;
  white-space: pre-line;
  color: #ffab91;
}

.report-footer {
  margin-top: 0.9rem;
  border-top: 1px solid var(--border-color);
  padding-top: 0.68rem;
  text-align: left;
}

.report-system-line {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-color);
}

.report-auto-note {
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  color: var(--secondary-color);
  font-style: italic;
}

.report-notice {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 3000;
  background: linear-gradient(180deg, #1f6feb 0%, #0969da 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.35);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: calc(100vw - 24px);
  text-align: center;
}

.report-notice.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* LOADING OVERLAY */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  color: white;
  flex-direction: column;
}

.spinner {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 4px solid white;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Actions Container */
.actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.actions .btn {
  width: auto;
  /* Allow buttons to size naturally content-wise */
}

.actions .btn-primary {
  flex: 2;
}

.actions .btn-secondary {
  flex: 1;
}


/* RESPONSIVE DESIGN (Media Queries) */
@media (max-width: 768px) {
  .container {
    padding: 1.25rem 1rem;
    max-width: 100%;
    border-radius: 0;
    /* Full screen on mobile */
    border: none;
    box-shadow: none;
    box-sizing: border-box;
  }

  .question-container {
    width: 100%;
    box-sizing: border-box;
    padding: 0;
  }

  .slider-container {
    padding: 0.75rem;
  }

  h1 {
    font-size: 1.25rem;
  }

  .actions {
    flex-direction: column-reverse;
    /* Stack buttons on mobile, primary on top usually */
  }

  .actions .btn {
    width: 100%;
    margin-right: 0;
  }

  .top-logo {
    height: 44px;
  }

  .theme-toggle {
    width: 46px;
    height: 46px;
    font-size: 1.2rem;
  }

  .container.survey-wide {
    max-width: 100%;
  }

  #question-text {
    line-height: 1.45;
  }

  #level-info {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    width: 100%;
    padding: 0;
    box-sizing: border-box;
  }

  .level-option-box {
    padding: 0.85rem 1rem;
  }

  .report-title {
    font-size: 1.4rem;
  }

  .report-shell {
    padding: 0.85rem;
    border-radius: 10px;
  }

  .report-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .report-logo {
    width: 92px;
    max-width: 44%;
  }

  .report-grid-top {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .report-panel-title {
    font-size: 1.2rem;
  }

  .score-value {
    font-size: 2.7rem;
  }

  .score-target {
    font-size: 0.92rem;
  }

  .result-cards {
    grid-template-columns: 1fr;
  }

  .radar-wrap {
    min-height: 230px;
    height: 230px;
  }

  .report-table {
    font-size: 0.78rem;
    table-layout: fixed;
    width: 100%;
  }

  .report-table th,
  .report-table td {
    padding: 0.4rem 0.34rem;
  }

  .report-table th:nth-child(2),
  .report-table th:nth-child(3),
  .report-table td:nth-child(2),
  .report-table td:nth-child(3) {
    width: 72px;
  }

  .report-table th:first-child,
  .report-table td:first-child {
    width: auto;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .report-notice {
    top: 12px;
    font-size: 0.86rem;
    padding: 0.65rem 0.8rem;
  }
}

/* UTILS */
.hidden {
  display: none !important;
}

/* TUTORIAL CARDS */
.tutorial-card {
  padding: 1rem;
  border-left: 5px solid #ccc;
  background-color: var(--input-bg);
  margin-bottom: 1rem;
  border-radius: 4px;
}

.tutorial-card.blue {
  border-left-color: var(--primary-color);
}

.tutorial-card.green {
  border-left-color: var(--success-color);
}

footer {
  padding: 2rem;
  font-size: 0.85rem;
  color: var(--secondary-color);
}
