/* ============================================
   ZapContrat - Custom Styles
   State-of-the-art Lead Generation CSS 2026
   ============================================ */

/* Smooth scroll with reduced motion support */
html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Focus styles for accessibility */
:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Selection color */
::selection {
  background-color: #bfdbfe;
  color: #1e3a8a;
}

/* Loader animation */
.loader {
  width: 48px;
  height: 48px;
  border: 4px solid #E5E7EB;
  border-bottom-color: #2563eb;
  border-radius: 50%;
  animation: loader-spin 0.8s linear infinite;
}

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

/* Header shadow on scroll */
.header-scrolled {
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
}

/* Form step transitions */
.form-step {
  animation: fadeSlideIn 0.3s ease-out;
}

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

/* Step indicator transition */
.step-indicator {
  transition: all 0.3s ease;
}

.step-indicator.active {
  transform: scale(1.1);
  box-shadow: 0 0 0 4px rgba(37,99,235, 0.2);
}

.step-indicator.completed {
  background-color: #10B981;
  color: white;
}

.step-line.active {
  background-color: #2563eb;
}

/* Range slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  background: #E5E7EB;
  border-radius: 9999px;
  outline: none;
}

input[type="range"]:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 4px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: #2563eb;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37,99,235, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 3px 10px rgba(37,99,235, 0.4);
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: #2563eb;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37,99,235, 0.3);
}

/* FAQ toggle animation */
.faq-toggle svg {
  transition: transform 0.2s ease;
}

.faq-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.faq-content {
  animation: faqOpen 0.2s ease-out;
}

@keyframes faqOpen {
  from {
    opacity: 0;
    max-height: 0;
  }
  to {
    opacity: 1;
    max-height: 500px;
  }
}

/* Modal animations */
#quote-modal.visible,
#exit-modal.visible {
  opacity: 1;
}

#quote-modal.visible #modal-content,
#exit-modal.visible > div {
  transform: scale(1);
}

/* Counter animation */
.counter {
  font-variant-numeric: tabular-nums;
}

/* CTA pulse effect */
.cta-button {
  position: relative;
}

.cta-button::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  opacity: 0;
  box-shadow: 0 0 0 0 rgba(37,99,235, 0.4);
  transition: opacity 0.3s ease;
}

.cta-button:hover::after {
  animation: ctaPulse 1.5s ease-out;
}

@keyframes ctaPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(37,99,235, 0.4);
    opacity: 1;
  }
  100% {
    box-shadow: 0 0 0 12px rgba(37,99,235, 0);
    opacity: 0;
  }
}

/* Toast notification */
.toast {
  animation: toastIn 0.3s ease-out;
}

.toast.removing {
  animation: toastOut 0.3s ease-in forwards;
}

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

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

/* Result card entrance */
#result {
  animation: resultReveal 0.5s ease-out;
}

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

/* Urgency banner close animation */
#urgency-banner.closing {
  animation: slideUp 0.3s ease-in forwards;
}

@keyframes slideUp {
  to {
    transform: translateY(-100%);
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
  }
}

/* Mobile CTA slide up */
#mobile-cta {
  animation: slideFromBottom 0.3s ease-out;
}

@keyframes slideFromBottom {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Scroll top button */
#scroll-top {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#scroll-top:hover {
  transform: translateY(-2px);
}

/* Projection table rows */
#savings-projection tr {
  transition: background-color 0.15s ease;
}

#savings-projection tr:hover {
  background-color: #F0FDF4;
}

/* WhatsApp floating button pulse */
#whatsapp-float {
  animation: waFloat 2s ease-in-out infinite;
  overflow: visible;
}

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

#whatsapp-float::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: rgba(37, 211, 102, 0.3);
  animation: waPulse 2s ease-out infinite;
  pointer-events: none;
  will-change: transform, opacity;
}

@keyframes waPulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Print styles */
/* ============================================
   ZapChat — Inline + Floating Chat Widget
   ============================================ */

/* --- Shared --- */
.sc-messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: 1rem;
}

.sc-msg { display: flex; gap: 0.5rem; align-items: flex-end; }
.sc-msg--user { justify-content: flex-end; }
.sc-msg--bot { justify-content: flex-start; }

