/*
  JADE Senior Care Services - Components
  Reusable UI components and patterns
*/

/* Container */
.container {
  width: 100%;
  max-width: var(--container-2xl);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

@media (min-width: 640px) {
  .container {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

@media (min-width: 768px) {
  .container {
    padding-left: var(--space-8);
    padding-right: var(--space-8);
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: var(--container-xl);
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--btn-padding-y) var(--btn-padding-x);
  font-family: var(--font-primary);
  font-size: var(--text-base);
  font-weight: var(--btn-font-weight);
  line-height: var(--leading-none);
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--btn-border-radius);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 44px; /* Accessibility: minimum touch target */
  white-space: nowrap;
  user-select: none;
}

.btn:focus {
  outline: 2px solid var(--jade-primary);
  outline-offset: 2px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Button variants */
.btn--primary {
  background: var(--jade-gradient);
  color: var(--text-white);
  border-color: var(--jade-primary);
  box-shadow: var(--shadow-sm);
}

.btn--primary:hover {
  background: var(--jade-dark);
  border-color: var(--jade-dark);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn--secondary {
  background: var(--gold-gradient);
  color: var(--jade-dark);
  border-color: var(--gold-primary);
  box-shadow: var(--shadow-sm);
}

.btn--secondary:hover {
  background: var(--gold-dark);
  border-color: var(--gold-dark);
  color: var(--white);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn--outline {
  background: transparent;
  color: var(--jade-primary);
  border-color: var(--jade-primary);
}

.btn--outline:hover {
  background: var(--jade-primary);
  color: var(--white);
}

.btn--ghost {
  background: transparent;
  color: var(--jade-primary);
  border-color: transparent;
}

.btn--ghost:hover {
  background: var(--jade-light);
  color: var(--jade-dark);
}

/* Button sizes */
.btn--small {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  min-height: 36px;
}

.btn--large {
  padding: var(--btn-padding-y-lg) var(--btn-padding-x-lg);
  font-size: var(--text-lg);
  min-height: 52px;
}

.btn--full {
  width: 100%;
}

/* Forms */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.form-label[required]::after,
.form-label .required::after {
  content: " *";
  color: var(--error);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: var(--form-padding-y) var(--form-padding-x);
  font-family: var(--font-primary);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--white);
  border: var(--form-border-width) solid var(--form-border-color);
  border-radius: var(--form-border-radius);
  transition: all var(--transition-fast);
  min-height: 44px; /* Accessibility */
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--form-focus-color);
  box-shadow: 0 0 0 3px rgba(45, 125, 50, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-light);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: var(--leading-relaxed);
}

.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='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right var(--space-2) center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: var(--space-10);
  appearance: none;
}

.form-error {
  display: block;
  font-size: var(--text-sm);
  color: var(--error);
  margin-top: var(--space-1);
  min-height: 1.25rem;
}

.form-input.error,
.form-textarea.error,
.form-select.error {
  border-color: var(--error);
}

.form-row {
  display: grid;
  gap: var(--space-4);
}

@media (min-width: 768px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* Checkboxes and Radio buttons */
.checkbox-label,
.radio-label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-3);
}

.checkbox-input,
.radio-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.checkbox-custom,
.radio-custom {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 2px solid var(--form-border-color);
  background-color: var(--white);
  transition: all var(--transition-fast);
  position: relative;
  margin-top: 2px;
}

.checkbox-custom {
  border-radius: var(--radius-sm);
}

.radio-custom {
  border-radius: var(--radius-full);
}

.checkbox-input:checked + .checkbox-custom,
.radio-input:checked + .radio-custom {
  background-color: var(--jade-primary);
  border-color: var(--jade-primary);
}

.checkbox-input:checked + .checkbox-custom::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 8px;
  border: solid var(--white);
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -60%) rotate(45deg);
}

.radio-input:checked + .radio-custom::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background-color: var(--white);
  border-radius: var(--radius-full);
}

.checkbox-input:focus + .checkbox-custom,
.radio-input:focus + .radio-custom {
  outline: 2px solid var(--jade-primary);
  outline-offset: 2px;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Cards */
.card {
  background-color: var(--white);
  border: 1px solid var(--card-border-color);
  border-radius: var(--card-border-radius);
  padding: var(--card-padding);
  box-shadow: var(--card-shadow);
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card__header {
  margin-bottom: var(--space-4);
}

.card__title {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.card__description {
  color: var(--text-secondary);
  font-size: var(--text-base);
}

.card__content {
  margin-bottom: var(--space-4);
}

.card__footer {
  border-top: 1px solid var(--gray-200);
  padding-top: var(--space-4);
  margin-top: var(--space-4);
}

/* Form Cards */
.form-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
  margin-bottom: var(--space-6);
}

.form-card:hover {
  border-color: var(--jade-primary);
  box-shadow: var(--shadow-lg);
}

.form-card__header {
  text-align: center;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--gray-100);
}

.form-card__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-3);
  background: var(--jade-gradient);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  color: var(--white);
}

