/*
 * Premium POS & Inventory System custom CSS design system
 */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --font-family: 'Outfit', sans-serif;
    --border-radius: 12px;
    --transition-speed: 0.3s;
    
    /* Light Theme (Default) */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-rgb: 79, 70, 229;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --border-color: #e2e8f0;
    --sidebar-bg: #1e1b4b;
    --sidebar-text: #e2e8f0;
    --sidebar-active: #4f46e5;
    --card-shadow: 0 4px 20px -2px rgba(148, 163, 184, 0.12), 0 2px 8px -1px rgba(148, 163, 184, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.5);
}

[data-bs-theme="dark"] {
    /* Dark Theme overrides */
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-rgb: 99, 102, 241;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --border-color: #1f2937;
    --sidebar-bg: #0f172a;
    --sidebar-text: #f3f4f6;
    --sidebar-active: #6366f1;
    --card-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.3), 0 4px 12px -2px rgba(0, 0, 0, 0.2);
    --glass-bg: rgba(17, 24, 39, 0.75);
    --glass-border: rgba(31, 41, 55, 0.5);
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color var(--transition-speed), color var(--transition-speed);
    overflow-x: hidden;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    opacity: 0.3;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

.glass-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.glass-card:hover {
    box-shadow: 0 12px 30px -4px rgba(148, 163, 184, 0.18);
}

/* Sidebar Styling */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    width: 250px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    transition: all var(--transition-speed) ease-in-out;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

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

.sidebar .brand img {
    height: 40px;
    width: auto;
    margin-right: 10px;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0.8rem;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}

.sidebar-menu li {
    margin-bottom: 0.4rem;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 0.8rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    opacity: 0.85;
    transition: all var(--transition-speed);
}

.sidebar-menu a i {
    width: 1.5rem;
    margin-right: 0.8rem;
    font-size: 1.1rem;
}

.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.08);
    opacity: 1;
    transform: translateX(4px);
}

.sidebar-menu li.active a {
    background-color: var(--sidebar-active);
    color: #ffffff;
    opacity: 1;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* Main Layout Setup */
.main-wrapper {
    margin-left: 250px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: all var(--transition-speed) ease-in-out;
}

.top-navbar {
    height: 70px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    position: sticky;
    top: 0;
    z-index: 90;
}

.content-body {
    padding: 2rem;
    flex-grow: 1;
}

/* Auth Login Page Specifics */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f46e5 0%, #1e1b4b 100%);
    position: relative;
    overflow: hidden;
}

.auth-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.15);
    top: -200px;
    right: -200px;
    z-index: 1;
}

.auth-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.1);
    bottom: -150px;
    left: -150px;
    z-index: 1;
}

.auth-card {
    position: relative;
    z-index: 10;
    max-width: 450px;
    width: 100%;
    padding: 3rem 2.5rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(20px);
}

