/**
 * ComplySimply Custom Styles
 *
 * Supplements Tailwind CSS CDN with animations, print styles,
 * scrollbar styling, focus states, and other styles that
 * Tailwind utility classes cannot handle alone.
 */

/* ================================================================== */
/*  Smooth page transitions                                            */
/* ================================================================== */

.page-enter {
  animation: pageEnter 0.2s ease-out forwards;
}

.page-exit {
  animation: pageExit 0.15s ease-in forwards;
}

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

@keyframes pageExit {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* ================================================================== */
/*  Toast notification animations                                      */
/* ================================================================== */

.toast-enter {
  animation: toastSlideIn 0.3s ease-out forwards;
}

.toast-exit {
  animation: toastSlideOut 0.3s ease-in forwards;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ================================================================== */
/*  Modal backdrop animation                                           */
/* ================================================================== */

.modal-backdrop-enter {
  animation: fadeIn 0.2s ease-out forwards;
}

.modal-backdrop-exit {
  animation: fadeOut 0.15s ease-in forwards;
}

.modal-content-enter {
  animation: scaleIn 0.2s ease-out forwards;
}

.modal-content-exit {
  animation: scaleOut 0.15s ease-in forwards;
}

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

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes scaleOut {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.95) translateY(8px);
  }
}

/* ================================================================== */
/*  Skeleton loading animation                                         */
/* ================================================================== */

.skeleton {
  background: linear-gradient(
    90deg,
    #e5e7eb 0%,
    #f3f4f6 40%,
    #f3f4f6 60%,
    #e5e7eb 100%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border-radius: 0.5rem;
}

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

/* ================================================================== */
/*  Progress bar animation                                             */
/* ================================================================== */

.progress-bar-fill {
  transition: width 0.4s ease-in-out;
}

.progress-bar-indeterminate {
  animation: progressIndeterminate 1.5s ease-in-out infinite;
  width: 40%;
}

@keyframes progressIndeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

/* ================================================================== */
/*  Loading spinner                                                    */
/* ================================================================== */

.spinner {
  border: 3px solid #e5e7eb;
  border-top-color: #1e40af;
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  animation: spin 0.6s linear infinite;
}

.spinner-sm {
  width: 1.25rem;
  height: 1.25rem;
  border-width: 2px;
}

.spinner-lg {
  width: 3rem;
  height: 3rem;
  border-width: 4px;
}

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

/* ================================================================== */
/*  Custom scrollbar styling                                           */
/* ================================================================== */

/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: #d1d5db;
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: #9ca3af;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
}

/* ================================================================== */
/*  Focus styles for accessibility                                     */
/* ================================================================== */

/* Use focus-visible so focus ring only appears on keyboard navigation */
*:focus-visible {
  outline: 2px solid #1e40af;
  outline-offset: 2px;
}

/* Remove default outline for mouse interactions */
*:focus:not(:focus-visible) {
  outline: none;
}

/* Enhanced focus for form inputs */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Focus styles for custom buttons (select options, boolean toggles) */
.cs-select-option:focus-visible,
.cs-bool-option:focus-visible {
  outline: 2px solid #1e40af;
  outline-offset: 2px;
}

/* ================================================================== */
/*  Smooth scrolling                                                   */
/* ================================================================== */

html {
  scroll-behavior: smooth;
}

/* Respect user preferences for reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .page-enter,
  .page-exit,
  .toast-enter,
  .toast-exit,
  .modal-backdrop-enter,
  .modal-backdrop-exit,
  .modal-content-enter,
  .modal-content-exit {
    animation-duration: 0.01ms !important;
  }

  .skeleton {
    animation: none;
  }

  .progress-bar-fill {
    transition: none;
  }

  .spinner {
    animation-duration: 1s;
  }
}

/* ================================================================== */
/*  Print styles                                                       */
/* ================================================================== */

@media print {
  /* Hide non-essential UI elements */
  header,
  nav,
  footer,
  .no-print,
  #toast-container,
  #cs-modal-root,
  #modal-container,
  button,
  .cs-photo-dropzone,
  .cs-photo-delete {
    display: none !important;
  }

  /* Show print-only elements */
  .print-only {
    display: block !important;
  }

  /* Reset backgrounds and colours */
  body {
    background: white !important;
    color: black !important;
    font-size: 12pt;
    line-height: 1.5;
  }

  /* Full-width content */
  .max-w-2xl,
  .max-w-3xl,
  .max-w-4xl,
  .max-w-7xl {
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Ensure content is visible */
  * {
    overflow: visible !important;
  }

  /* Page breaks */
  .page-break {
    page-break-before: always;
  }

  .no-page-break {
    page-break-inside: avoid;
  }

  /* Show link URLs */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  /* Don't show URL for internal hash links */
  a[href^="#"]::after {
    content: "";
  }

  /* Risk level banners - ensure readable on print */
  .bg-green-500,
  .bg-amber-500,
  .bg-red-500 {
    color: black !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Tables */
  table {
    border-collapse: collapse;
    width: 100%;
  }

  th, td {
    border: 1px solid #d1d5db;
    padding: 8px 12px;
    text-align: left;
  }

  th {
    background-color: #f3f4f6 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Remove shadows and rounded corners for cleaner print */
  .shadow-sm,
  .shadow-md,
  .shadow-lg,
  .shadow-xl,
  .shadow-2xl {
    box-shadow: none !important;
  }
}

/* ================================================================== */
/*  Drag and drop visual feedback                                      */
/* ================================================================== */

.cs-photo-dropzone.drag-active {
  border-color: #3b82f6;
  background-color: #eff6ff;
}

/* ================================================================== */
/*  Assessment question transitions                                    */
/* ================================================================== */

.cs-question {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.cs-question.entering {
  opacity: 0;
  transform: translateY(8px);
}

.cs-question.entered {
  opacity: 1;
  transform: translateY(0);
}

/* Help text collapse transition */
.cs-help-content {
  transition: max-height 0.2s ease-out, opacity 0.2s ease-out;
}

.cs-help-chevron {
  transition: transform 0.2s ease;
}

/* ================================================================== */
/*  Photo upload thumbnail hover effects                               */
/* ================================================================== */

.cs-photo-upload .group:hover .cs-photo-delete {
  opacity: 1;
}

/* Always show delete button on touch devices */
@media (hover: none) {
  .cs-photo-delete {
    opacity: 1 !important;
  }
}
