/* Interactive Elements and Animations */

/* Smooth Transitions */
* {
  transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
  transition-duration: 0.2s;
  transition-timing-function: ease-in-out;
}

/* Focus Management */
.focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Hover Effects */
.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.hover-scale {
  transition: transform 0.2s ease;
}

.hover-scale:hover {
  transform: scale(1.05);
}

.hover-glow {
  transition: box-shadow 0.2s ease;
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.3);
}

/* Loading Animations */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    transform: translate3d(0, -30px, 0);
  }
  70% {
    transform: translate3d(0, -15px, 0);
  }
  90% {
    transform: translate3d(0, -4px, 0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Animation Classes */
.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-bounce {
  animation: bounce 1s infinite;
}

.animate-fade-in {
  animation: fadeIn 0.5s ease-out;
}

.animate-fade-in-up {
  animation: fadeInUp 0.6s ease-out;
}

.animate-fade-in-down {
  animation: fadeInDown 0.6s ease-out;
}

.animate-slide-in-right {
  animation: slideInRight 0.5s ease-out;
}

.animate-slide-in-left {
  animation: slideInLeft 0.5s ease-out;
}

.animate-zoom-in {
  animation: zoomIn 0.3s ease-out;
}

/* Staggered Animations */
.stagger-children > * {
  animation: fadeInUp 0.6s ease-out;
  animation-fill-mode: both;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.6s; }

/* Interactive Form Elements */
.form-input-animated {
  position: relative;
  background: transparent;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem 1rem 0.5rem;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.form-input-animated:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-label-animated {
  position: absolute;
  top: 1rem;
  left: 1rem;
  color: var(--text-secondary);
  font-size: 1rem;
  pointer-events: none;
  transition: all 0.3s ease;
  background: var(--surface-color);
  padding: 0 0.25rem;
}

.form-input-animated:focus + .form-label-animated,
.form-input-animated:not(:placeholder-shown) + .form-label-animated {
  top: -0.5rem;
  left: 0.75rem;
  font-size: 0.875rem;
  color: var(--primary-color);
}

/* Ripple Effect */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.ripple:active::before {
  width: 300px;
  height: 300px;
}

/* Micro-interactions */
.micro-bounce {
  transition: transform 0.1s ease;
}

.micro-bounce:active {
  transform: scale(0.95);
}

.micro-rotate {
  transition: transform 0.2s ease;
}

.micro-rotate:hover {
  transform: rotate(5deg);
}

/* Progress Indicators */
.progress-ring {
  width: 60px;
  height: 60px;
  transform: rotate(-90deg);
}

.progress-ring-circle {
  fill: none;
  stroke: var(--border-color);
  stroke-width: 4;
  stroke-dasharray: 157;
  stroke-dashoffset: 157;
  transition: stroke-dashoffset 0.5s ease;
}

.progress-ring-circle.active {
  stroke: var(--primary-color);
  stroke-dashoffset: calc(157 - (157 * var(--progress, 0)) / 100);
}

/* Floating Action Button */
.fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: all 0.3s ease;
  z-index: 1000;
}

.fab:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.5);
}

.fab:active {
  transform: scale(0.95);
}

/* Tooltip */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip-text {
  visibility: hidden;
  width: max-content;
  max-width: 200px;
  background: var(--text-primary);
  color: var(--surface-color);
  text-align: center;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  position: absolute;
  z-index: 1001;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  font-size: 0.875rem;
  white-space: nowrap;
}

.tooltip-text::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: var(--text-primary) transparent transparent transparent;
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Card Hover Effects */
.card-interactive {
  transition: all 0.3s ease;
  cursor: pointer;
}

.card-interactive:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

.card-interactive:hover .card-title {
  color: var(--primary-color);
}

/* Accordion */
.accordion-item {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.accordion-header {
  background: var(--background-color);
  padding: 1rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.2s ease;
}

.accordion-header:hover {
  background: var(--border-color);
}

.accordion-title {
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.accordion-icon {
  transition: transform 0.3s ease;
}

.accordion-item.active .accordion-icon {
  transform: rotate(180deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.accordion-item.active .accordion-content {
  max-height: 500px;
}

.accordion-body {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--border-color);
  transition: 0.3s;
  border-radius: 24px;
}

.switch-slider:before {
  position: absolute;
  content: '';
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .switch-slider {
  background: var(--primary-color);
}

.switch input:checked + .switch-slider:before {
  transform: translateX(24px);
}

/* Checkbox and Radio Animations */
.checkbox-animated,
.radio-animated {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.checkbox-animated input,
.radio-animated input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.checkbox-animated .checkmark,
.radio-animated .checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 20px;
  width: 20px;
  background: var(--surface-color);
  border: 2px solid var(--border-color);
  transition: all 0.2s ease;
}

.checkbox-animated .checkmark {
  border-radius: 4px;
}

.radio-animated .checkmark {
  border-radius: 50%;
}

.checkbox-animated:hover input ~ .checkmark,
.radio-animated:hover input ~ .checkmark {
  border-color: var(--primary-color);
}

.checkbox-animated input:checked ~ .checkmark,
.radio-animated input:checked ~ .checkmark {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.checkbox-animated .checkmark:after,
.radio-animated .checkmark:after {
  content: '';
  position: absolute;
  display: none;
}

.checkbox-animated input:checked ~ .checkmark:after,
.radio-animated input:checked ~ .checkmark:after {
  display: block;
}

.checkbox-animated .checkmark:after {
  left: 6px;
  top: 2px;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.radio-animated .checkmark:after {
  top: 4px;
  left: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
}

/* Responsive Animations */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 768px) {
  .fab {
    bottom: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }

  .tooltip-text {
    max-width: 150px;
    font-size: 0.8rem;
  }

  .hover-lift:hover {
    transform: none;
    box-shadow: none;
  }

  .card-interactive:hover {
    transform: none;
  }
}