/*
 * This WebApp is developed, maintained and operated by Mr. James Ngugi Kaburu,
 * A Developer, Economist, Certified Fraud Examiner and Entrepreneur.
 * Contact him on WhatsApp or call +254710496209.
 */
/* ============================================================================
 * Kenya Auto Deals — Global Full-Width, Mobile-First Responsive Design System
 * Zero Node.js / Zero Vite — 100% Pure CSS (320px Fold → 3840px 4K UHD)
 * ============================================================================ */

:root {
    --kad-navy: #0b1325;
    --kad-red: #dc2626;
    --kad-red-dark: #b91c1c;
    --kad-green: #15803d;
    --kad-gold: #facc15;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
}

/* 1. Prevent horizontal scroll at ALL breakpoints (320px → 3840px & 200% zoom) */
html, body {
    max-width: 100%;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

img, svg, video, canvas, iframe {
    max-width: 100%;
}

/* 2. Fluid Typography via clamp() */
.kad-h1 { font-size: clamp(1.75rem, 3.8vw + 0.5rem, 4.25rem); line-height: 1.08; }
.kad-h2 { font-size: clamp(1.35rem, 2.2vw + 0.4rem, 2.75rem); line-height: 1.15; }
.kad-h3 { font-size: clamp(1.1rem, 1.3vw + 0.35rem, 1.75rem); line-height: 1.25; }
.kad-lead { font-size: clamp(0.95rem, 0.7vw + 0.7rem, 1.25rem); line-height: 1.55; }

/* 3. Full-width edge-to-edge section container (no wasted desktop white gutters) */
.kad-full {
    width: 100%;
    padding-left: max(1rem, var(--safe-left));
    padding-right: max(1rem, var(--safe-right));
}
@media (min-width: 768px) {
    .kad-full { padding-left: max(2rem, var(--safe-left)); padding-right: max(2rem, var(--safe-right)); }
}
@media (min-width: 1024px) {
    .kad-full { padding-left: max(3rem, var(--safe-left)); padding-right: max(3rem, var(--safe-right)); }
}
@media (min-width: 1280px) {
    .kad-full { padding-left: max(4rem, var(--safe-left)); padding-right: max(4rem, var(--safe-right)); }
}

/* Upgrade legacy boxed max-w-7xl sections inside main/header/footer to stretch edge-to-edge on >=1024px */
@media (min-width: 1024px) {
    .kad-edge-page main > section > .max-w-7xl,
    .kad-edge-page main > .max-w-7xl,
    .kad-edge-page main > div > .max-w-7xl {
        max-width: 100% !important;
        padding-left: 3rem;
        padding-right: 3rem;
    }
}
@media (min-width: 1280px) {
    .kad-edge-page main > section > .max-w-7xl,
    .kad-edge-page main > .max-w-7xl,
    .kad-edge-page main > div > .max-w-7xl {
        padding-left: 4rem;
        padding-right: 4rem;
    }
}

/* 4. Popular / Marketplace Vehicle Grid: 1 -> 2 -> 3 -> 4 -> 5 -> 6 columns full width */
.kad-car-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1.25rem;
    width: 100%;
}
@media (min-width: 640px)  { .kad-car-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 768px)  { .kad-car-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .kad-car-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .kad-car-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 1536px) { .kad-car-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* 5. Minimum 44x44px touch targets & no forced iOS zoom on input focus (16px floor) */
.kad-tap,
button,
[role="button"],
a.kad-btn,
input[type="submit"],
input[type="button"] {
    min-height: 44px;
}

.kad-tap-icon {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Keep compact pill toggles neat on desktop while touch-safe on mobile */
@media (min-width: 1024px) {
    header button.kad-compact,
    nav button.kad-compact,
    .kad-compact {
        min-height: 32px;
    }
}

@media (max-width: 1023px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select,
    textarea {
        font-size: 16px !important;
        min-height: 44px;
    }
}

/* 6. Responsive Horizontal Scroll Tables (never break 320px/375px layout) */
.kad-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.kad-table-wrap table {
    min-width: 640px;
    width: 100%;
}

/* 7. Full-screen Modals / Bottom Sheets on Mobile */
@media (max-width: 639px) {
    .kad-modal-panel {
        width: 100vw !important;
        max-width: 100vw !important;
        min-height: 100dvh;
        border-radius: 0 !important;
        margin: 0 !important;
        padding-bottom: max(1.5rem, var(--safe-bottom));
    }
}

/* 8. Sticky Mobile Bottom Safe-Area Bar */
.kad-mobile-bar {
    padding-bottom: max(0.5rem, var(--safe-bottom));
}
@media (max-width: 1023px) {
    body.has-mobile-sticky {
        padding-bottom: calc(68px + var(--safe-bottom));
    }
}

/* 9. PWA Standalone Display Mode Safe Areas */
@media (display-mode: standalone) {
    body {
        padding-top: var(--safe-top);
    }
}

/* 10. Signature Pad Responsive Canvas */
.kad-sig-canvas {
    width: 100%;
    height: 190px;
    touch-action: none;
    cursor: crosshair;
    background: #ffffff;
    border: 2px dashed #94a3b8;
    border-radius: 12px;
    display: block;
}
.kad-sig-canvas:focus {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

/* 11. Accessible Contrast, Motion & Foldables (320px) */
@media (max-width: 359px) {
    .kad-full { padding-left: 0.75rem; padding-right: 0.75rem; }
}

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

@media (prefers-contrast: more) {
    a, button { text-decoration-thickness: 2px; }
    .border-slate-200 { border-color: #64748b !important; }
}

/* 12. Bottom-Left Logo Watermark, Anti-Download Image Guard & Diagonal SOLD Ribbon */
img {
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
    user-select: none;
}

.kad-wm-badge {
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 15;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(11, 19, 37, 0.78);
    backdrop-filter: blur(2px);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #ffffff;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.06em;
    line-height: 1;
    pointer-events: none;
    user-select: none;
    max-width: 55%;
}

.kad-wm-logo-img {
    height: 18px;
    width: auto;
    max-width: 96px;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.kad-wm-ke-bar {
    width: 3px;
    height: 12px;
    border-radius: 2px;
    background: linear-gradient(180deg, #111827 0%, #dc2626 50%, #15803d 100%);
    flex-shrink: 0;
}

.kad-sold-ribbon {
    position: absolute;
    top: 18px;
    left: -34px;
    z-index: 25;
    width: 140px;
    text-align: center;
    background: #dc2626;
    color: #ffffff;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.14em;
    padding: 4px 0;
    transform: rotate(-38deg);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
    border-top: 1px solid rgba(255, 255, 255, 0.35);
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
    pointer-events: none;
}

/* 13. Print Styling for Brochures, Comparisons & Contracts */
@media print {
    .no-print, .kad-mobile-bar, #kad-whatsapp-float, #kad-chat-widget, #kad-social-ticker, #kad-scroll-bar {
        display: none !important;
    }
    body { background: #fff !important; color: #000 !important; padding: 0 !important; }
}

/* Part 32: Skeleton Shimmer Loaders */
.kad-skeleton {
    position: relative;
    overflow: hidden;
    background: #e2e8f0;
    border-radius: 0.75rem;
}
.kad-skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    animation: kadShimmer 1.4s infinite;
}
@keyframes kadShimmer {
    100% { transform: translateX(100%); }
}

/* ============================================================================
 * Unified Portal & Public Design System Tokens (Admin, Account, Dealer, Buyer, Pro)
 * Guarantees exact same Plus Jakarta Sans typography, colors, surfaces & focus feel
 * ============================================================================ */
.kad-portal-shell {
    font-family: 'Plus Jakarta Sans', Inter, system-ui, -apple-system, sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.kad-portal-shell h1,
.kad-portal-shell h2,
.kad-portal-shell h3 {
    letter-spacing: -0.015em;
}

.kad-portal-shell input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]):focus,
.kad-portal-shell select:focus,
.kad-portal-shell textarea:focus {
    outline: none;
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.kad-portal-sidebar {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}
.kad-portal-sidebar::-webkit-scrollbar {
    width: 6px;
}
.kad-portal-sidebar::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 9999px;
}
.kad-portal-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.kad-portal-main > .max-w-7xl,
.kad-portal-main > .max-w-6xl,
.kad-portal-main > .max-w-5xl,
.kad-portal-main > .max-w-4xl,
.kad-portal-main > section.max-w-6xl,
.kad-portal-main > section.max-w-5xl,
.kad-portal-main > section.max-w-4xl {
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Darker high-contrast internal sidebar scrollbar (Admin & User/Dealer Portals) */
.kad-portal-sidebar-dark {
    background-color: #0b1325;
    color: #f1f5f9;
    scrollbar-color: #334155 #0b1325;
}
.kad-portal-sidebar-dark::-webkit-scrollbar {
    width: 6px;
}
.kad-portal-sidebar-dark::-webkit-scrollbar-track {
    background: #080f1e;
}
.kad-portal-sidebar-dark::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 9999px;
}
.kad-portal-sidebar-dark::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* ============================================================================
 * Responsive Sidebar Locking:
 *   - Phone / Tablet (< 1024px): ALWAYS hidden off-canvas until explicitly opened
 *   - PC / Laptop (>= 1024px):   ALWAYS fixed / pinned & fully opened on the left
 * ============================================================================ */
@media (max-width: 1023.98px) {
    .kad-responsive-sidebar:not(.is-mobile-open) {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        transform: translateX(-100%) !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
    .kad-responsive-sidebar.is-mobile-open {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        transform: translateX(0) !important;
        visibility: visible !important;
        pointer-events: auto !important;
        z-index: 70 !important;
    }
}

@media (min-width: 1024px) {
    .kad-responsive-sidebar-fixed {
        position: fixed !important;
        top: var(--kad-topbar-h, 94px) !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 16.5rem !important;
        height: auto !important;
        transform: translateX(0) !important;
        visibility: visible !important;
        pointer-events: auto !important;
        overflow-y: auto !important;
        z-index: 30 !important;
    }
    .kad-responsive-main-fixed {
        margin-left: 16.5rem !important;
        width: calc(100% - 16.5rem) !important;
        max-width: calc(100% - 16.5rem) !important;
    }
    .kad-responsive-sidebar-app {
        position: sticky !important;
        top: 61px !important;
        align-self: flex-start !important;
        width: 15.5rem !important;
        height: calc(100vh - 61px) !important;
        transform: translateX(0) !important;
        visibility: visible !important;
        pointer-events: auto !important;
        overflow-y: auto !important;
        z-index: 20 !important;
    }
}

@media (min-width: 1280px) {
    .kad-responsive-sidebar-fixed {
        width: 17rem !important;
    }
    .kad-responsive-main-fixed {
        margin-left: 17rem !important;
        width: calc(100% - 17rem) !important;
        max-width: calc(100% - 17rem) !important;
    }
    .kad-responsive-sidebar-app {
        width: 16rem !important;
    }
}

@media print {
    .kad-responsive-sidebar {
        display: none !important;
    }
    .kad-responsive-main-fixed {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}



