/**
 * Nyieun POS - Modern UI/UX Pro Max Theme
 * Inspired by Tailwind UI, Linear, Apple Human Interface, and Modern Retail POS systems.
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
    /* Brand & Accent Colors */
    --pos-primary: #4F46E5;
    --pos-primary-hover: #4338CA;
    --pos-primary-light: #EEF2FF;
    --pos-primary-glow: rgba(79, 70, 229, 0.25);
    
    --pos-accent: #06B6D4;
    --pos-success: #10B981;
    --pos-success-hover: #059669;
    --pos-success-light: #ECFDF5;
    --pos-warning: #F59E0B;
    --pos-warning-light: #FFFBEB;
    --pos-danger: #EF4444;
    --pos-danger-hover: #DC2626;
    --pos-danger-light: #FEF2F2;
    
    /* Neutrals & Surfaces */
    --pos-bg: #F8FAFC;
    --pos-surface: #FFFFFF;
    --pos-surface-glass: rgba(255, 255, 255, 0.85);
    --pos-border: #E2E8F0;
    --pos-border-light: #F1F5F9;
    
    /* Typography */
    --pos-text-main: #0F172A;
    --pos-text-body: #334155;
    --pos-text-muted: #64748B;
    --pos-text-subtle: #94A3B8;
    
    /* Glassmorphism & Elevation Shadows */
    --pos-shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --pos-shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.05);
    --pos-shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --pos-shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
    --pos-shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    --pos-shadow-glow: 0 0 20px rgba(79, 70, 229, 0.2);
    
    /* Radius */
    --pos-radius-sm: 8px;
    --pos-radius-md: 12px;
    --pos-radius-lg: 16px;
    --pos-radius-xl: 20px;
    --pos-radius-pill: 9999px;

    /* Fast, Snappy Transitions ("Set Set Gitu" - Hardware Accelerated) */
    --pos-transition-fast: 90ms ease-out;
    --pos-transition-smooth: 140ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   Global Reset & Typography
   ========================================================================== */
body, 
.tw-font-sans, 
input, button, select, textarea {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    letter-spacing: -0.011em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--pos-bg) !important;
    color: var(--pos-text-body);
}

/* Monospace for numbers/SKU/prices */
.price-display, .sku-badge, .receipt-number, .font-mono {
    font-family: 'JetBrains Mono', monospace !important;
    font-variant-numeric: tabular-nums;
}

/* Custom Sleek Scrollbar */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* ==========================================================================
   Page Progress Loading Bar
   ========================================================================== */
#pos-page-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #4F46E5, #06B6D4, #10B981);
    z-index: 99999;
    transition: width 0.12s ease-out, opacity 0.15s ease-out;
    box-shadow: 0 0 8px rgba(79, 70, 229, 0.4);
}

/* ==========================================================================
   Shimmer & Skeleton Loader Animations (Lightweight & Smooth)
   ========================================================================== */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton-loader {
    background: linear-gradient(90deg, #F1F5F9 25%, #E2E8F0 50%, #F1F5F9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.1s infinite linear;
    border-radius: var(--pos-radius-sm);
    display: inline-block;
    will-change: background-position;
}

.skeleton-card {
    background: #FFFFFF;
    border: 1px solid var(--pos-border);
    border-radius: var(--pos-radius-md);
    padding: 12px;
    box-shadow: var(--pos-shadow-xs);
}

.skeleton-text {
    height: 12px;
    margin-bottom: 6px;
    width: 100%;
}
.skeleton-title {
    height: 16px;
    margin-bottom: 10px;
    width: 65%;
}
.skeleton-thumb {
    width: 100%;
    height: 72px;
    border-radius: var(--pos-radius-sm);
    margin-bottom: 8px;
}

/* ==========================================================================
   Snappy Micro-interactions & Keyframe Animations
   ========================================================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.97);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    will-change: transform, opacity;
}

.animate-scale-in {
    animation: scaleIn 0.12s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    will-change: transform, opacity;
}

/* Hover Lift Effect */
.hover-lift {
    transition: transform var(--pos-transition-smooth), box-shadow var(--pos-transition-smooth) !important;
    will-change: transform, box-shadow;
}
.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: var(--pos-shadow-md) !important;
}

/* Active Press Micro-interaction */
.active-press {
    transition: transform var(--pos-transition-fast) !important;
    will-change: transform;
}
.active-press:active {
    transform: scale(0.97) !important;
}

/* Ripple effect container */
.has-ripple {
    position: relative;
    overflow: hidden;
}
.ripple-wave {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    animation: rippleAnimation 0.3s linear;
    pointer-events: none;
}
@keyframes rippleAnimation {
    to {
        transform: scale(3.5);
        opacity: 0;
    }
}

/* ==========================================================================
   Header POS Button (Modern Accent & Live Indicator)
   ========================================================================== */
