/* ========================================
   CSS Variables & Reset
   ======================================== */
:root {
  /* Colors - Light Theme (default) */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(0, 0, 0, 0.02);
  --bg-card-hover: rgba(0, 0, 0, 0.04);
  --bg-glass: rgba(0, 0, 0, 0.05);

  --text-primary: #1e293b;
  --text-secondary: rgba(30, 41, 59, 0.7);
  --text-muted: rgba(30, 41, 59, 0.5);

  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-dark: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.2);

  --success: #22c55e;
  --success-glow: rgba(34, 197, 94, 0.2);
  --error: #ef4444;
  --warning: #f59e0b;

  --border: rgba(0, 0, 0, 0.1);
  --border-focus: rgba(99, 102, 241, 0.5);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.15);
  --shadow-glow: 0 0 40px var(--accent-glow);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

/* Dark Theme */
.dark-theme {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.05);
  --bg-glass: rgba(255, 255, 255, 0.08);

  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);

  --border: rgba(255, 255, 255, 0.08);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --accent-glow: rgba(99, 102, 241, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Layout
   ======================================== */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-lg);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ========================================
   State Containers
   ======================================== */
.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: var(--space-md);
}

.state-container h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

.state-container p {
  color: var(--text-secondary);
}

/* Loader */
.loader {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Icons */
.error-icon,
.success-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.success-icon {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--success), #16a34a);
  border-radius: 50%;
  font-size: 2.5rem;
  box-shadow: 0 0 40px var(--success-glow);
}

.success-icon.animated {
  animation: successPop 0.5s ease-out;
}

@keyframes successPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========================================
   Survey Header
   ======================================== */
.survey-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.header-content h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.survey-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-glass);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.user-avatar {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 50%;
  font-size: 0.875rem;
  font-weight: 600;
}

/* ========================================
   Progress Bar
   ======================================== */
.progress-container {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
  position: sticky;
  top: var(--space-md);
  z-index: 100;
  background: var(--bg-primary);
  padding: var(--space-sm) 0;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-glass);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 3px;
  transition: width var(--transition-slow);
}

.progress-text {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent-light);
  min-width: 40px;
}

/* ========================================
   Blocks & Questions
   ======================================== */
.survey-block {
  margin-bottom: var(--space-2xl);
}

.block-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.block-number {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  box-shadow: var(--shadow-glow);
}

.block-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  transition: all var(--transition-normal);
}

.question-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
}

.question-card.has-error {
  border-color: var(--error);
}

.question-text {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}

.required-mark {
  color: var(--error);
  font-weight: 600;
}

/* ========================================
   Form Inputs
   ======================================== */
.input-text,
.input-number {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  transition: all var(--transition-fast);
  resize: vertical;
}

.input-text:focus,
.input-number:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-text::placeholder,
.input-number::placeholder {
  color: var(--text-muted);
}

.input-number {
  -moz-appearance: textfield;
}

.input-number::-webkit-outer-spin-button,
.input-number::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Options (Radio & Checkbox) */
.options-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.option-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.option-item:hover {
  background: var(--bg-glass);
  border-color: rgba(255, 255, 255, 0.15);
}

.option-item.selected {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--accent);
}

.option-item input {
  display: none;
}

.option-check {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.option-item.checkbox .option-check {
  border-radius: var(--radius-sm);
}

.option-item.selected .option-check {
  background: var(--accent);
  border-color: var(--accent);
}

.option-check::after {
  content: '';
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  transform: scale(0);
  transition: transform var(--transition-fast);
}

.option-item.checkbox .option-check::after {
  width: 10px;
  height: 5px;
  background: transparent;
  border: 2px solid white;
  border-top: none;
  border-right: none;
  border-radius: 0;
  transform: scale(0) rotate(-45deg);
  margin-top: -2px;
}

.option-item.selected .option-check::after {
  transform: scale(1);
}

.option-item.checkbox.selected .option-check::after {
  transform: scale(1) rotate(-45deg);
}

.option-text {
  flex: 1;
  font-size: 0.95rem;
}

/* ========================================
   Submit Button
   ======================================== */
.submit-container {
  position: sticky;
  bottom: var(--space-lg);
  padding-top: var(--space-lg);
  background: linear-gradient(to top, var(--bg-primary) 80%, transparent);
}

.submit-button {
  width: 100%;
  padding: var(--space-md) var(--space-xl);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-md), var(--shadow-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.submit-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 60px var(--accent-glow);
}

.submit-button:active:not(:disabled) {
  transform: translateY(0);
}

.submit-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.button-loader {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 640px) {
  .container {
    padding: var(--space-md);
  }

  .survey-header {
    flex-direction: column;
    gap: var(--space-md);
  }

  .user-badge {
    align-self: flex-start;
  }

  .header-content h1 {
    font-size: 1.5rem;
  }

  .question-card {
    padding: var(--space-md);
  }
}