:root {
    --sp-sidebar-bg: #0f2b46;
    --sp-sidebar-text: #a8c2dd;
    --sp-sidebar-active: #ffffff;
    --sp-sidebar-hover: rgba(255, 255, 255, 0.08);
    --sp-topbar-bg: #ffffff;
    --sp-body-bg: #f4f6fb;
    --sp-card-bg: #ffffff;
    --sp-border: #e4e9f2;
    --sp-text: #1e293b;
    --sp-muted: #64748b;
    --sp-primary: #0d6efd;
}

[data-bs-theme="dark"] {
    --sp-sidebar-bg: #0b1a2e;
    --sp-sidebar-text: #8fa6c0;
    --sp-sidebar-active: #ffffff;
    --sp-sidebar-hover: rgba(255, 255, 255, 0.06);
    --sp-topbar-bg: #101a2b;
    --sp-body-bg: #0d1522;
    --sp-card-bg: #131e31;
    --sp-border: #243148;
    --sp-text: #dbe4f0;
    --sp-muted: #8fa0b8;
}

body {
    background: var(--sp-body-bg);
    color: var(--sp-text);
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 0.925rem;
}

/* Sidebar */
.app-wrapper { display: flex; min-height: 100vh; }
.app-sidebar {
    width: 260px;
    background: var(--sp-sidebar-bg);
    color: var(--sp-sidebar-text);
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease;
}
.app-sidebar .sidebar-brand {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 1rem 1.25rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.app-sidebar .sidebar-brand img { height: 36px; width: 36px; object-fit: contain; border-radius: 8px; }
.app-sidebar .sidebar-nav { flex: 1; overflow-y: auto; padding: 0.75rem 0.75rem 1.5rem; }
.app-sidebar .nav-group {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sp-sidebar-text);
    opacity: 0.7;
    padding: 0.9rem 0.75rem 0.35rem;
    font-weight: 600;
}
.app-sidebar .nav-link {
    color: var(--sp-sidebar-text);
    border-radius: 0.5rem;
    padding: 0.55rem 0.75rem;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.9rem;
}
.app-sidebar .nav-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; }
.app-sidebar .nav-link:hover { color: #fff; background: var(--sp-sidebar-hover); }
.app-sidebar .nav-link.active { color: var(--sp-sidebar-active); background: rgba(13, 110, 253, 0.25); font-weight: 600; }
.app-sidebar .nav-link.active i { color: #7ab3ff; }
.app-sidebar .nav-group-toggle {
    width: 100%;
    background: transparent;
    border: 0;
    text-align: left;
    cursor: pointer;
    color: var(--sp-sidebar-text);
    user-select: none;
}
.app-sidebar .nav-group-toggle:hover { color: #fff; background: var(--sp-sidebar-hover); }
.app-sidebar .nav-group-toggle .nav-chevron {
    font-size: 0.8rem;
    width: auto;
    margin-left: auto;
    transition: transform 0.2s ease;
}
.app-sidebar .nav-group-toggle[aria-expanded="true"] .nav-chevron { transform: rotate(180deg); }
.app-sidebar .nav-collapse { padding-left: 0.5rem; }
.app-sidebar .nav-collapse .nav-link { font-size: 0.85rem; padding: 0.45rem 0.75rem; }
.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1039; display: none;
}

/* Main */
.app-main { flex: 1; margin-left: 260px; display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
    background: var(--sp-topbar-bg);
    border-bottom: 1px solid var(--sp-border);
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: 1rem;
    padding: 0.65rem 1.5rem;
}
.app-topbar .topbar-title { font-weight: 600; font-size: 1.05rem; }
.app-content { padding: 1.5rem; flex: 1; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.show { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .sidebar-backdrop.show { display: block; }
}

/* Cards */
.card {
    background: var(--sp-card-bg);
    border: 1px solid var(--sp-border);
    border-radius: 0.9rem;
    box-shadow: 0 1px 2px rgba(15, 30, 60, 0.04);
}
.card .card-header { background: transparent; border-bottom: 1px solid var(--sp-border); font-weight: 600; }
.stat-card { position: relative; overflow: hidden; }
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 1.35rem;
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-card .stat-label { color: var(--sp-muted); font-size: 0.82rem; }

/* Tables */
.table { --bs-table-bg: transparent; }
.table > :not(caption) > * > * { background-color: transparent; color: var(--sp-text); }
.table-hover tbody tr:hover { background: rgba(13, 110, 253, 0.04); }
.table thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sp-muted);
    border-bottom-width: 1px;
    white-space: nowrap;
}

/* Forms */
.form-control, .form-select { background-color: var(--sp-card-bg); border-color: var(--sp-border); color: var(--sp-text); }
.form-control:focus, .form-select:focus { background-color: var(--sp-card-bg); color: var(--sp-text); }

/* Badges */
.badge { font-weight: 600; }

/* Buttons */
.btn { border-radius: 0.5rem; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* Page header */
.page-header { margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-header .breadcrumb { margin: 0; font-size: 0.8rem; }

/* POS */
.pos-wrapper {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 1rem;
    height: auto;
    min-height: calc(100vh - 130px);
}

/* Middle pane: search + product grid */
.pos-products { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.pos-toolbar { flex-shrink: 0; }
.pos-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 0.75rem;
    align-content: start;
    padding: 2px 4px 2px 2px;
}
.pos-card {
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    border: 1px solid var(--sp-border);
    display: flex;
    flex-direction: column;
    height: 100%;
}
.pos-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15, 30, 60, 0.14); }
.pos-thumb {
    position: relative;
    height: 120px;
    flex-shrink: 0;
    background: var(--sp-body-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sp-muted);
    border-bottom: 1px solid var(--sp-border);
}
.pos-thumb i { font-size: 2.4rem; opacity: 0.35; }
.pos-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pos-card-body { padding: 0.6rem 0.75rem 0.75rem; display: flex; flex-direction: column; flex: 1; }
.pos-card-body .d-flex:last-child { margin-top: auto; }
.pos-name {
    font-weight: 600;
    font-size: 0.82rem;
    line-height: 1.25;
    min-height: 2.5em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.pos-meta { font-size: 0.7rem; color: var(--sp-muted); }
.pos-price { font-weight: 700; color: var(--sp-primary); }

/* Right pane: cart */
.pos-cart { display: flex; flex-direction: column; min-height: 0; align-self: start; }
.pos-cart .card { display: flex; flex-direction: column; min-height: 0; }
.pos-cart-items { padding: 0.75rem; }
.pos-cart-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0; border-bottom: 1px solid var(--sp-border); }
.pos-cart-row:last-child { border-bottom: none; }

.pos-pagination {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0 0;
}
.pos-cart-collapsed .pos-cart-items,
.pos-cart-collapsed .card-body { display: none !important; }

@media (max-width: 1199.98px) {
    .pos-wrapper { grid-template-columns: minmax(0, 1fr) 350px; }
}
@media (max-width: 991.98px) {
    .pos-wrapper { grid-template-columns: 1fr; height: auto; }
    .pos-grid { overflow-y: visible; }
    .pos-cart { height: auto; }
}

/* Modals with a form wrapper: keep the body scrollable and the footer visible */
.modal-dialog-scrollable .modal-content > form {
    display: flex;
    flex-direction: column;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
}
.modal-dialog-scrollable .modal-content > form .modal-body {
    overflow-y: auto;
    min-height: 0;
}

/* Dark mode toggle */
.theme-toggle { cursor: pointer; width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 1px solid var(--sp-border); background: transparent; color: var(--sp-text); }

/* Notifications dropdown */
.notif-dropdown { width: 340px; max-height: 420px; overflow-y: auto; }

/* Receipt */
.receipt-container { max-width: 420px; margin: 0 auto; }
.receipt { font-family: "Courier New", monospace; background: #fff; color: #000; padding: 1.25rem; }
.receipt .r-line { display: flex; justify-content: space-between; gap: 1rem; }
.receipt .r-dashed { border-top: 1px dashed #000; margin: 0.5rem 0; }

/* Print helpers */
@media print {
    .no-print { display: none !important; }
    .app-sidebar, .app-topbar { display: none !important; }
    .app-main { margin-left: 0 !important; }
    .receipt { box-shadow: none; }
    body { background: #fff; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, 0.4); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.avatar-sm { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.text-muted-2 { color: var(--sp-muted) !important; }

.min-width-200 { min-width: 200px; }
.empty-state { padding: 3rem 1rem; text-align: center; color: var(--sp-muted); }
.empty-state i { font-size: 3rem; opacity: 0.4; display: block; margin-bottom: 0.75rem; }