.header-pos-quick-btn {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%) !important;
    border: none !important;
    color: #FFFFFF !important;
    font-weight: 700 !important;
    font-size: 0.875rem !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35) !important;
    border-radius: var(--pos-radius-sm) !important;
    padding: 8px 14px !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all var(--pos-transition-smooth) !important;
    text-decoration: none !important;
    will-change: transform, box-shadow;
}

.header-pos-quick-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.5) !important;
    transform: translateY(-1px);
    color: #FFFFFF !important;
}

.header-pos-quick-btn:active {
    transform: scale(0.97) !important;
}

/* Live Beacon Indicator */
.live-beacon {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #A7F3D0;
    display: inline-block;
}
.live-beacon-ping {
    position: absolute;
    top: -2px;
    left: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #34D399;
    opacity: 0.75;
    animation: beaconPing 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes beaconPing {
    75%, 100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

/* ==========================================================================
   Sidebar: Mini / Icon-Only Auto-Hide Mode (Default Collapsed)
   ========================================================================== */
.theme-logo-bg {
    background: linear-gradient(135deg, #1E1B4B 0%, #312E81 100%) !important;
    height: 60px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    transition: all var(--pos-transition-smooth);
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 12px 4px 12px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94A3B8;
    position: relative;
    transition: all var(--pos-transition-fast);
}
.sidebar-section-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #E2E8F0;
    margin-left: 6px;
}

#side-bar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    font-size: 0.835rem;
    font-weight: 500;
    color: #475569;
    border-radius: 8px;
    margin: 1px 0;
    transition: all var(--pos-transition-fast);
    text-decoration: none !important;
    position: relative;
}

#side-bar a:hover {
    background: #F1F5F9;
    color: var(--pos-primary);
    transform: translateX(2px);
}

#side-bar a.theme-sidebar-active {
    background: var(--pos-primary-light) !important;
    color: var(--pos-primary) !important;
    font-weight: 600 !important;
}

/* --- Mini / Icon-Only Sidebar on Desktop --- */
@media (min-width: 992px) {
    /* Default state: Mini icon-only sidebar (68px wide) */
    aside.side-bar.sidebar-auto-mini {
        width: 68px !important;
        min-width: 68px !important;
        max-width: 68px !important;
        transition: width 140ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 140ms ease !important;
        overflow-x: hidden !important;
        z-index: 1025 !important;
        box-shadow: 1px 0 3px rgba(0, 0, 0, 0.04);
    }

    /* Expanding on mouse hover OR when locked open via toggle button */
    aside.side-bar.sidebar-auto-mini:hover,
    aside.side-bar.sidebar-auto-mini.sidebar-expanded {
        width: 256px !important;
        min-width: 256px !important;
        max-width: 256px !important;
        box-shadow: 6px 0 24px rgba(0, 0, 0, 0.08) !important;
    }

    /* When in mini mode (not hovered and not manually expanded): */
    aside.side-bar.sidebar-auto-mini:not(:hover):not(.sidebar-expanded) .side-bar-heading {
        display: none !important;
    }

    aside.side-bar.sidebar-auto-mini:not(:hover):not(.sidebar-expanded) .mini-sidebar-logo-icon {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    aside.side-bar.sidebar-auto-mini:not(:hover):not(.sidebar-expanded) #sidebar-search,
    aside.side-bar.sidebar-auto-mini:not(:hover):not(.sidebar-expanded) #sidebar-search-clear,
    aside.side-bar.sidebar-auto-mini:not(:hover):not(.sidebar-expanded) #sidebar-no-results {
        display: none !important;
    }

    aside.side-bar.sidebar-auto-mini:not(:hover):not(.sidebar-expanded) .sidebar-section-header span {
        display: none !important;
    }
    aside.side-bar.sidebar-auto-mini:not(:hover):not(.sidebar-expanded) .sidebar-section-header {
        padding: 3px 0 !important;
        margin: 5px 12px !important;
        border-top: 1px solid #E2E8F0 !important;
    }
    aside.side-bar.sidebar-auto-mini:not(:hover):not(.sidebar-expanded) .sidebar-section-header::after {
        display: none !important;
    }

    /* Center icon buttons */
    aside.side-bar.sidebar-auto-mini:not(:hover):not(.sidebar-expanded) #side-bar a {
        justify-content: center !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin: 2px 4px !important;
        width: calc(100% - 8px) !important;
    }

    aside.side-bar.sidebar-auto-mini:not(:hover):not(.sidebar-expanded) #side-bar a span.tw-truncate {
        display: none !important;
    }

    aside.side-bar.sidebar-auto-mini:not(:hover):not(.sidebar-expanded) #side-bar a svg.svg {
        display: none !important;
    }

    /* Hide submenus when mini */
    aside.side-bar.sidebar-auto-mini:not(:hover):not(.sidebar-expanded) .chiled {
        display: none !important;
    }

    aside.side-bar.sidebar-auto-mini:not(:hover):not(.sidebar-expanded) #side-bar a:hover {
        transform: scale(1.08) !important;
        background: #EEF2FF !important;
        color: var(--pos-primary) !important;
    }
}

