*,
::before,
::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior-y: contain;
}

/* Safe area for iPhone notch */
.safe-area-bottom { padding-bottom: env(safe-area-inset-bottom, 0px); }
.safe-area-top { padding-top: env(safe-area-inset-top, 0px); }

/* Mobile Bottom Nav active state */
@media (max-width: 767px) {
    body { padding-bottom: 56px; }
    .hide-mobile { display: none !important; }
    .mobile-full { width: 100% !important; }
}

/* Signature pad */
#signature-pad canvas { width: 100% !important; height: 150px !important; cursor: crosshair; touch-action: none; }

/* Item row transitions */
.item-row { transition: all 0.2s ease; }
.item-row:hover { border-color: #93c5fd; }

/* Tool cards */
.tool-card { transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.tool-card:hover { transform: translateY(-3px); box-shadow: 0 16px 48px rgba(0,0,0,0.1); }
@media (max-width: 767px) { .tool-card:hover { transform: none; } }

/* Feature cards */
.feature-card { transition: all 0.3s ease; }
.feature-card:hover { transform: translateY(-2px); }
.feature-card:hover .feature-icon { transform: scale(1.12); }
.feature-icon { transition: transform 0.3s ease; }

/* Smooth page transitions */
.htmx-swapping { opacity: 0; transition: opacity 0.15s ease; }
.htmx-settling { opacity: 1; transition: opacity 0.15s ease; }

/* Button hover lift */
.btn-lift { transition: all 0.2s ease; }
.btn-lift:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.btn-lift:active { transform: translateY(0); }

/* Input focus ring animation */
input:focus, select:focus, textarea:focus {
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Smooth toast */
.toast {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Document page for PDF/preview */
.document-page { background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
#document-preview { background: white; }

/* HTMX indicators */
.htmx-request { opacity: 0.7; pointer-events: none; }
.htmx-indicator { opacity: 0; }
.htmx-indicator.htmx-request { opacity: 1; display: flex; }
.htmx-request .htmx-indicator { opacity: 1; }
/* Keep preview action buttons clickable even during HTMX requests */
#preview-actions, #preview-actions button, #preview-actions a { pointer-events: auto !important; opacity: 1 !important; }

/* Spinner */
.spinner {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3); border-radius: 50%;
    border-top-color: #fff; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Print */
@media print {
    body { background: white; }
    nav, footer, .no-print, #mobile-menu, .fixed { display: none !important; }
    #document-preview { box-shadow: none; border: none; }
}

/* Toast (bottom sheet style on mobile) */
.toast {
    padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500;
    color: white; animation: slideUp 0.3s ease; box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    max-width: 340px; word-wrap: break-word;
}
.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }
.toast-info { background: #2563eb; }

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

/* Number input styling */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* Improve touch targets on mobile */
@media (max-width: 767px) {
    button, a.btn, [role="button"] { min-height: 40px; min-width: 40px; }
    input, select, textarea { font-size: 16px !important; }
    .item-row { font-size: 13px; }
    .item-row input { padding: 6px 8px; }
    table { font-size: 12px; }
    h1 { font-size: 1.5rem !important; }
}

/* Smooth mobile menu */
#mobile-menu {
    transition: max-height 0.3s ease, opacity 0.3s ease;
    max-height: 500px; opacity: 1;
}
#mobile-menu.hidden { max-height: 0; opacity: 0; overflow: hidden; }

/* Active bottom nav handled by JS */

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: -200% 0 } 100% { background-position: 200% 0 } }

/* Page skeleton overlay */
.page-skeleton {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(249, 250, 251, 0.85); z-index: 100;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 16px; opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.page-skeleton.active { opacity: 1; pointer-events: all; }
.page-skeleton .sk-bar {
    width: 60%; max-width: 320px; height: 16px;
    border-radius: 8px;
    background: linear-gradient(90deg, #e5e7eb 25%, #d1d5db 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
}
.page-skeleton .sk-bar.short { width: 40%; }
.page-skeleton .sk-bar.medium { width: 50%; }
.page-skeleton .sk-circle {
    width: 48px; height: 48px; border-radius: 50%;
    background: linear-gradient(90deg, #dbeafe 25%, #bfdbfe 50%, #dbeafe 75%);
    background-size: 200% 100%;
    animation: shimmer 1s infinite;
}

/* Better empty states */
.empty-state {
    text-align: center; padding: 3rem 1rem;
}
.empty-state i { opacity: 0.2; margin-bottom: 0.75rem; }
.empty-state p { color: #9ca3af; }

/* Table responsive */
@media (max-width: 767px) {
    .table-responsive { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* Generator form on mobile - stack instead of grid */
@media (max-width: 1023px) {
    .generator-grid { grid-template-columns: 1fr !important; }
    .preview-sticky { position: static !important; }
}

/* Ripple effect */
.ripple { position: relative; overflow: hidden; }
.ripple::after {
    content: ''; position: absolute; border-radius: 50%;
    background: rgba(255,255,255,0.3); width: 100px; height: 100px;
    margin-top: -50px; margin-left: -50px; top: 50%; left: 50%;
    transform: scale(0); opacity: 0; pointer-events: none;
}
.ripple:active::after { animation: ripple 0.6s ease-out; }
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

/* Reveal on scroll — used by landing pages + HTMX swaps */
.reveal-up { opacity: 0; transform: translateY(40px); transition: opacity 0.7s ease-out, transform 0.7s ease-out; }
.reveal-up.revealed { opacity: 1; transform: translateY(0); }

/* ---- Intro.js Tour Theme (Kejar Target brand) ---- */
.introjs-tooltip {
  border-radius: 12px !important;
  padding: 0 !important;
  min-width: 300px !important;
  max-width: 420px !important;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15) !important;
  border: 1px solid #e5e7eb !important;
}

.introjs-tooltip-header {
  padding: 18px 20px 0 20px !important;
}

.introjs-tooltiptitle {
  font-size: 15px !important;
  font-weight: 700 !important;
  color: #111827 !important;
  line-height: 1.3 !important;
}

.introjs-tooltip-body {
  padding: 8px 20px 16px 20px !important;
}

.introjs-tooltiptext {
  font-size: 13px !important;
  line-height: 1.6 !important;
  color: #4b5563 !important;
}

.introjs-tooltiptext strong {
  color: #2563eb;
}

.introjs-tooltipbuttons {
  padding: 0 20px 16px 20px !important;
  border-top: none !important;
  display: flex !important;
  justify-content: flex-end !important;
}

.introjs-button {
  font-size: 13px !important;
  font-weight: 600 !important;
  padding: 8px 18px !important;
  border-radius: 10px !important;
  cursor: pointer !important;
  transition: background 0.2s !important;
  text-shadow: none !important;
  box-shadow: none !important;
  line-height: 1.4 !important;
}

.introjs-nextbutton,
.introjs-donebutton {
  background: #2563eb !important;
  color: #fff !important;
  border: none !important;
}

.introjs-nextbutton:hover,
.introjs-donebutton:hover {
  background: #1d4ed8 !important;
}

.introjs-prevbutton {
  background: #f3f4f6 !important;
  color: #374151 !important;
  border: 1px solid #d1d5db !important;
  margin-right: 8px !important;
}

.introjs-prevbutton:hover {
  background: #e5e7eb !important;
}

.introjs-disabled {
  display: none !important;
}

.introjs-skipbutton {
  background: transparent !important;
  color: #9ca3af !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  padding: 6px 12px !important;
  margin-right: auto !important;
  float: left !important;
}

.introjs-skipbutton:hover {
  color: #6b7280 !important;
}

.introjs-bullets {
  padding: 6px 0 !important;
}

.introjs-bullets ul li a {
  width: 6px !important;
  height: 6px !important;
  background: #d1d5db !important;
}

.introjs-bullets ul li a.active {
  background: #2563eb !important;
}

.introjs-helperLayer {
  border-radius: 12px !important;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.25), 0 0 30px rgba(37,99,235,0.1) !important;
}

.introjs-arrow {
  display: none !important;
}

/* Mobile */
@media (max-width: 640px) {
  .introjs-tooltip {
    min-width: auto !important;
    max-width: 90vw !important;
  }
  .introjs-tooltiptitle { font-size: 14px !important; }
  .introjs-tooltiptext { font-size: 12px !important; }
  .introjs-button { font-size: 12px !important; padding: 7px 14px !important; }
}
