/* app/static/css/style.css */

/**
 * CENF-C Adaptive Survey - Modern Professional Styles
 * 
 * Features:
 * - Dark/Light theme support
 * - Modern gradients and shadows
 * - Responsive design for mobile/desktop
 * - Professional animations and interactions
 * - Accessibility compliant
 */

/* ========================================
   CSS CUSTOM PROPERTIES (VARIABLES)
======================================== */

:root {
  /* Light Theme Colors */
  --primary-color: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary-color: #64748b;
  --accent-color: #0ea5e9;
  --success-color: #22c55e;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  
  /* Light Theme Backgrounds */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #e2e8f0;
  --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  
  /* Light Theme Text */
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-light: #ffffff;
  
  /* Shadows and Effects */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --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);
  
  /* Border Radius */
  --border-radius-sm: 0.375rem;
  --border-radius: 0.5rem;
  --border-radius-lg: 0.75rem;
  --border-radius-xl: 1rem;
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* Dark Theme Colors */
[data-theme="dark"] {
  --primary-color: #3b82f6;
  --primary-dark: #2563eb;
  --secondary-color: #64748b;
  --accent-color: #06b6d4;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #f87171;
  
  /* Dark Theme Backgrounds */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-gradient: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
  
  /* Dark Theme Text */
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-light: #ffffff;
}

/* ========================================
   BASE STYLES
======================================== */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ========================================
   LAYOUT COMPONENTS
======================================== */

.main-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
  background: var(--bg-gradient);
}

.survey-wrapper {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

.survey-card {
  background: var(--bg-primary);
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--bg-tertiary);
  overflow: hidden;
  transition: all var(--transition-normal);
}

.survey-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* ========================================
   HEADER STYLES
======================================== */

.survey-header {
  background: var(--bg-gradient);
  padding: var(--spacing-xl);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.survey-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, rgba(255,255,255,0.1) 25%, transparent 25%),
              linear-gradient(-45deg, rgba(255,255,255,0.1) 25%, transparent 25%);
  background-size: 20px 20px;
  opacity: 0.3;
}

.survey-title {
  color: var(--text-light);
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.survey-subtitle {
  color: rgba(255,255,255,0.9);
  font-size: 1rem;
  margin: var(--spacing-sm) 0 0 0;
  position: relative;
  z-index: 1;
}

/* Theme Toggle */
.theme-toggle {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  z-index: 2;
}

.theme-toggle-btn {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--text-light);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all var(--transition-fast);
  backdrop-filter: blur(10px);
}

.theme-toggle-btn:hover {
  background: rgba(255,255,255,0.3);
  transform: scale(1.05);
}

/* ========================================
   CONTENT STYLES
======================================== */

.survey-body {
  padding: var(--spacing-2xl);
}

.welcome-content {
  text-align: center;
  padding: var(--spacing-xl) 0;
}

.welcome-title {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
}

.welcome-description {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xl);
  line-height: 1.7;
}

/* ========================================
   QUESTION STYLES
======================================== */

.question-container {
  margin-bottom: var(--spacing-xl);
}

.question-text {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
  line-height: 1.5;
}

.question-description {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: var(--spacing-lg);
  font-style: italic;
}

.question-options {
  display: grid;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-xl);
}

/* ========================================
   FORM ELEMENTS
======================================== */

/* Text Input and Textarea */
.form-control {
  background: var(--bg-secondary);
  border: 2px solid var(--bg-tertiary);
  color: var(--text-primary);
  padding: var(--spacing-md);
  border-radius: var(--border-radius);
  font-size: 1rem;
  transition: all var(--transition-fast);
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background: var(--bg-primary);
}

.form-control::placeholder {
  color: var(--text-muted);
}

/* Large Textarea */
.form-textarea {
  min-height: 120px;
  resize: vertical;
  font-family: inherit;
}

/* ========================================
   BUTTON STYLES
======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  font-size: 1rem;
  font-weight: 500;
  border-radius: var(--border-radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

/* Primary Button */
.btn-primary {
  background: var(--primary-color);
  color: var(--text-light);
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

/* Secondary Button */
.btn-secondary {
  background: var(--secondary-color);
  color: var(--text-light);
}

.btn-secondary:hover {
  background: var(--text-secondary);
  transform: translateY(-1px);
}

/* Outline Buttons */
.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--bg-tertiary);
}