.form-card__title {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.form-card__description {
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

/* Service Cards */
.service-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  text-align: center;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.service-card:hover {
  border-color: var(--jade-primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.service-card__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-4);
  background: var(--jade-gradient);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xl);
  color: var(--white);
}

.service-card__title {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.service-card__description {
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

/* Feature List */
.feature-list {
  list-style: none;
  padding: 0;
}

.feature-list__item {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  align-items: flex-start;
}

.feature-list__icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--jade-light);
  color: var(--jade-primary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  margin-top: var(--space-1);
}

.feature-list__content {
  flex: 1;
}

.feature-list__title {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.feature-list__description {
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

/* Social Links */
.social-links {
  display: flex;
  gap: var(--space-3);
}

.social-link {
  width: 40px;
  height: 40px;
  color: var(--jade-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  transition: all var(--transition-fast);
  text-decoration: none;
}

.social-link:hover {
  color: var(--jade-dark);
  transform: translateY(-2px);
}

/* Social Media Icon Fixes */
.social-link .fab {
  font-style: normal;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  display: inline-block;
  text-rendering: auto;
}

/* Ensure Font Awesome icons display correctly */
.social-link .fab {
  font-family: "Font Awesome 6 Brands" !important;
  font-style: normal !important;
  font-variant: normal !important;
  text-rendering: auto !important;
  line-height: 1 !important;
}

/* Force specific Font Awesome icons */
.social-link .fab.fa-facebook::before {
  content: "\f09a" !important;
  font-family: "Font Awesome 6 Brands" !important;
  font-weight: 400 !important;
}

.social-link .fab.fa-instagram::before {
  content: "\f16d" !important;
  font-family: "Font Awesome 6 Brands" !important;
  font-weight: 400 !important;
}

/* Contact Info */
.contact-info {
  list-style: none;
  padding: 0;
}

.contact-info li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  font-size: var(--text-base);
}

.contact-info i {
  width: 20px;
  color: var(--jade-primary);
  text-align: center;
}

.contact-info a {
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.contact-info a:hover {
  color: var(--jade-primary);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-full);
}

.badge--primary {
  background: var(--jade-light);
  color: var(--jade-dark);
}

.badge--secondary {
  background: var(--gold-light);
  color: var(--gold-dark);
}

.badge--success {
  background: var(--success-light);
  color: var(--success);
}

/* Progress indicators */
.progress {
  width: 100%;
  height: 8px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  background: var(--jade-gradient);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

/* Dividers */
.divider {
  height: 1px;
  background: var(--gray-200);
  margin: var(--space-8) 0;
}

.divider--thick {
  height: 2px;
  background: var(--jade-primary);
}

/* Tooltips */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip__content {
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: var(--white);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  z-index: var(--z-tooltip);
}

.tooltip:hover .tooltip__content {
  opacity: 1;
  visibility: visible;
}

.tooltip__content::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--gray-900);
}

/* Loading spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--jade-primary);
  border-radius: var(--radius-full);
  animation: spin 1s linear infinite;
}

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

/* Utility classes */
.image-responsive {
  width: 100%;
  height: auto;
  object-fit: cover;
}

.aspect-square {
  aspect-ratio: 1 / 1;
}

.aspect-video {
  aspect-ratio: 16 / 9;
}

.rounded {
  border-radius: var(--radius-base);
}

.rounded-lg {
  border-radius: var(--radius-lg);
}

.rounded-full {
  border-radius: var(--radius-full);
}

.shadow {
  box-shadow: var(--shadow-base);
}

.shadow-lg {
  box-shadow: var(--shadow-lg);
}

/* Animation utilities */
.fade-in {
  animation: fadeIn var(--transition-slow) ease-out;
}

.slide-up {
  animation: slideUp var(--transition-slow) ease-out;
}

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

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

/* Responsive utilities */
.hidden {
  display: none;
}

@media (max-width: 767px) {
  .hidden-mobile {
    display: none;
  }
}

@media (min-width: 768px) {
  .hidden-desktop {
    display: none;
  }
}

/* Contact Form Container - moved to layout.css for better organization */

/* Consultation CTA */
.consultation-cta {
  background: linear-gradient(135deg, var(--jade-primary) 0%, var(--jade-secondary) 100%);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.consultation-cta::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg width="60" height="60" viewBox="0 0 60 60" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><g fill="rgba(255,255,255,0.05)" fill-opacity="0.1"><circle cx="30" cy="30" r="2"/></g></svg>') repeat;
  pointer-events: none;
}

.consultation-cta__content {
  position: relative;
  z-index: 1;
}

.consultation-cta__title {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--white);
  margin-bottom: var(--space-3);
}

.consultation-cta__description {
  color: rgba(255, 255, 255, 0.9);
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-6);
}

.consultation-cta .btn {
  background: var(--white);
  color: var(--jade-primary);
  border: none;
  font-weight: var(--font-weight-semibold);
  padding: var(--space-4) var(--space-8);
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-base);
}