/* ==========================================================================
   Modern POS Product Grid & Cards (Clean, Organized, Snappy)
   ========================================================================== */
.pos-grid-col {
    padding-left: 3px !important;
    padding-right: 3px !important;
    margin-bottom: 6px !important;
}

.pos-product-card {
    background: #FFFFFF;
    border: 1px solid var(--pos-border);
    border-radius: 12px;
    padding: 7px;
    cursor: pointer;
    transition: transform var(--pos-transition-smooth), box-shadow var(--pos-transition-smooth), border-color var(--pos-transition-smooth);
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 168px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    user-select: none;
    will-change: transform, box-shadow;
}

.pos-product-card:hover {
    border-color: #6366F1;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.12);
    transform: translateY(-2px);
}

.pos-product-card:active {
    transform: scale(0.96) !important;
}

.pos-featured-card {
    background: #FFFDF5;
    border-color: #FDE68A;
}
.pos-featured-card:hover {
    border-color: #F59E0B;
}

.pos-product-card.is-out-of-stock {
    background: #F8FAFC !important;
    opacity: 0.65;
}

/* Product Thumbnail Box */
.pos-card-thumb {
    width: 100%;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background-color: #F8FAFC;
    border: 1px solid #F1F5F9;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.pos-card-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 2px;
    transition: transform var(--pos-transition-fast);
}

.pos-product-card:hover .pos-card-img {
    transform: scale(1.06);
}

/* Fallback Aesthetic Placeholder When Image Is Missing */
.pos-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #F0FDF4 0%, #F8FAFC 50%, #EEF2FF 100%);
    position: relative;
    padding: 4px;
}

.pos-card-initials {
    font-size: 13px;
    font-weight: 800;
    color: #4F46E5;
    letter-spacing: 0.5px;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 7px;
    border-radius: 6px;
    border: 1px solid rgba(79, 70, 229, 0.15);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    line-height: 1.2;
}

.pos-card-placeholder-icon {
    width: 18px;
    height: 18px;
    color: #94A3B8;
    margin-top: 3px;
}

/* Product Body & Meta */
.pos-card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.pos-card-title {
    font-size: 11.5px;
    font-weight: 600;
    color: #1E293B;
    line-height: 14px;
    min-height: 28px;
    max-height: 28px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 2px;
    text-align: center;
}

.pos-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    width: 100%;
}

.pos-card-sku {
    font-size: 10px;
    font-family: 'JetBrains Mono', monospace, ui-monospace;
    color: #64748B;
    font-weight: 500;
}

.product-stock-tag {
    font-size: 9.5px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: -0.2px;
    line-height: 1.2;
}

.pos-stock-in {
    background: #ECFDF5;
    color: #047857;
    border: 1px solid #A7F3D0;
}

.pos-stock-out {
    background: #FFF1F2;
    color: #BE123C;
    border: 1px solid #FECDD3;
}

/* Selling Price - Prominent & Green */
.product-price-badge {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 800;
    color: #059669;
    line-height: 14px;
    text-align: center;
    font-family: 'JetBrains Mono', 'Plus Jakarta Sans', sans-serif;
    letter-spacing: -0.3px;
}

/* ==========================================================================
   POS Cart Line Item Thumbnail (Left Billing Table)
   ========================================================================== */
.pos-cart-thumb-box {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #F1F5F9;
    border: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.pos-cart-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pos-cart-thumb-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #EEF2FF 0%, #F1F5F9 100%);
    color: #4F46E5;
}

/* ==========================================================================
   POS Action Buttons Bar
   ========================================================================== */
.pos-action-btn-cash {
    background: linear-gradient(135deg, #10B981, #059669) !important;
    color: #FFFFFF !important;
    font-weight: 700 !important;
    font-size: 1rem !important;
    border-radius: var(--pos-radius-md) !important;
    padding: 11px 18px !important;
    border: none !important;
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.3) !important;
    transition: all var(--pos-transition-smooth) !important;
    will-change: transform, box-shadow;
}
.pos-action-btn-cash:hover {
    background: linear-gradient(135deg, #059669, #047857) !important;
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(16, 185, 129, 0.4) !important;
}
.pos-action-btn-cash:active {
    transform: scale(0.97) !important;
}

.pos-action-btn-multi {
    background: linear-gradient(135deg, #4F46E5, #4338CA) !important;
    color: #FFFFFF !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    border-radius: var(--pos-radius-md) !important;
    padding: 11px 18px !important;
    border: none !important;
    box-shadow: 0 3px 10px rgba(79, 70, 229, 0.3) !important;
    transition: all var(--pos-transition-smooth) !important;
    will-change: transform, box-shadow;
}
.pos-action-btn-multi:hover {
    background: linear-gradient(135deg, #4338CA, #3730A3) !important;
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(79, 70, 229, 0.4) !important;
}
.pos-action-btn-multi:active {
    transform: scale(0.97) !important;
}
