/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Ensure modals with fixed positioning work inside scroll containers */
[data-modal-target="container"],
[data-quick-task-target="scheduleModal"],
[data-quick-task-target="customModal"],
[data-deal-update-modal-target="modal"] {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
}
[data-modal-target="container"].hidden,
[data-quick-task-target="scheduleModal"].hidden,
[data-quick-task-target="customModal"].hidden,
[data-deal-update-modal-target="modal"].hidden {
  position: relative !important;
  inset: auto !important;
  width: auto !important;
  height: auto !important;
}

/* Scrollbar-hide utility for mobile-scrollable tab bars */
.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* Page transition animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.animate-fade-in {
  animation: fadeIn 0.4s ease-out;
}

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

.animate-fade-out {
  animation: fadeOut 0.3s ease-in forwards;
}

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

.animate-bounce-in {
  animation: bounceIn 0.5s ease-out;
}

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

.animate-flash-in {
  animation: flashIn 0.3s ease-out;
}

@keyframes notificationIn {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 640px) {
  @keyframes notificationIn {
    from {
      opacity: 0;
      transform: translateX(0.5rem);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }
}

/* Staggered animations for cards */
.animate-stagger-1 {
  animation: fadeIn 0.4s ease-out 0.05s both;
}

.animate-stagger-2 {
  animation: fadeIn 0.4s ease-out 0.1s both;
}

.animate-stagger-3 {
  animation: fadeIn 0.4s ease-out 0.15s both;
}

.animate-stagger-4 {
  animation: fadeIn 0.4s ease-out 0.2s both;
}

/* Custom width utilities for navbar */
@media (min-width: 1024px) {
  .lg\:w-65 {
    width: 16.25rem; /* 260px */
  }

  .lg\:pl-65 {
    padding-left: 16.25rem; /* 260px */
  }

  .lg\:ml-65 {
    margin-left: 16.25rem; /* 260px */
  }
}

/* Sidebar styles when collapsed */
@media (min-width: 1024px) {
  /* Apply collapsed state immediately from localStorage to prevent flash */
  .sidebar-collapsed [data-sidebar-target="sidebar"] {
    width: 5rem !important; /* 80px - lg:w-20 */
  }

  .sidebar-collapsed [data-sidebar-target="content"] {
    padding-left: 5rem !important; /* 80px - lg:pl-20 */
  }

  .sidebar-collapsed [data-sidebar-target="header"] {
    margin-left: 5rem !important; /* 80px - lg:ml-20 */
  }

  .sidebar-collapsed [data-sidebar-target="toggleButton"] {
    left: 70px !important;
  }

  .sidebar-collapsed .nav-label,
  .sidebar-collapsed .recently-viewed-section {
    opacity: 0 !important;
    visibility: hidden !important;
  }

  /* Prevent horizontal scrollbar when collapsed */
  .collapsed {
    overflow-x: hidden;
  }

  /* Inner container should also hide overflow when collapsed */
  .collapsed > div {
    overflow-x: hidden;
  }

  /* Prevent text wrapping during animations */
  .nav-label,
  .recently-viewed-section {
    white-space: nowrap;
  }

  /* Nav labels - hidden when collapsed, visible when expanded */
  .nav-label {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease-in, visibility 0s 0.25s;
  }

  .collapsed .nav-label {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-in, visibility 0s 0.2s;
  }

  /* When expanded, delay showing text until width animation is mostly done */
  @media (min-width: 1024px) {
    .nav-label {
      transition: opacity 0.2s ease-in 0.25s, visibility 0s;
    }

    .collapsed .nav-label {
      transition: opacity 0.2s ease-in, visibility 0s 0.2s;
    }
  }

  /* Recently viewed section - hidden when collapsed, visible when expanded */
  .recently-viewed-section {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease-in 0.25s, visibility 0s;
  }

  .collapsed .recently-viewed-section {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-in, visibility 0s 0.2s;
  }
}

/* Google Places Autocomplete Styling */
.pac-container {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  border: 1px solid rgb(229 231 235);
  margin-top: 0.5rem;
  font-family: inherit;
  z-index: 9999;
}

.pac-container:after {
  display: none;
}

.pac-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border: none;
  line-height: 1.5;
  font-size: 0.875rem;
}

.pac-item:hover {
  background-color: rgb(249 250 251);
}

.pac-item-selected,
.pac-item-selected:hover {
  background-color: rgb(238 242 255);
}

.pac-icon {
  display: none;
}

.pac-item-query {
  font-size: 0.875rem;
  color: rgb(17 24 39);
  font-weight: 500;
}

.pac-matched {
  font-weight: 600;
  color: rgb(79 70 229);
}

/* Hide Google logo in autocomplete */
.pac-logo:after {
  display: none;
}

/* ===== Wizard Animations ===== */