.btn-outline:hover {
  background: var(--bg-secondary);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Large Button */
.btn-lg {
  padding: var(--spacing-lg) var(--spacing-xl);
  font-size: 1.125rem;
  border-radius: var(--border-radius-lg);
}

/* Start Button Special */
.btn-start {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
  color: var(--text-light);
  padding: var(--spacing-lg) var(--spacing-2xl);
  font-size: 1.25rem;
  font-weight: 600;
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-lg);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

/* ========================================
   OPTION BUTTONS
======================================== */

.option-button,
.checkbox-button,
.scale-button {
  background: var(--bg-secondary);
  border: 2px solid var(--bg-tertiary);
  color: var(--text-primary);
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.option-button:hover,
.checkbox-button:hover,
.scale-button:hover {
  background: var(--bg-tertiary);
  border-color: var(--primary-color);
  transform: translateX(4px);
}

/* Selected States */
.option-button.selected,
.scale-button.selected {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: var(--text-light);
}

.checkbox-button.selected {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: var(--text-light);
}

/* Scale Buttons Grid */
.scale-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
  gap: var(--spacing-md);
}

.scale-button {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.125rem;
}

/* ========================================
   MODAL STYLES
======================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-primary);
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.9) translateY(-20px);
  transition: all var(--transition-normal);
}

.modal-overlay.active .modal-content {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: var(--spacing-xl);
  border-bottom: 1px solid var(--bg-tertiary);
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-body {
  padding: var(--spacing-xl);
}

.modal-footer {
  padding: var(--spacing-xl);
  border-top: 1px solid var(--bg-tertiary);
  display: flex;
  gap: var(--spacing-md);
  justify-content: flex-end;
}

/* ========================================
   LOADING AND FEEDBACK STATES
======================================== */

.loading-container {
  text-align: center;
  padding: var(--spacing-2xl);
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--bg-tertiary);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--spacing-lg);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* Error States */
.error-container {
  padding: var(--spacing-xl);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--border-radius);
  margin: var(--spacing-lg) 0;
}

.error-title {
  color: var(--danger-color);
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
}

.error-message {
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
}

/* Success States */
.success-container {
  text-align: center;
  padding: var(--spacing-2xl);
}

.success-icon {
  font-size: 4rem;
  color: var(--success-color);
  margin-bottom: var(--spacing-lg);
}

.success-title {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
}

.success-message {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xl);
  line-height: 1.6;
}

/* ========================================
   PROGRESS INDICATORS
======================================== */

.progress-container {
  padding: var(--spacing-md) var(--spacing-xl);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--bg-tertiary);
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color) 0%, var(--accent-color) 100%);
  border-radius: var(--border-radius-sm);
  transition: width var(--transition-slow);
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(45deg, rgba(255,255,255,0.2) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.2) 75%, transparent 75%);
  background-size: 20px 20px;
  animation: progress-stripe 1s linear infinite;
}

@keyframes progress-stripe {
  0% { background-position: 0 0; }
  100% { background-position: 20px 0; }
}

.progress-text {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: var(--spacing-sm);
}

/* ========================================
   FOOTER STYLES
======================================== */

.survey-footer {
  background: var(--bg-secondary);
  padding: var(--spacing-lg);
  text-align: center;
  border-top: 1px solid var(--bg-tertiary);
}

.footer-text {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0;
}

/* ========================================
   RESPONSIVE DESIGN
======================================== */

/* Tablet Styles */
@media (max-width: 768px) {
  .main-container {
    padding: var(--spacing-sm);
  }
  
  .survey-body {
    padding: var(--spacing-xl);
  }
  
  .survey-header {
    padding: var(--spacing-lg);
  }
  
  .survey-title {
    font-size: 1.5rem;
  }
  
  .welcome-title {
    font-size: 1.75rem;
  }
  
  .btn-start {
    width: 100%;
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1.125rem;
  }
  
  .question-options {
    gap: var(--spacing-sm);
  }
  
  .scale-options {
    grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
    gap: var(--spacing-sm);
  }
  
  .modal-content {
    width: 95%;
    margin: var(--spacing-sm);
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: var(--spacing-lg);
  }
}

/* Mobile Styles */
@media (max-width: 480px) {
  .survey-body {
    padding: var(--spacing-lg);
  }
  
  .survey-header {
    padding: var(--spacing-md);
  }
  
  .survey-title {
    font-size: 1.25rem;
  }
  
  .survey-subtitle {
    font-size: 0.875rem;
  }
  
  .welcome-title {
    font-size: 1.5rem;
  }
  
  .welcome-description {
    font-size: 1rem;
  }
  
  .question-text {
    font-size: 1.125rem;
  }
  
  .btn {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.95rem;
  }
  
  .btn-lg {
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1rem;
  }
  
  .theme-toggle {
    position: static;
    margin-top: var(--spacing-md);
  }
  
  .form-control {
    font-size: 16px; /* Prevent zoom on iOS */
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: var(--spacing-md);
  }
  
  .modal-footer {
    flex-direction: column;
  }
  
  .modal-footer .btn {
    width: 100%;
  }
}

/* ========================================
   ACCESSIBILITY
======================================== */

/* Focus States */
.btn:focus,
.form-control:focus,
.option-button:focus,
.checkbox-button:focus,
.scale-button:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
    --shadow-xl: none;
  }
  
  .btn,
  .form-control,
  .option-button,
  .checkbox-button,
  .scale-button {
    border-width: 3px;
  }
}

/* ========================================
   UTILITY CLASSES
======================================== */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }
.mb-5 { margin-bottom: var(--spacing-xl); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }
.mt-5 { margin-top: var(--spacing-xl); }

.d-none { display: none; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

.align-center { align-items: center; }
.align-start { align-items: flex-start; }
.align-end { align-items: flex-end; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}