.consultation-cta .btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
  background: var(--gray-50);
}

/* Improved form card for single form layout */
.contact-form-container .form-card {
  max-width: 600px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .contact-form-container {
    padding: 0 var(--space-4);
  }

  .consultation-cta {
    padding: var(--space-6);
  }

  .consultation-cta__title {
    font-size: var(--text-xl);
  }

  .consultation-cta__description {
    font-size: var(--text-base);
  }
}

/* ===== DYNAMIC ANIMATIONS ===== */

/* Fade in animation for page elements */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Apply animations to page sections */
.hero__content {
  animation: fadeInUp 1s ease-out;
}

.hero__title {
  animation: fadeInUp 1s ease-out 0.2s both;
}

.hero__subtitle {
  animation: fadeInUp 1s ease-out 0.4s both;
}

.hero__actions {
  animation: fadeInUp 1s ease-out 0.6s both;
}

/* Service cards animation on scroll */
.service-card {
  opacity: 0;
  transform: translateY(30px);
  transition: all var(--transition-base);
}

.service-card.animate-in {
  animation: fadeInUp 0.6s ease-out forwards;
}

.service-card:nth-child(1).animate-in {
  animation-delay: 0.1s;
}

.service-card:nth-child(2).animate-in {
  animation-delay: 0.2s;
}

.service-card:nth-child(3).animate-in {
  animation-delay: 0.3s;
}

.service-card:nth-child(4).animate-in {
  animation-delay: 0.4s;
}

.service-card:nth-child(5).animate-in {
  animation-delay: 0.5s;
}

.service-card:nth-child(6).animate-in {
  animation-delay: 0.6s;
}

/* Enhanced button hover animations */
.btn {
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.btn:hover::before {
  left: 100%;
}

.btn--primary {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(45, 125, 50, 0.3);
}

.btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(45, 125, 50, 0.4);
}

/* Feature list item animations */
.feature-list__item {
  opacity: 0;
  transform: translateX(-30px);
  transition: all var(--transition-base);
}

.feature-list__item.animate-in {
  animation: slideInLeft 0.6s ease-out forwards;
}

.feature-list__item:nth-child(1).animate-in {
  animation-delay: 0.1s;
}

.feature-list__item:nth-child(2).animate-in {
  animation-delay: 0.2s;
}

.feature-list__item:nth-child(3).animate-in {
  animation-delay: 0.3s;
}

.feature-list__item:nth-child(4).animate-in {
  animation-delay: 0.4s;
}

/* Form cards subtle animation */
.form-card {
  opacity: 1;
  transform: translateY(0);
  transition: all var(--transition-base);
}

/* Hidden state for animation - only when not yet animated */
.form-card:not(.animate-in):not(.no-animation) {
  opacity: 0;
  transform: translateY(20px);
}

.form-card.animate-in {
  animation: fadeInUp 0.8s ease-out forwards;
}

/* Floating animation for icons */
.service-card__icon,
.feature-list__icon,
.form-card__icon {
  animation: float 3s ease-in-out infinite;
}

.service-card:hover .service-card__icon {
  animation: pulse 0.6s ease-in-out;
}

/* Page transitions */
.page-hero__content {
  animation: fadeIn 0.8s ease-out;
}

.page-hero__title {
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

.page-hero__subtitle {
  animation: fadeInUp 0.8s ease-out 0.4s both;
}

/* Responsive animations - reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Loading state for smooth page loads */
.fade-in-content {
  opacity: 0;
  animation: fadeIn 0.5s ease-out forwards;
}