/* Progress bar: animated gradient shimmer (grow handled by JS) */
@keyframes wizardShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.wizard-progress-bar {
  background: linear-gradient(90deg, var(--progress-from, #4f46e5), var(--progress-via, #818cf8), var(--progress-from, #4f46e5));
  background-size: 200% 100%;
  animation: wizardShimmer 3s ease-in-out 1s infinite;
}

/* Progress step labels stagger in after the bar fills */
@keyframes wizardLabelFade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.wizard-step-labels > * {
  opacity: 0;
  animation: wizardLabelFade 0.3s ease-out forwards;
}

.wizard-step-labels > *:nth-child(1) { animation-delay: 0.35s; }
.wizard-step-labels > *:nth-child(2) { animation-delay: 0.45s; }
.wizard-step-labels > *:nth-child(3) { animation-delay: 0.55s; }
.wizard-step-labels > *:nth-child(4) { animation-delay: 0.65s; }
.wizard-step-labels > *:nth-child(5) { animation-delay: 0.75s; }
.wizard-step-labels > *:nth-child(6) { animation-delay: 0.85s; }

/* Staggered entrance for wizard form sections */
@keyframes wizardSectionEnter {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.wizard-sections > * {
  opacity: 0;
  animation: wizardSectionEnter 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.wizard-sections > *:nth-child(1) { animation-delay: 0.08s; }
.wizard-sections > *:nth-child(2) { animation-delay: 0.16s; }
.wizard-sections > *:nth-child(3) { animation-delay: 0.24s; }
.wizard-sections > *:nth-child(4) { animation-delay: 0.32s; }
.wizard-sections > *:nth-child(5) { animation-delay: 0.40s; }
.wizard-sections > *:nth-child(6) { animation-delay: 0.48s; }
.wizard-sections > *:nth-child(7) { animation-delay: 0.56s; }
.wizard-sections > *:nth-child(8) { animation-delay: 0.64s; }

/* Card hover lift + gradient header sweep */
.wizard-card {
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}

.wizard-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -8px rgb(0 0 0 / 0.12), 0 4px 10px -4px rgb(0 0 0 / 0.06);
}

.wizard-gradient-header {
  position: relative;
  overflow: hidden;
}

.wizard-gradient-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.15) 50%, transparent 100%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
  pointer-events: none;
}

.wizard-card:hover .wizard-gradient-header::after {
  transform: translateX(100%);
}

/* Body content fade-out on navigation (header + progress stay visible) */
.wizard-body-leaving {
  opacity: 0 !important;
  transform: translateY(-10px) !important;
  transition: opacity 0.18s ease, transform 0.18s ease !important;
}

/* Title/subtitle wipe-in from right (forward movement feel) */
@keyframes wizardTitleWipe {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.wizard-title-enter {
  animation: wizardTitleWipe 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.wizard-subtitle-enter {
  animation: wizardTitleWipe 0.45s cubic-bezier(0.16, 1, 0.3, 1) 0.06s both;
}

/* Prevent step labels from re-animating on Turbo navigations */
.wizard-labels-stable > * {
  opacity: 1 !important;
  animation: none !important;
  transform: none !important;
}

/* ===== Mega Menu ===== */
.mega-menu-link {
  display: block;
  font-size: 0.875rem;
  line-height: 1.5rem;
  color: rgb(55 65 81);
  transition: color 0.15s ease;
}

.mega-menu-link:hover {
  color: rgb(79 70 229);
}

[data-mega-menu-target="chevron"] {
  transition: transform 0.2s ease;
}

/* ===== Flatpickr Overrides ===== */
.flatpickr-calendar {
  border-radius: 0.75rem;
  box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  border: 1px solid rgb(229 231 235);
  font-family: inherit;
}

.flatpickr-months .flatpickr-month {
  height: 40px;
}

.flatpickr-current-month {
  font-size: 0.9375rem;
  font-weight: 600;
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: rgb(79 70 229);
  border-color: rgb(79 70 229);
}

.flatpickr-day.today {
  border-color: rgb(199 210 254);
}

.flatpickr-day.today:hover {
  background: rgb(238 242 255);
  border-color: rgb(199 210 254);
}

.flatpickr-day:hover {
  background: rgb(243 244 246);
}

/* Style the alt input to inherit the original input styling */
.flatpickr-input.flatpickr-mobile,
input.flatpickr-input[readonly] {
  cursor: pointer;
}

/* Ensure the alt input created by flatpickr inherits the field classes */
.flatpickr-alt-input {
  cursor: pointer !important;
}

/* ===== Trix Rich Text Content ===== */
.trix-content h1 { font-size: 1.5rem; font-weight: 700; margin: 1rem 0 0.5rem; }
.trix-content h2 { font-size: 1.25rem; font-weight: 600; margin: 1rem 0 0.5rem; }
.trix-content h3 { font-size: 1.125rem; font-weight: 600; margin: 0.75rem 0 0.5rem; }
.trix-content strong, .trix-content b { font-weight: 700; }
.trix-content em, .trix-content i { font-style: italic; }
.trix-content u { text-decoration: underline; }
.trix-content del, .trix-content strike { text-decoration: line-through; }
.trix-content ul { list-style-type: disc; padding-left: 1.5rem; margin: 0.5rem 0; }
.trix-content ol { list-style-type: decimal; padding-left: 1.5rem; margin: 0.5rem 0; }
.trix-content li { margin: 0.25rem 0; }
.trix-content blockquote { border-left: 3px solid rgb(199 210 254); padding-left: 1rem; margin: 0.75rem 0; color: rgb(107 114 128); font-style: italic; }
.trix-content pre { background: rgb(243 244 246); padding: 0.75rem 1rem; border-radius: 0.375rem; overflow-x: auto; font-size: 0.875rem; margin: 0.5rem 0; }
.trix-content a { color: rgb(79 70 229); text-decoration: underline; }
.trix-content a:hover { color: rgb(67 56 202); }
.trix-content p { margin: 0.25rem 0; }
.trix-content br { display: block; content: ""; margin-top: 0.25rem; }