[data-bs-theme="dark"] .auth-card {
    background: rgba(17, 24, 39, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* POS Screen Split-Pane Layout */
.pos-wrapper {
    display: grid;
    grid-template-columns: 3fr 2fr;
    height: calc(100vh - 70px);
    overflow: hidden;
}

.pos-products-pane {
    background-color: var(--bg-primary);
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.pos-cart-pane {
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.pos-cart-items {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
}

.pos-cart-totals {
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    background: var(--bg-primary);
}

.product-grid-card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.product-grid-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--card-shadow);
}

.product-grid-card img {
    height: 140px;
    width: 100%;
    object-fit: cover;
    border-bottom: 1px solid var(--border-color);
}

.product-grid-card .prod-body {
    padding: 0.8rem;
}

/* Micro-animations */
.hover-scale {
    transition: transform var(--transition-speed) ease;
}
.hover-scale:hover {
    transform: scale(1.03);
}

.pulse-alert {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Stat KPI Cards */
.stat-card {
    border-radius: var(--border-radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
}

.stat-card .icon-box {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background-color: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

/* Table Style Overrides */
.table {
    vertical-align: middle;
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
}

/* Print Invoice styles */
@media print {
    body * {
        visibility: hidden;
    }
    .print-receipt, .print-receipt * {
        visibility: visible;
    }
    .print-receipt {
        position: absolute;
        left: 0;
        top: 0;
        width: 80mm; /* standard POS receipt width */
        font-size: 12px;
        color: #000;
        padding: 5px;
    }
    .no-print {
        display: none !important;
    }
}

/* Responsive sidebar collapsed for smaller viewports */
@media (max-width: 991.98px) {
    .sidebar {
        left: -250px;
    }
    .sidebar.open {
        left: 0;
    }
    .main-wrapper {
        margin-left: 0;
    }
    .pos-wrapper {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }
    .pos-cart-pane {
        border-left: none;
        border-top: 1px solid var(--border-color);
        height: auto;
    }
}

/* ============================================================
   POS FULL-SCREEN MODE
   When $page_body_class = 'pos-fullscreen-mode', the sidebar
   and top-navbar are hidden, and the POS takes 100vh.
   ============================================================ */

body.pos-fullscreen-mode {
    overflow: hidden;
}

/* Remove sidebar margin — sidebar is not rendered */
body.pos-fullscreen-mode .main-wrapper {
    margin-left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Content body gets no padding in POS mode */
body.pos-fullscreen-mode .content-body.pos-fullscreen-content {
    padding: 0;
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Full-screen outer wrapper */
.pos-fullscreen-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-primary);
}

/* ---- POS Custom Top Bar ---- */
.pos-topbar {
    height: 54px;
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    z-index: 50;
    flex-shrink: 0;
}

/* ---- POS clock text ---- */
.pos-clock {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    gap: 0.4rem;
}

/* ---- POS split-pane body (fills remaining height under topbar) ---- */
.pos-body-split {
    display: grid;
    grid-template-columns: 3fr 2fr;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}

/* Products pane */
.pos-body-split .pos-products-pane {
    background-color: var(--bg-primary);
    padding: 1.25rem 1.25rem 0 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Product grid gets a small bottom padding so last row breathes */
.pos-body-split .pos-products-pane #posProductGrid {
    padding-bottom: 1rem;
}

/* Cart pane */
.pos-body-split .pos-cart-pane {
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Cart items list — scrollable middle section */
.pos-body-split .pos-cart-items {
    flex: 1 1 0;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    min-height: 0;
}

/* Totals box — fixed at bottom of cart pane */
.pos-body-split .pos-cart-totals {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    background: var(--bg-primary);
    flex-shrink: 0;
}

/* Responsive: stack vertically on small screens */
@media (max-width: 991.98px) {
    .pos-body-split {
        grid-template-columns: 1fr;
        overflow-y: auto;
        height: auto;
    }
    body.pos-fullscreen-mode .pos-fullscreen-wrapper {
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
    }
    .pos-body-split .pos-products-pane {
        height: auto;
        overflow-y: visible;
    }
    .pos-body-split .pos-cart-pane {
        border-left: none;
        border-top: 1px solid var(--border-color);
        height: auto;
        overflow-y: visible;
    }
    .pos-body-split .pos-cart-items {
        max-height: 350px;
    }
}

/* ============================================================
   PREMIUM CART ITEM CARDS
   ============================================================ */

/* ---- Slide-in animation ---- */
@keyframes cartItemSlideIn {
    from {
        opacity: 0;
        transform: translateX(16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ---- Cart item card ---- */
.cart-item-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 3px solid hsl(var(--item-hue, 230deg), 70%, 55%);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    animation: cartItemSlideIn 0.22s ease both;
    transition: box-shadow 0.2s, transform 0.15s;
    position: relative;
    overflow: hidden;
}

.cart-item-card:last-child {
    margin-bottom: 0;
}

.cart-item-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

/* Subtle shimmer gradient on hover */
.cart-item-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, hsla(var(--item-hue, 230deg), 70%, 55%, 0.05) 0%, transparent 60%);
    pointer-events: none;
    border-radius: inherit;
}

/* ---- Item index badge ---- */
.cart-item-index {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: hsl(var(--item-hue, 230deg), 70%, 55%);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 2px 6px hsla(var(--item-hue, 230deg), 70%, 55%, 0.35);
}

/* ---- Product info block ---- */
.cart-item-info {
    flex: 1 1 0;
    min-width: 0;
}

.cart-item-name {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin-bottom: 3px;
}

.cart-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cart-barcode-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1px 7px;
    font-family: monospace;
    letter-spacing: 0.03em;
}

.cart-unit-price {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ---- Actions block (stepper + total + remove) ---- */
.cart-item-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- Quantity stepper ---- */
.cart-qty-stepper {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    height: 30px;
    background: var(--bg-primary);
}

.cart-qty-btn {
    width: 26px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.cart-qty-btn:hover {
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary);
}

.cart-qty-input {
    width: 38px;
    height: 30px;
    border: none;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    padding: 0;
    -moz-appearance: textfield;
    outline: none;
}

.cart-qty-input::-webkit-outer-spin-button,
.cart-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cart-qty-input:focus {
    background: rgba(var(--primary-rgb), 0.05);
}

/* ---- Line total ---- */
.cart-line-total {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 62px;
    text-align: right;
    letter-spacing: -0.02em;
}

/* ---- Remove button ---- */
.cart-remove-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    border-radius: 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: background 0.15s, transform 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.cart-remove-btn:hover {
    background: #ef4444;
    color: #fff;
    transform: scale(1.1);
}

/* ---- Empty cart state ---- */
.cart-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 0.5rem;
    height: 100%;
    min-height: 180px;
    user-select: none;
}

.cart-empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(var(--primary-rgb), 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--primary);
    opacity: 0.6;
    margin-bottom: 0.5rem;
    animation: emptyPulse 3s ease-in-out infinite;
}

@keyframes emptyPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50%       { transform: scale(1.07); opacity: 0.85; }
}

.cart-empty-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    opacity: 0.7;
}

.cart-empty-sub {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-align: center;
}
