:root {
    --cp-primary: #1e3a8a;
    --cp-primary-hover: #1d4ed8;
    --cp-primary-light: #eff6ff;
    --cp-dark: #0f172a;
    --cp-surface: #1e293b;
    --cp-surface-card: #ffffff;
    --cp-bg: #f8fafc;
    --cp-border: #e2e8f0;
    --cp-text-main: #0f172a;
    --cp-text-muted: #64748b;
    --cp-success: #10b981;
    --cp-success-light: #ecfdf5;
    --cp-warning: #f59e0b;
    --cp-warning-light: #fffbeb;
    --cp-danger: #ef4444;
    --cp-danger-light: #fef2f2;
    --cp-info: #0ea5e9;
    --cp-accent: #d946ef;
    --cp-shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.07), 0 1px 2px -1px rgb(0 0 0 / 0.07);
    --cp-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
    --cp-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--cp-bg);
    color: var(--cp-text-main);
    overflow-x: hidden;
}

/* Sidebar Navigation */
.cp-sidebar {
    width: 260px;
    background: #0b132b;
    color: #cbd5e1;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

.cp-sidebar .brand-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cp-sidebar .brand-logo-badge {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    font-weight: 700;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.cp-sidebar .nav-link {
    color: #94a3b8;
    padding: 0.65rem 1rem;
    margin: 0.2rem 0.75rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.cp-sidebar .nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

.cp-sidebar .nav-link.active {
    color: #ffffff;
    background: linear-gradient(90deg, #1d4ed8 0%, #2563eb 100%);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.cp-sidebar .nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 1rem 1.25rem 0.35rem 1.25rem;
    font-weight: 700;
}

/* Main Content Area */
.cp-main-wrapper {
    margin-left: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

@media (max-width: 991.98px) {
    .cp-sidebar {
        margin-left: -260px;
    }
    .cp-sidebar.show {
        margin-left: 0;
    }
    .cp-main-wrapper {
        margin-left: 0;
    }
    .cp-navbar {
        padding: 0.5rem 0.75rem;
    }
}

/* Sidebar Mobile Backdrop Overlay */
.cp-sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(3px);
    z-index: 1039;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.cp-sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Top Navbar */
.cp-navbar {
    background: #ffffff;
    border-bottom: 1px solid var(--cp-border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

/* Cards & Surfaces */
.cp-card {
    background: #ffffff;
    border: 1px solid var(--cp-border);
    border-radius: 12px;
    box-shadow: var(--cp-shadow-sm);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.cp-card-hover:hover {
    box-shadow: var(--cp-shadow);
    transform: translateY(-2px);
}

.cp-stat-card {
    border-left: 4px solid var(--cp-primary);
}

.cp-stat-card.stat-success { border-left-color: var(--cp-success); }
.cp-stat-card.stat-warning { border-left-color: var(--cp-warning); }
.cp-stat-card.stat-danger  { border-left-color: var(--cp-danger); }
.cp-stat-card.stat-info    { border-left-color: var(--cp-info); }

/* ==========================================================================
   CosmeticPro POS Terminal - Luxury Retail Experience
   ========================================================================== */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 430px;
    gap: 1rem;
    height: calc(100vh - 72px);
    overflow: hidden;
    padding: 0.75rem 1rem 1rem 1rem;
    background-color: #f1f5f9;
}

/* Mobile & Tablet Responsive POS Layout */
@media (max-width: 991.98px) {
    .pos-layout {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 65px);
        overflow: visible;
        padding: 0.4rem;
        padding-bottom: 95px; /* space for fixed mobile bottom checkout bar */
        background-color: #f8fafc;
    }

    .pos-catalog-panel,
    .pos-cart-panel {
        height: auto !important;
        border-radius: 14px;
        padding: 0.75rem !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    }

    /* Tab switching on mobile */
    .pos-panel-tab.d-mobile-hidden {
        display: none !important;
    }

    #catalogScrollContainer {
        max-height: none !important;
        overflow: visible !important;
        padding-bottom: 2rem;
    }

    #cartItemsList {
        max-height: none !important;
        overflow: visible !important;
    }

    /* Ergonomic Touch Targets */
    .pos-qty-stepper button {
        padding: 6px 14px;
        font-size: 1.05rem;
        min-width: 38px;
        min-height: 38px;
    }

    .pos-qty-stepper input {
        width: 44px;
        height: 38px;
        font-size: 0.95rem;
    }

    .quick-cash-chip {
        padding: 0.5rem 0.85rem;
        font-size: 0.85rem;
    }

    .pos-product-card {
        padding: 0.65rem;
        border-radius: 12px;
    }

    .pos-product-img-box {
        height: 72px;
    }
}

.pos-catalog-panel {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 1rem 1.25rem;
    height: 100%;
    overflow: hidden;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.04);
}

.pos-cart-panel {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    height: 100%;
    overflow: hidden;
    box-shadow: 0 8px 25px -4px rgba(0, 0, 0, 0.06);
}

/* Mobile Segmented Nav Pill Switcher */
.pos-mobile-nav {
    display: flex;
    background: #e2e8f0;
    padding: 3px;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    gap: 3px;
}

.pos-mobile-nav button {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.55rem 0.75rem;
    border-radius: 9px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
}

.pos-mobile-nav button.active {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Floating Sticky Bottom Cart / Pay Bar for Mobile */
.pos-mobile-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #ffffff;
    padding: 0.75rem 1rem;
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.pos-mobile-bottom-bar .cart-badge-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Category Filter Pills */
.pos-cat-pill {
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.pos-cat-pill:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.pos-cat-pill.active {
    background: #1e293b;
    color: #ffffff;
    border-color: #1e293b;
    box-shadow: 0 3px 8px rgba(30, 41, 59, 0.25);
}

/* Global Utility for Compact Buttons */
.btn-xs {
    padding: 0.22rem 0.55rem;
    font-size: 0.75rem;
    line-height: 1.25;
    border-radius: 6px;
    font-weight: 600;
}

/* Fluid Auto-Fill Responsive POS Product Grid (Never Squeezed) */
.pos-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: 0.85rem;
}

@media (min-width: 1400px) {
    .pos-product-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 575.98px) {
    .pos-product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
}

/* Cosmetic Product Cards - Luxury Retail Experience */
.pos-product-card {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 0.75rem;
    cursor: pointer;
    background: #ffffff;
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.pos-product-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 12px 28px -4px rgba(30, 58, 138, 0.12);
    transform: translateY(-3px);
}

.pos-product-card:active {
    transform: scale(0.98);
}

.pos-product-img-box {
    height: 120px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.65rem;
    overflow: hidden;
    position: relative;
    border: 1px solid #f1f5f9;
}

.pos-product-img-box img {
    max-height: 110px;
    max-width: 92%;
    object-fit: contain;
    border-radius: 6px;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.08));
    transition: transform 0.3s ease;
}

.pos-product-card:hover .pos-product-img-box img {
    transform: scale(1.08) translateY(-2px);
}

/* Short Code Badge Pill */
.pos-code-badge {
    background: #0f172a;
    color: #38bdf8;
    font-family: monospace;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 1px;
    letter-spacing: 0.02em;
}

.pos-brand-pill {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    display: inline-block;
    max-width: 110px;
}

/* Product Title 2-Line Clamp */
.pos-product-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.7em;
    margin-top: 2px;
}

/* Stock Badges */
.pos-stock-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 12px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.pos-stock-badge.in-stock {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.pos-stock-badge.low-stock {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

.pos-stock-badge.out-stock {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

/* Card Bottom Footer Row */
.pos-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid #f1f5f9;
}

.pos-add-btn {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 7px;
    padding: 0.25rem 0.65rem;
    font-size: 0.76rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.pos-add-btn:hover {
    background: #1d4ed8;
    color: #ffffff;
    border-color: #1d4ed8;
    box-shadow: 0 3px 8px rgba(29, 78, 216, 0.35);
}

.pos-shade-pill {
    background: #fdf2f8;
    color: #db2777;
    border: 1px solid #fbcfe8;
    border-radius: 12px;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 7px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

/* Shade Swatches */
.pos-shade-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1.5px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    display: inline-block;
    margin-right: -4px;
    vertical-align: middle;
}

.pos-shade-swatch-lg {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

/* Cart Item Rows */
.pos-cart-item {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.7rem 0.8rem;
    margin-bottom: 0.5rem;
    transition: all 0.15s ease;
}

.pos-cart-item:hover {
    border-color: #cbd5e1;
    background: #fdfdfe;
}

.pos-qty-stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
    background: #f8fafc;
}

.pos-qty-stepper button {
    border: none;
    background: transparent;
    padding: 3px 9px;
    font-weight: 700;
    font-size: 0.85rem;
    color: #475569;
    transition: background 0.15s;
    cursor: pointer;
}

.pos-qty-stepper button:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.pos-qty-stepper input {
    border: none;
    width: 38px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    background: #ffffff;
    outline: none;
    padding: 2px 0;
}

/* Grand Total Display Box */
.pos-grand-total-card {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #ffffff;
    border-radius: 14px;
    padding: 0.85rem 1.15rem;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.2);
}

/* Quick Cash Tender Chips */
.quick-cash-chip {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #1e293b;
    border-radius: 8px;
    padding: 0.35rem 0.75rem;
    font-weight: 600;
    font-size: 0.825rem;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.quick-cash-chip:hover {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
    transform: translateY(-1px);
}

.quick-cash-chip:active {
    transform: translateY(0);
}

/* Keypad Shortcut Pill */
.shortcut-pill {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 6px;
    font-family: monospace;
}

/* Custom Scrollbar */
.pos-catalog-panel ::-webkit-scrollbar,
.pos-cart-panel ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.pos-catalog-panel ::-webkit-scrollbar-thumb,
.pos-cart-panel ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.pos-catalog-panel ::-webkit-scrollbar-thumb:hover,
.pos-cart-panel ::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Print Invoice Styling (Thermal & A4) */
@media print {
    body * {
        visibility: hidden;
    }
    #printable-receipt, #printable-receipt * {
        visibility: visible;
    }
    #printable-receipt {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0;
    }
    .no-print {
        display: none !important;
    }
}

.thermal-80mm {
    width: 79mm;
    margin: 0 auto;
    font-size: 11px;
    line-height: 1.35;
    font-family: "Courier New", Courier, monospace;
    color: #000;
}

/* Tables */
.cp-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.cp-table th {
    background: #f8fafc;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--cp-border);
}

.cp-table td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.875rem;
}

.cp-table tbody tr:hover td {
    background: #f8fafc;
}

/* Mobile Table & Panel Responsiveness */
@media (max-width: 991.98px) {
    .cp-card:has(.cp-table),
    .cp-table-container,
    .table-responsive-mobile {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .cp-table th, 
    .cp-table td {
        padding: 0.65rem 0.75rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* Modals on Mobile Phones */
    .modal-dialog {
        margin: 0.5rem auto;
        max-width: calc(100% - 1rem);
    }

    .modal-body {
        max-height: calc(85vh - 120px);
        overflow-y: auto;
    }

    /* Touch-friendly forms & inputs */
    .form-control, .form-select {
        font-size: 0.95rem;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
}
