/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-notification {
  position: fixed;
  top: 24px;
  right: 24px;
  min-width: 320px;
  max-width: 480px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  z-index: 9999;
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-notification.visible {
  opacity: 1;
  transform: translateX(0);
}

.toast-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-message {
  flex: 1;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dark, #1a1a18);
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-muted, #5b635d);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.toast-close:hover {
  background: rgba(0, 0, 0, 0.05);
}

.toast-success {
  border-left: 4px solid #10b981;
}

.toast-success .toast-icon {
  color: #10b981;
}

.toast-error {
  border-left: 4px solid #ef4444;
}

.toast-error .toast-icon {
  color: #ef4444;
}

.toast-warning {
  border-left: 4px solid #f59e0b;
}

.toast-warning .toast-icon {
  color: #f59e0b;
}

.toast-info {
  border-left: 4px solid #3b82f6;
}

.toast-info .toast-icon {
  color: #3b82f6;
}

/* ============================================
   LOADING OVERLAY
   ============================================ */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  backdrop-filter: blur(2px);
}

.loading-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.loading-spinner {
  background: white;
  border-radius: 16px;
  padding: 32px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(11, 61, 145, 0.1);
  border-top-color: var(--forest, #0b3d91);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-spinner p {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dark, #102040);
}

/* ============================================
   BUTTON LOADING STATE
   ============================================ */

.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================
   SKIP LINK (ACCESSIBILITY)
   ============================================ */

.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--forest, #0b3d91);
  color: white;
  padding: 12px 20px;
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 0 8px 0;
  z-index: 10000;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--forest-light, #4b75e0);
  outline-offset: 2px;
}

/* ============================================
   IMPROVED FOCUS STYLES
   ============================================ */

:focus-visible {
  outline: 2px solid var(--forest-light, #4b75e0);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--forest-light, #4b75e0);
  outline-offset: 2px;
}

/* ============================================
   ENHANCED FORM VALIDATION
   ============================================ */

input:invalid:not(:placeholder-shown),
select:invalid:not(:placeholder-shown),
textarea:invalid:not(:placeholder-shown) {
  border-color: #ef4444;
}

#modalSex:invalid,
#modalCivilStatus:invalid {
  border-color: var(--border);
}

input:valid:not(:placeholder-shown),
select:valid:not(:placeholder-shown),
textarea:valid:not(:placeholder-shown) {
  border-color: #10b981;
}

input[type="date"]:valid {
  border-color: #10b981;
}

input[type="date"]:invalid {
  border-color: var(--border, rgba(27, 67, 50, 0.12));
}

form.validation-visible input[type="date"]:invalid,
input[type="date"].validation-touched:invalid {
  border-color: #ef4444;
}

input[data-ph-mobile]:not(:placeholder-shown):valid {
  border-color: #10b981;
}

input[data-ph-mobile]:not(:placeholder-shown):invalid {
  border-color: #ef4444;
}

#modalContact:not(:placeholder-shown):valid,
#contact:not(:placeholder-shown):valid {
  border-color: #10b981;
}

#modalContact:not(:placeholder-shown):invalid,
#contact:not(:placeholder-shown):invalid {
  border-color: #ef4444;
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted, #6d7b9a);
  margin-top: 6px;
  line-height: 1.4;
}

.form-error {
  display: block;
  font-size: 12px;
  color: #ef4444;
  margin-top: 6px;
  font-weight: 500;
}

/* ============================================
   RESPONSIVE IMPROVEMENTS
   ============================================ */

@media (max-width: 640px) {
  .toast-notification {
    left: 16px;
    right: 16px;
    min-width: auto;
  }

  .loading-spinner {
    padding: 24px 32px;
  }
}

/* ============================================
   SMOOTH SCROLLING
   ============================================ */

html {
  scroll-behavior: smooth;
}

.scroll-reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 550ms ease, transform 550ms ease;
  transition-delay: var(--reveal-delay, 0ms);
}

.scroll-reveal.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

.registration-progress {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
}

.registration-progress li {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.registration-progress li span {
  display: inline-flex;
  width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #fff;
}

.registration-progress li.active {
  color: var(--forest);
}

.registration-progress li.active span {
  border-color: var(--forest);
  background: var(--forest);
  color: #fff;
}

#registerForm.registration-wizard-ready .registration-step[hidden] {
  display: none;
}

.registration-step h3 {
  margin: 0 0 18px;
  color: var(--forest);
  font-size: 17px;
}

.registration-step h3:focus {
  outline: none;
}

.registration-step-actions {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
}

.registration-captcha {
  max-width: 100%;
  margin: 0 0 18px;
  overflow-x: auto;
}

.registration-step-actions [hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .scroll-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .toast-notification,
  .loading-overlay,
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   HIGH CONTRAST MODE SUPPORT
   ============================================ */

@media (prefers-contrast: high) {
  .btn-primary,
  .btn-secondary,
  .service-card,
  .login-card {
    border: 2px solid currentColor;
  }
}

/* ============================================
   DARK MODE SUPPORT (FUTURE)
   ============================================ */

@media (prefers-color-scheme: dark) {
  /* Uncomment when implementing dark mode */
  /*
  :root {
    --forest: #6b9bd4;
    --bg: #1a1a1a;
    --surface: #2a2a2a;
    --text: #f0f0f0;
  }
  */
}

/* ============================================
   PRINT STYLES ENHANCEMENT
   ============================================ */

@media print {
  .toast-notification,
  .loading-overlay,
  .skip-link,
  .burger-toggle,
  .mobile-menu,
  .mobile-menu-overlay {
    display: none !important;
  }

  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 11px;
    color: #666;
  }

  a[href^="#"]:after,
  a[href^="javascript:"]:after {
    content: "";
  }
}

/* ============================================
   CAROUSEL IMPROVEMENTS
   ============================================ */

.carousel-track {
  cursor: grab;
  user-select: none;
}

.carousel-track:active {
  cursor: grabbing;
}

.carousel-track.dragging {
  scroll-behavior: auto;
}

/* ============================================
   IMPROVED ANIMATIONS
   ============================================ */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.5s ease-out;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
