/* Font and Base Styles */
body {
  font-family: "Inter", sans-serif;
  background-color: #f8fafc;
  overflow-x: hidden;
}

/* Enhanced Visual Polish */
.glass-morphism {
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

.section-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.input-group {
  position: relative;
  margin-bottom: 1.5rem;
}

.input-with-icon {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #6b7280;
  z-index: 10;
}

.input-with-icon input {
  padding-left: 2.5rem;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #e2e8f0 0%, #cbd5e1 100%);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #4f46e5 0%, #7c3aed 50%, #ec4899 100%);
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  width: var(--progress, 0%);
}

.shimmer {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Enhanced Tooltip Styles */
.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: help;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 280px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #fff;
  text-align: left;
  border-radius: 12px;
  padding: 12px 16px;
  position: absolute;
  z-index: 1000;
  bottom: 150%;
  left: 50%;
  margin-left: -140px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 
              0 10px 10px -5px rgba(0, 0, 0, 0.04),
              0 0 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.tooltip .tooltiptext::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -8px;
  border-width: 8px;
  border-style: solid;
  border-color: #1e293b transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.tooltip svg {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tooltip:hover svg {
  color: #4f46e5;
  transform: scale(1.1);
}

/* Enhanced Custom Slider Styles */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: linear-gradient(90deg, #e2e8f0 0%, #cbd5e1 100%);
  border-radius: 9999px;
  outline: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
}

input[type="range"]:hover {
  background: linear-gradient(90deg, #cbd5e1 0%, #94a3b8 100%);
  transform: scaleY(1.2);
}

input[type="range"]:focus {
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  cursor: pointer;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3), 0 0 0 1px rgba(79, 70, 229, 0.1);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4), 0 0 0 2px rgba(79, 70, 229, 0.2);
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  cursor: pointer;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.1);
}

/* Custom Select Arrow */
.custom-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Enhanced Animation System with Performance Optimizations */
.fade-in {
  animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity;
}

.fade-in-up {
  animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity, transform;
}

.fade-in-scale {
  animation: fadeInScale 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity, transform;
}

.stagger-animation {
  animation-delay: calc(var(--stagger) * 0.1s);
}

/* Hardware acceleration for smooth animations */
.smooth-transition {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, opacity;
  transform: translateZ(0); /* Force hardware acceleration */
}

.gpu-accelerated {
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.smooth-transition {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bounce-in {
  animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Animated Waves */
.header-waves-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 450px;
  overflow: hidden;
  z-index: -1;
}

.parallax > use {
  animation: wave-move 25s cubic-bezier(0.55, 0.5, 0.45, 0.5) infinite;
}

.parallax > use:nth-child(1) {
  animation-delay: -2s;
  animation-duration: 7s;
}

.parallax > use:nth-child(2) {
  animation-delay: -3s;
  animation-duration: 10s;
}

.parallax > use:nth-child(3) {
  animation-delay: -4s;
  animation-duration: 13s;
}

.parallax > use:nth-child(4) {
  animation-delay: -5s;
  animation-duration: 20s;
}

@keyframes wave-move {
  0% {
    transform: translate3d(-90px, 0, 0);
  }
  100% {
    transform: translate3d(85px, 0, 0);
  }
}

/* Modal Animations */
.modal-open {
  opacity: 1 !important;
  pointer-events: auto !important;
}

.modal-open > div {
  transform: scale(1) !important;
}

/* Smooth scrollbar for modal */
.modal-content::-webkit-scrollbar {
  width: 6px;
}

.modal-content::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.modal-content::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Enhanced Loading States */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.loading-skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 8px;
}

@keyframes skeleton-loading {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.calculating {
  position: relative;
  overflow: hidden;
}

.calculating::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.1), transparent);
  animation: calculating-sweep 2s infinite;
}

@keyframes calculating-sweep {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Subtle entrance animations */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-in-up {
  animation: slideInUp 0.3s ease-out;
}

/* Gradient text effect */
.gradient-text {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Smooth verdict transitions - override laggy bounce */
.calculating {
  opacity: 0.7;
  transition: all 0.3s ease-in-out;
}

.calculating * {
  pointer-events: none;
}

/* Number Animation Styles */
.number-animated {
  transition: transform 0.1s ease-out;
  display: inline-block;
  will-change: transform;
}

.number-animated.animating {
  animation: numberPulse 0.6s ease-out;
}

@keyframes numberPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.verdict-number {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, color;
}

.verdict-number.updating {
  color: #6366f1;
  transform: scale(1.05);
}

/* Enhanced smooth transitions for calculated values */
.calculated-value {
  transition: all 0.2s ease-out;
  will-change: transform;
}

.calculated-value.flash {
  animation: valueFlash 0.4s ease-out;
}

@keyframes valueFlash {
  0% { 
    background-color: rgba(79, 70, 229, 0.1);
    transform: scale(1);
  }
  50% { 
    background-color: rgba(79, 70, 229, 0.2);
    transform: scale(1.02);
  }
  100% { 
    background-color: transparent;
    transform: scale(1);
  }
}

/* Smooth layout preservation */
.verdict-section {
  min-height: 200px;
  transition: all 0.3s ease-out;
}

.verdict-section.stable {
  transform: translateZ(0); /* Force hardware acceleration */
}

/* Disable bouncy animations for smoother experience */
.bounce-in {
  animation: none !important;
}

/* Enhanced Input Styles */
.form-input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 16px;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.form-input:focus {
  outline: none;
  border-color: #4f46e5;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1), 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.form-input:hover:not(:focus) {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%234f46e5' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 20px;
  padding-right: 48px;
}

/* Section Headers */
.section-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
}

.section-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #4f46e5 0%, transparent 100%);
  border-radius: 1px;
}

