*,
::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;
}

/* Landing: Gratis Banner */
.gratis-banner {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 40%, #1e40af 100%);
    position: relative;
    overflow: hidden;
}
.gratis-banner::before {
    content: '';
    position: absolute;
    top: -50%; right: -20%;
    width: 300px; height: 300px;
    background: rgba(255,255,255,0.03);
    border-radius: 50%;
}
.gratis-banner .feature-pill {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Landing: Device Mockup (How It Works step 2) */
.device-mockup {
    position: relative;
    width: 140px; height: 220px;
    background: #1e293b;
    border-radius: 16px;
    padding: 6px;
    margin: 12px auto -8px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.15);
}
.device-mockup::before {
    content: '';
    position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
    width: 30px; height: 3px;
    background: #475569;
    border-radius: 2px;
}
.device-screen {
    background: #fff;
    border-radius: 12px;
    height: 100%;
    overflow: hidden;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.device-screen .ds-header {
    height: 10px;
    border-radius: 3px;
    background: var(--mock-pc, #2563eb);
    opacity: 0.8;
}
.device-screen .ds-row {
    display: flex; gap: 4px;
}
.device-screen .ds-row span {
    flex: 1; height: 6px; border-radius: 2px;
    background: #e5e7eb;
}
.device-screen .ds-row span.wide {
    flex: 2;
}
.device-screen .ds-total {
    height: 8px; border-radius: 3px;
    background: var(--mock-ac, #f59e0b);
    margin-top: auto;
    width: 60%;
    align-self: flex-end;
}
.device-pulse {
    animation: devicePulse 3s ease-in-out infinite;
}
@keyframes devicePulse {
    0%, 100% { box-shadow: 0 12px 32px rgba(0,0,0,0.15); }
    50% { box-shadow: 0 16px 40px rgba(37,99,235,0.25); }
}

/* Landing: Document selector grid (How It Works step 1) */
.doc-selector-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: 130px;
    padding: 4px;
}
.dsg-item {
    aspect-ratio: 1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    transition: all 0.3s;
}
.dsg-item.active {
    border-color: #16a34a;
    box-shadow: 0 0 0 3px rgba(22,163,74,0.15);
}
.dsg-dot {
    width: 12px; height: 12px;
    border-radius: 4px;
}

/* Landing: Export/Share mockup (How It Works step 3) */
.export-mockup {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    width: 155px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.em-preview-line {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    margin-bottom: 6px;
}
.em-preview-line.short {
    width: 55%;
    margin-bottom: 12px;
}
.em-buttons {
    display: flex;
    gap: 5px;
}
.em-btn {
    flex: 1;
    text-align: center;
    padding: 5px 0;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    background: #f3f4f6;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 1px solid #e5e7eb;
}
.em-btn.primary {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.em-inline-icon {
    font-style: normal;
    font-size: 11px;
    line-height: 1;
}

/* Landing: Trust Badges strip */
.trust-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    transition: all 0.3s;
}
.trust-badge:hover {
    border-color: #93c5fd;
    box-shadow: 0 4px 12px rgba(37,99,235,0.08);
    transform: translateY(-2px);
}

/* Landing: Testimonial cards */
.testimonial-card {
    position: relative;
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid #e5e7eb;
    transition: all 0.3s;
}
.testimonial-card:hover {
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    transform: translateY(-4px);
    border-color: #d1d5db;
}
.testimonial-card .t-quote {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 48px;
    line-height: 1;
    color: #e5e7eb;
    font-family: 'Georgia', serif;
}
.testimonial-card .t-avatar {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    flex-shrink: 0;
}
@media (max-width: 767px) {
    .testimonial-card { padding: 20px; }
    .testimonial-card .t-quote { top: 10px; right: 12px; font-size: 36px; }
}

/* Landing: FAQ cards */
.faq-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 18px 20px;
    transition: all 0.3s;
    cursor: default;
}
.faq-card:hover {
    border-color: #bfdbfe;
    box-shadow: 0 2px 12px rgba(37,99,235,0.06);
}
.faq-card .faq-q {
    font-weight: 700;
    font-size: 15px;
    color: #111827;
    margin-bottom: 4px;
}
.faq-card .faq-a {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.6;
}

/* Landing: Freshness badge in hero */
.freshness-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(251,191,36,0.15);
    border: 1px solid rgba(251,191,36,0.3);
    color: #fef3c7;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 14px;
    border-radius: 20px;
}
@media (max-width: 640px) {
    .freshness-badge { font-size: 10px; padding: 3px 10px; }
}

/* Mobile: sticky CTA bar */
@media (max-width: 767px) {
    .mobile-cta-bar {
        display: flex;
        position: fixed;
        bottom: 56px;
        left: 0; right: 0;
        background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
        padding: 10px 16px;
        z-index: 49;
        justify-content: center;
        gap: 10px;
        box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
    }
}
