/* ============================================================
   Apex POS — Custom Styles
   ============================================================ */

/* ── Prevent flash on load ── */
[v-cloak] {
    display: none !important;
}

/* ── Global Dark Theme Surface Defaults ── */
html.dark,
html.dark body {
    background-color: var(--page) !important;
    color: var(--ink) !important;
}

html.dark #app {
    background-color: var(--page) !important;
}

/* ── Canvas Chart Container Constraints ── */
canvas {
    max-width: 100% !important;
    max-height: 100% !important;
}

/* ── Smooth scrolling (respecting reduced motion) ── */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    .pulse-emerald,
    .animate-pulse,
    .animate-bounce {
        animation: none !important;
    }
    .fade-enter-active,
    .fade-leave-active,
    .slide-in-enter-active,
    .slide-in-leave-active,
    .transition-all,
    .transition-colors,
    .transition-transform,
    .transition-opacity,
    .group-hover\:scale-105 {
        transition: none !important;
    }
}

/* ── Custom scrollbars ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* ── Print Styles — POS Thermal Receipts ── */
@media print {
    /* Hide everything on the page except the receipt container */
    body * {
        visibility: hidden;
    }

    #receipt-print-area,
    #receipt-print-area * {
        visibility: visible;
    }

    #receipt-print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 80mm;
        font-family: 'Courier New', Courier, monospace;
        color: #000000;
        font-size: 12px;
        line-height: 1.2;
        padding: 5px;
        background: white;
    }

    @page {
        size: auto;
        margin: 0mm;
    }
}

/* ── Animations ── */
.fade-enter-active,
.fade-leave-active {
    transition: opacity 0.2s ease;
}

.fade-enter-from,
.fade-leave-to {
    opacity: 0;
}

.slide-in-enter-active,
.slide-in-leave-active {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.slide-in-enter-from,
.slide-in-leave-to {
    transform: translateX(100%);
}

/* ── Grid Layout ── */
.products-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

@media (min-width: 640px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

/* ── Pulse effect for scanned items ── */
.pulse-emerald {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 2s infinite cubic-bezier(0.66, 0, 0, 1);
}

@keyframes pulse {
    to {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

/* ── Accessibility ── */

/* Focus visibility: WCAG 2.4.7 + 2.4.13 */
:focus-visible {
    outline: 2px solid #22c55e;
    outline-offset: 2px;
}

/* Skip-to-content link (hidden until focused) */
.skip-to-content {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 10000;
    padding: 12px 24px;
    background: #22c55e;
    color: #0f172a;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    border-radius: 0 0 8px 0;
}

.skip-to-content:focus {
    left: 0;
}

/* Touch target sizing: WCAG 2.5.8 (44x44px minimum) */
.products-grid button,
button:has(> i),
a:has(> i) {
    min-height: 44px;
    min-width: 44px;
}

/* High contrast mode support */
@media (forced-colors: active) {
    .border,
    .border-slate-200,
    .border-slate-300,
    .border-slate-700,
    .border-slate-800 {
        border-color: CanvasText !important;
    }
    button:focus-visible {
        outline: 2px solid Highlight !important;
        outline-offset: 2px;
    }
}

/* Reduced data: prefers reduced data */
@media (prefers-reduced-data: reduce) {
    .products-grid img {
        display: none;
    }
    .products-grid .aspect-square {
        background: #e2e8f0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .products-grid .aspect-square::after {
        content: "📦";
        font-size: 2rem;
    }
}

/* ── Inline SVG icon helper ── */
.icon-inline {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    fill: currentColor;
}

/* ── Toast notification bounce ── */
@media (prefers-reduced-motion: no-preference) {
    .toast-enter-active {
        animation: toast-in 0.3s ease-out;
    }
    .toast-leave-active {
        animation: toast-out 0.2s ease-in;
    }
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(20px) scale(0.95); }
}

/* ── Skeleton loading state ── */
.skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

.dark .skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Utility: truncate with ellipsis ── */
.truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Utility: hide visually but keep accessible ── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ── Camera Barcode Scanner ── */
.barcode-scanner-video {
    width: 100%;
    max-height: 240px;
    border-radius: 12px;
    background: #000;
    display: block;
}

.dark .barcode-scanner-video {
    border: 1px solid #334155;
}

/* ── Receipt Logo ── */
.receipt-logo-preview {
    max-height: 60px;
    width: auto;
    object-fit: contain;
}