.section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  border-radius: 12px;
  color: white;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* Advanced Options Toggle */
.advanced-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(79, 70, 229, 0.05);
  border: 1px solid rgba(79, 70, 229, 0.1);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 16px;
}

.advanced-toggle:hover {
  background: rgba(79, 70, 229, 0.08);
  border-color: rgba(79, 70, 229, 0.2);
}

.advanced-toggle.active {
  background: rgba(79, 70, 229, 0.1);
  border-color: rgba(79, 70, 229, 0.3);
}

.advanced-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.advanced-content.expanded {
  max-height: 1000px;
}

/* Input Groups with Better Spacing */
.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 640px) {
  .input-row {
    grid-template-columns: 1fr;
  }
}

/* Enhanced Button Styles */
.btn-primary {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  border: none;
  color: white;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #e2e8f0;
  color: #475569;
  padding: 10px 22px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.btn-secondary:hover {
  border-color: #4f46e5;
  color: #4f46e5;
  background: rgba(255, 255, 255, 1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Cost Impact Indicators */
.cost-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cost-indicator.low {
  background: rgba(16, 185, 129, 0.1);
  color: #065f46;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.cost-indicator.medium {
  background: rgba(245, 158, 11, 0.1);
  color: #92400e;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.cost-indicator.high {
  background: rgba(239, 68, 68, 0.1);
  color: #991b1b;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  .section-card {
    margin: 0 -8px;
    border-radius: 20px 20px 0 0;
    padding: 20px 16px;
  }
  
  .form-input {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 16px;
    border-radius: 12px;
  }
  
  .tooltip .tooltiptext {
    width: 240px;
    margin-left: -120px;
    font-size: 12px;
    padding: 8px 12px;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 20px;
  }
  
  .section-icon {
    width: 32px;
    height: 32px;
  }
  
  .input-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .advanced-toggle {
    padding: 16px;
    border-radius: 16px;
  }
  
  .input-with-icon input {
    padding-left: 3rem;
  }
  
  .btn-primary,
  .btn-secondary {
    padding: 14px 20px;
    font-size: 16px;
    min-height: 48px; /* Better touch targets */
  }
  
  /* Modal adjustments for mobile */
  #explanationModal .modal-content {
    margin: 8px;
    border-radius: 24px;
    max-height: calc(100vh - 32px);
  }
  
  #explanationModal .section-card {
    margin: 0;
    padding: 16px;
  }
  
  .progress-bar {
    height: 6px;
  }
  
  /* Touch-friendly input adjustments */
  input[type="range"]::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
  }
  
  input[type="range"]::-moz-range-thumb {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 16px;
  }
  
  .glass-morphism {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  
  .tooltip .tooltiptext {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 280px;
    margin-left: 0;
    z-index: 9999;
  }
  
  .section-header h3 {
    font-size: 1.25rem;
  }
  
  .input-group {
    margin-bottom: 1.25rem;
  }
}

/* Enhanced Focus States for Accessibility */
.form-input:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
input[type="range"]:focus-visible,
.advanced-toggle:focus-visible {
  outline: 3px solid #4f46e5;
  outline-offset: 2px;
}

/* Skip to content link for screen readers */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #4f46e5;
  color: white;
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 1000;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 6px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .section-card {
    border: 2px solid #000;
  }
  
  .form-input {
    border: 2px solid #000;
  }
  
  .btn-primary {
    background: #000;
    color: #fff;
    border: 2px solid #000;
  }
  
  .btn-secondary {
    background: #fff;
    color: #000;
    border: 2px solid #000;
  }
}

/* Print styles */
@media print {
  .header-waves-container,
  #menu-btn,
  #explainBtn {
    display: none;
  }
  
  .section-card {
    background: white;
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .form-input {
    border: 1px solid #999;
    background: white;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .parallax > use {
    animation: none !important;
  }
  
  .calculating::after {
    animation: none !important;
  }
  
  .shimmer {
    animation: none !important;
  }
}

/* Help text and guidance */
.help-text {
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 4px;
  line-height: 1.4;
}

.help-text.success {
  color: #059669;
}

.help-text.warning {
  color: #d97706;
}

.help-text.error {
  color: #dc2626;
}

.input-hint {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: #9ca3af;
  pointer-events: none;
}

/* Status indicators */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-indicator.optimal {
  background: rgba(34, 197, 94, 0.1);
  color: #15803d;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-indicator.good {
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.status-indicator.caution {
  background: rgba(245, 158, 11, 0.1);
  color: #92400e;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-indicator.warning {
  background: rgba(239, 68, 68, 0.1);
  color: #991b1b;
  border: 1px solid rgba(239, 68, 68, 0.2);
}