.sc-avatar {
  width: 2rem; height: 2rem; min-width: 2rem;
  border-radius: 9999px; object-fit: cover;
  flex-shrink: 0;
}

.sc-bubble {
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
}
.sc-bubble--user {
  background: #2563eb; color: #fff;
  border-bottom-right-radius: 0.25rem;
  max-width: 320px;
}
.sc-bubble--bot {
  background: #fff; color: #374151;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 0.25rem;
  max-width: 420px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.sc-bubble--typing {
  display: flex; gap: 4px; padding: 0.75rem 1.25rem;
}
.sc-dot {
  width: 8px; height: 8px;
  background: #d1d5db; border-radius: 50%;
  animation: sc-bounce 1.2s infinite;
}
.sc-dot:nth-child(2) { animation-delay: 0.15s; }
.sc-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes sc-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.sc-link { color: #1d4ed8; text-decoration: underline; }
.sc-link:hover { color: #1e40af; }

/* Input bar */
.sc-input-bar {
  display: flex; gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  position: relative;
}
.sc-input {
  flex: 1; border: 1px solid #e5e7eb;
  border-radius: 1.5rem; padding: 0.625rem 1rem;
  font-size: 0.9rem; outline: none;
  transition: border-color .2s;
}
.sc-input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.sc-send {
  width: 40px; height: 40px;
  background: #2563eb; color: #fff;
  border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .2s;
  flex-shrink: 0;
}
.sc-send:hover { background: #1d4ed8; }
.sc-send:disabled { opacity: .5; cursor: not-allowed; }

/* Suggestion chips */
.sc-suggestions {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  padding: 0 1rem 0.75rem;
}
.sc-chip {
  background: #eff6ff; border: 1px solid #bfdbfe;
  color: #1e3a8a; font-size: 0.8rem;
  padding: 0.4rem 0.85rem; border-radius: 1.5rem;
  cursor: pointer; transition: all .2s;
  white-space: nowrap;
}
.sc-chip:hover {
  background: #dbeafe; border-color: #2563eb;
  transform: translateY(-1px);
}

/* --- Inline mode (landing page) --- */
.sc-inline {
  background: #fff;
  border-radius: 1.25rem;
  border: 1px solid #e5e7eb;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
  overflow: hidden;
  max-width: 700px;
  margin: 0 auto;
}

/* Inline header with avatar */
.sc-inline-header {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid #f3f4f6;
  background: linear-gradient(to right, #eff6ff, #fff);
}
.sc-inline-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(37,99,235,.2);
  flex-shrink: 0;
}
.sc-inline-name {
  font-weight: 700; font-size: 0.95rem; color: #1f2937;
  display: flex; align-items: center; gap: 0.5rem;
}
.sc-inline-badge {
  font-size: 0.65rem; font-weight: 600;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff; padding: 0.15rem 0.5rem;
  border-radius: 1rem; white-space: nowrap;
}
.sc-inline-status {
  font-size: 0.75rem; color: #6b7280;
  display: flex; align-items: center; gap: 4px; margin-top: 1px;
}

/* --- Attachment button --- */
.sc-attach {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex-shrink: 0;
  color: #9ca3af; cursor: pointer; border-radius: 50%;
  transition: color .2s, background .2s;
}
.sc-attach:hover { color: #2563eb; background: #dbeafe; }
.sc-attach-input { display: none; }

/* --- Drag-and-drop overlay --- */
.sc-dropzone-overlay {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(37,99,235,.12);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  border: 2.5px dashed #2563eb;
  border-radius: inherit;
  pointer-events: none;
  animation: sc-dropzone-in .2s ease-out;
}
.sc-dropzone-overlay.hidden { display: none !important; }
@keyframes sc-dropzone-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.sc-dropzone-content {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  color: #1e3a8a; font-weight: 600; font-size: 0.9rem;
}
.sc-dropzone-content svg { color: #2563eb; }
.sc-dropzone-hint {
  font-size: 0.7rem; font-weight: 400; opacity: .7;
}

/* --- File message bubble --- */
.sc-file-bubble {
  display: flex !important; align-items: center; gap: 0.5rem;
  background: #eef2ff !important; border-color: #c7d2fe !important;
}
.sc-file-bubble svg { color: #6366f1; flex-shrink: 0; }
.sc-file-info { display: flex; flex-direction: column; }
.sc-file-name {
  font-size: 0.8rem; font-weight: 600; color: #312e81;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sc-file-meta { font-size: 0.65rem; color: #6b7280; }

/* --- Progress bubble --- */
.sc-progress-bubble {
  min-width: 200px;
}
.sc-progress-text {
  font-size: 0.8rem; color: #1e3a8a; margin-bottom: 0.4rem;
}
.sc-progress-bar {
  height: 4px; background: #bfdbfe; border-radius: 2px; overflow: hidden;
}
.sc-progress-fill {
  height: 100%; background: linear-gradient(90deg, #2563eb, #4f46e5);
  border-radius: 2px; transition: width .8s ease;
}
.sc-spin { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* --- Results card --- */
.sc-results-card {
  padding: 0 !important; overflow: hidden;
  border: 1px solid #e5e7eb !important; border-radius: 0.85rem !important;
  max-width: 340px !important; background: #fff !important;
}
.sc-results-header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-bottom: 1px solid #bfdbfe;
  font-weight: 700; font-size: 0.85rem; color: #1e3a8a;
}
.sc-results-header svg { color: #2563eb; }
.sc-results-highlight {
  padding: 0.75rem 0.85rem;
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  text-align: center;
}
.sc-results-saving {
  font-size: 1.4rem; font-weight: 800; color: #059669;
  line-height: 1.2;
}
.sc-results-saving span {
  display: block; font-size: 0.75rem; font-weight: 500; color: #6b7280;
  margin-top: 2px;
}
.sc-results-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0; padding: 0;
}
.sc-results-item {
  display: flex; flex-direction: column; gap: 1px;
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid #f3f4f6;
}
.sc-results-item:nth-child(odd) { border-right: 1px solid #f3f4f6; }
.sc-results-label { font-size: 0.65rem; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.03em; }
.sc-results-value { font-size: 0.82rem; font-weight: 600; color: #1f2937; }
.sc-text-red { color: #dc2626 !important; }
.sc-text-green { color: #059669 !important; }
.sc-results-prime {
  padding: 0.5rem 0.85rem;
  font-size: 0.8rem; color: #1e3a8a;
  background: #eff6ff; border-top: 1px solid #bfdbfe;
  text-align: center;
}
.sc-results-cta {
  padding: 0.65rem 0.85rem 0.35rem;
}
.sc-results-btn {
  display: block; width: 100%;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff; border: none; border-radius: 0.5rem;
  padding: 0.6rem; font-size: 0.85rem; font-weight: 700;
  cursor: pointer; transition: opacity .2s;
  text-align: center;
}
.sc-results-btn:hover { opacity: .9; }
.sc-results-retry { padding: 0 0.85rem 0.65rem; text-align: center; }
.sc-results-retry-btn {
  background: none; border: none; color: #6b7280;
  font-size: 0.72rem; cursor: pointer; text-decoration: underline;
  transition: color .2s;
}
.sc-results-retry-btn:hover { color: #2563eb; }

/* --- Relative positioning for dropzone --- */
.sc-inline, .sc-float { position: relative; }

.sc-inline .sc-messages {
  min-height: 260px;
  max-height: 400px;
}
.sc-inline .sc-bubble--user { max-width: 400px; }
.sc-inline .sc-bubble--bot { max-width: 500px; }
.sc-inline .sc-suggestions { justify-content: center; }

/* --- Floating mode (other pages) --- */
.sc-toggle {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  width: 60px; height: 60px;
  background: none; border: 3px solid #2563eb;
  border-radius: 50%; padding: 0; overflow: hidden;
  cursor: pointer; z-index: 50;
  box-shadow: 0 4px 16px rgba(37,99,235,.35);
  transition: transform .3s, box-shadow .3s;
  animation: sc-pulse 3s ease-in-out 8s 3;
}
.sc-toggle-avatar {
  width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%;
  display: block;
}
.sc-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(37,99,235,.45); }
@keyframes sc-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(37,99,235,.35); }
  50% { box-shadow: 0 0 0 12px rgba(37,99,235,0), 0 4px 16px rgba(37,99,235,.35); }
}
.sc-toggle-badge {
  position: absolute; top: -2px; right: -2px;
  width: 18px; height: 18px;
  background: #ef4444; color: #fff;
  border-radius: 50%; font-size: 0.65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.sc-float {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  width: 380px;
  max-height: 540px;
  background: #f9fafb;
  border-radius: 1rem;
  box-shadow: 0 8px 40px rgba(0,0,0,.12);
  z-index: 51;
  display: flex; flex-direction: column;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}
.sc-float-enter {
  animation: sc-slide-up .3s ease-out;
}

@keyframes sc-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.sc-float-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
}
.sc-float-header-info { display: flex; align-items: center; gap: 0.6rem; }
.sc-float-avatar {
  width: 36px; height: 36px;
  border-radius: 50%; object-fit: cover;
  flex-shrink: 0;
}
.sc-float-title { font-weight: 700; font-size: 0.9rem; }
.sc-float-status { font-size: 0.75rem; opacity: .85; display: flex; align-items: center; gap: 4px; }
.sc-status-dot {
  width: 7px; height: 7px;
  background: #4ade80; border-radius: 50%;
  display: inline-block;
}
.sc-float-close {
  background: rgba(255,255,255,.15); border: none;
  color: #fff; width: 32px; height: 32px;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.sc-float-close:hover { background: rgba(255,255,255,.3); }

.sc-messages--float {
  min-height: 200px;
  max-height: 320px;
  flex: 1;
}
.sc-suggestions--float { padding: 0 0.75rem 0.5rem; }
.sc-suggestions--float .sc-chip { font-size: 0.75rem; padding: 0.3rem 0.65rem; }

/* --- Lead capture form --- */
.sc-lead-form {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1px solid #bfdbfe;
  border-radius: 1rem;
  padding: 1rem;
  max-width: 420px;
}
.sc-lead-title {
  font-weight: 700; font-size: 0.9rem; color: #1e3a8a;
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.sc-lead-fields { display: flex; flex-direction: column; gap: 0.5rem; }
.sc-lead-input {
  border: 1px solid #e5e7eb; border-radius: 0.5rem;
  padding: 0.5rem 0.75rem; font-size: 0.85rem;
  outline: none; transition: border-color .2s;
}
.sc-lead-input:focus { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.sc-lead-submit {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff; border: none; border-radius: 0.5rem;
  padding: 0.6rem; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: opacity .2s;
}
.sc-lead-submit:hover { opacity: .9; }
.sc-lead-submit:disabled { opacity: .6; cursor: not-allowed; }
.sc-lead-privacy {
  font-size: 0.7rem; color: #1e3a8a; opacity: .7;
  text-align: center; margin-top: 0.25rem;
}
.sc-lead-success {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.5rem; text-align: center; padding: 0.5rem 0;
}
.sc-lead-success p { font-size: 0.85rem; color: #374151; line-height: 1.4; }

/* --- Animations --- */
.animate-bounce-in { animation: sc-bounce-in .5s ease-out; }
@keyframes sc-bounce-in {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

/* --- Mobile --- */
@media (max-width: 640px) {
  .sc-float {
    width: 100%; height: 100%;
    max-height: 100%; bottom: 0; right: 0;
    border-radius: 0; z-index: 39;
  }
  .sc-messages--float { max-height: none; flex: 1; }
  .sc-toggle { bottom: 5rem; right: 1rem; z-index: 39; }
  .sc-inline .sc-messages { min-height: 250px; max-height: 380px; }
  .sc-chip { font-size: 0.75rem; padding: 0.35rem 0.7rem; }
  .sc-bubble--user, .sc-bubble--bot { max-width: 260px !important; }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  .sc-dot { animation: none; }
  .sc-float-enter { animation: none; }
  .animate-bounce-in { animation: none; }
  .sc-toggle { animation: none; }
  .sc-chip:hover { transform: none; }
}

/* --- Utility: scoped to chat only, avoids breaking Tailwind's responsive .hidden --- */
.sc-float.hidden,
.sc-toggle.hidden,
.sc-toggle-badge.hidden,
.sc-lead-success.hidden,
.sc-lead-fields.hidden { display: none !important; }

@media print {
  header, footer, #urgency-banner, #mobile-cta, #scroll-top,
  #exit-modal, #quote-modal, .cta-button, button,
  .sc-toggle, .sc-float, #sc-chat-float {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  #result {
    display: block !important;
  }
}
