/* ═══════════════════════════════════════════════
   InventoryPro — CSS Variables & Theme
   ═══════════════════════════════════════════════ */
:root {
    --primary:      #1e3a5f;
    --primary-light:#2c5282;
    --secondary:    #38b2ac;
    --accent:       #ed8936;
    --sidebar-bg:   #1a202c;
    --sidebar-hover:#2d3748;
    --sidebar-text: #a0aec0;
    --sidebar-active:#4299e1;
    --card-bg:      #ffffff;
    --bg:           #f0f4f8;
    --text:         #2d3748;
    --text-muted:   #718096;
    --border:       #e2e8f0;
    --success:      #38a169;
    --danger:       #e53e3e;
    --warning:      #d69e2e;
    --info:         #3182ce;
    --shadow:       0 1px 3px rgba(0,0,0,.08);
    --sidebar-width:250px;
    --topbar-height:56px;
}

/* ═══════════════════════════════════════════════
   Base
   ═══════════════════════════════════════════════ */
html { font-size:14px; height:100%; }
@media(min-width:768px){ html{ font-size:15px; } }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
}

/* ═══════════════════════════════════════════════
   Sidebar
   ═══════════════════════════════════════════════ */
.ip-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow-y: auto;
    z-index: 1040;
    transition: transform .25s ease;
    display: flex;
    flex-direction: column;
}

.ip-sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    background: rgba(0,0,0,.15);
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    gap: .5rem;
    flex-shrink: 0;
    text-decoration: none;
}
.ip-sidebar-brand:hover { color:#fff; text-decoration:none; }
.ip-sidebar-brand i { font-size: 1.35rem; color: var(--secondary); }

.ip-sidebar-nav { flex:1; padding: .5rem 0; }

.ip-nav-section {
    padding: .65rem 1rem .25rem;
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #4a5568;
}

.ip-nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .875rem;
    border-left: 3px solid transparent;
    transition: all .15s ease;
}
.ip-nav-link i { font-size: 1.1rem; width: 1.25rem; text-align: center; }
.ip-nav-link:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
    border-left-color: var(--sidebar-hover);
}
.ip-nav-link.active {
    background: rgba(66,153,225,.12);
    color: var(--sidebar-active);
    border-left-color: var(--sidebar-active);
    font-weight: 600;
}

.ip-sidebar-footer {
    padding: .75rem 1rem;
    font-size: .7rem;
    color: #4a5568;
    border-top: 1px solid #2d3748;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════
   Main content wrapper
   ═══════════════════════════════════════════════ */
.ip-main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .25s ease;
}

/* ═══════════════════════════════════════════════
   Top navbar
   ═══════════════════════════════════════════════ */
.ip-topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    gap: .75rem;
}

.ip-topbar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.35rem;
    color: var(--text);
    cursor: pointer;
    padding: .25rem;
}

.ip-tenant-logo {
    width: 32px;
    height: 32px;
    border-radius: .375rem;
    object-fit: cover;
    background: var(--border);
}

.ip-tenant-name {
    font-weight: 600;
    font-size: .9rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.ip-topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.ip-notif-btn {
    position: relative;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: .3rem;
}
.ip-notif-btn:hover { color: var(--text); }
.ip-notif-badge {
    position: absolute;
    top: 0; right: -2px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--danger);
}

.ip-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
}

/* ═══════════════════════════════════════════════
   Breadcrumb bar
   ═══════════════════════════════════════════════ */
.ip-breadcrumb-bar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: .5rem 1.25rem;
}
.ip-breadcrumb-bar .breadcrumb {
    margin: 0;
    font-size: .8rem;
}
.ip-breadcrumb-bar .breadcrumb-item a { color: var(--primary); text-decoration: none; }
.ip-breadcrumb-bar .breadcrumb-item.active { color: var(--text-muted); }

/* ═══════════════════════════════════════════════
   Page content
   ═══════════════════════════════════════════════ */
.ip-content {
    flex: 1;
    padding: 1.25rem;
}

/* ═══════════════════════════════════════════════
   Footer
   ═══════════════════════════════════════════════ */
.ip-footer {
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--border);
    font-size: .75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
}

/* ═══════════════════════════════════════════════
   Card & table styling
   ═══════════════════════════════════════════════ */
.card {
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: .5rem;
    background: var(--card-bg);
}
.card-header {
    background: var(--card-bg);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
}

.stat-card {
    border-left: 4px solid var(--primary);
    transition: transform .15s ease;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .stat-icon  { font-size: 2rem; color: var(--primary); }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }

.table th {
    background: #edf2f7;
    font-weight: 600;
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .05em;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════ */
.btn-ip-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-ip-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
    color: #fff;
}

/* ═══════════════════════════════════════════════
   Auth pages (login/register — no sidebar)
   ═══════════════════════════════════════════════ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    border-radius: .75rem;
    box-shadow: 0 10px 40px rgba(0,0,0,.15);
}

/* ═══════════════════════════════════════════════
   Focus ring
   ═══════════════════════════════════════════════ */
.btn:focus, .btn:active:focus, .form-control:focus, .form-check-input:focus, .form-select:focus {
    box-shadow: 0 0 0 .1rem white, 0 0 0 .25rem var(--secondary);
}

/* ═══════════════════════════════════════════════
   Mobile: sidebar overlay (< 992px base)
   ═══════════════════════════════════════════════ */
@media (max-width: 991.98px) {
    .ip-sidebar {
        transform: translateX(-100%);
    }
    .ip-sidebar.show {
        transform: translateX(0);
    }
    .ip-main {
        margin-left: 0;
    }
    .ip-topbar-toggle {
        display: block;
    }
    .ip-sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.4);
        z-index: 1035;
    }
    .ip-sidebar-backdrop.show {
        display: block;
    }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE v2 — 320 / 576 / 768 / 1024 / 1280+
   ═══════════════════════════════════════════════ */

/* Font: 14px < 768px, 15px 768–1279px (already set above), 16px ≥ 1280px */
@media (min-width: 1280px) { html { font-size: 16px; } }

/* ── Sidebar: icon-only (always visible) at 768–991px ─────────── */
@media (min-width: 768px) and (max-width: 991.98px) {
    :root { --sidebar-width: 64px; }
    /* Keep sidebar always visible, cancel the base translate-X(-100%) */
    .ip-sidebar           { transform: translateX(0) !important; }
    .ip-main              { margin-left: var(--sidebar-width); }
    .ip-topbar-toggle     { display: none !important; }
    .ip-sidebar-backdrop  { display: none !important; }

    /* font-size:0 hides text nodes; override explicit sizes for icons */
    .ip-nav-link {
        font-size: 0;
        justify-content: center;
        padding: .65rem 0;
        border-left: 3px solid transparent;
    }
    .ip-nav-link.active { border-left-color: var(--sidebar-active); }
    .ip-nav-link i       { font-size: 1.25rem; width: auto; }
    .ip-nav-section {
        height: 1px;
        padding: 0;
        margin: .4rem .5rem;
        background: #2d3748;
        overflow: hidden;
        font-size: 0;
    }
    .ip-sidebar-footer   { display: none; }
    .ip-sidebar-brand    { justify-content: center; font-size: 0; padding: 0; }
    .ip-sidebar-brand i  { font-size: 1.4rem; }
}

/* ── Content padding on very small screens ───────────────────── */
@media (max-width: 575.98px) {
    .ip-content         { padding: .625rem .75rem; }
    .ip-breadcrumb-bar  { padding: .375rem .75rem; }
    .ip-topbar          { padding: 0 .75rem; gap: .4rem; }
    .ip-tenant-name     { max-width: 110px; font-size: .8rem; }
}

/* ── Touch targets: 44 px min on mobile ──────────────────────── */
@media (max-width: 767.98px) {
    a.btn:not(.btn-link),
    button.btn:not(.btn-link)   { min-height: 44px; }
    .btn-sm:not(.btn-link)      { min-height: 40px; }
    .form-control,
    .form-select                { min-height: 44px; font-size: 1rem !important; }
    .form-control-sm,
    .form-select-sm             { min-height: 40px; }
    .page-link {
        min-height: 40px; min-width: 40px;
        display: flex; align-items: center; justify-content: center;
    }
    /* Relax for compact table action buttons */
    .btn-group .btn, .btn-group .btn-sm,
    .table .btn, .table .btn-sm { min-height: 36px; min-width: 36px; }
}

/* ── Page header: stack on narrow mobile ─────────────────────── */
@media (max-width: 575.98px) {
    .d-flex.justify-content-between.align-items-center.mb-4,
    .d-flex.justify-content-between.align-items-center.mb-3 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: .625rem;
    }
}

/* ── Nav pills: horizontal scroll on mobile ──────────────────── */
@media (max-width: 575.98px) {
    .nav-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: .25rem;
        gap: .25rem;
    }
    .nav-pills .nav-item { flex-shrink: 0; }
    .nav-pills .nav-link { white-space: nowrap; }
}

/* ── Table: webkit momentum scroll ──────────────────────────── */
.table-responsive { -webkit-overflow-scrolling: touch; }

/* ── Priority-column helpers (apply to <th>/<td>) ───────────── */
@media (max-width: 575.98px) { .col-hide-xs { display: none !important; } }
@media (max-width: 767.98px) { .col-hide-sm { display: none !important; } }

/* ── SaleBills list — hide low-priority columns ──────────────
   Col order: 1=BillNo 2=Date 3=Customer 4=Items 5=NetAmt
              6=Paid 7=Balance 8=Mode 9=Status 10=Actions      */
@media (max-width: 767.98px) {
    #saleBillsTable th:nth-child(4), #saleBillsTable td:nth-child(4),
    #saleBillsTable th:nth-child(6), #saleBillsTable td:nth-child(6),
    #saleBillsTable th:nth-child(8), #saleBillsTable td:nth-child(8) {
        display: none;
    }
}
@media (max-width: 575.98px) {
    #saleBillsTable th:nth-child(2), #saleBillsTable td:nth-child(2),
    #saleBillsTable th:nth-child(7), #saleBillsTable td:nth-child(7) {
        display: none;
    }
}

/* ── CounterSales list — hide low-priority columns ───────────
   Col order: 1=BillNo 2=Date 3=Customer 4=Phone
              5=Mode 6=Payment 7=NetAmt 8=Status 9=Actions     */
@media (max-width: 767.98px) {
    #counterSalesTable th:nth-child(4), #counterSalesTable td:nth-child(4),
    #counterSalesTable th:nth-child(5), #counterSalesTable td:nth-child(5),
    #counterSalesTable th:nth-child(6), #counterSalesTable td:nth-child(6) {
        display: none;
    }
}
@media (max-width: 575.98px) {
    #counterSalesTable th:nth-child(2), #counterSalesTable td:nth-child(2) {
        display: none;
    }
}

/* ── Bill entry: item table → card grid on mobile ───────────── */
@media (max-width: 767.98px) {
    .bill-item-table thead           { display: none !important; }
    .bill-item-table tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: .2rem .5rem;
        border: 1px solid var(--border);
        border-radius: .5rem;
        padding: .5rem;
        margin-bottom: .625rem;
        background: #fff;
    }
    .bill-item-table tbody td {
        border: none !important;
        padding: .2rem .25rem;
        font-size: .875rem;
        vertical-align: middle;
    }
    .bill-item-table tbody td::before {
        content: attr(data-label) ": ";
        font-size: .7rem;
        font-weight: 700;
        text-transform: uppercase;
        color: var(--text-muted);
        display: block;
        margin-bottom: .1rem;
    }
    .bill-item-table tbody td.td-num  { display: none; }
    .bill-item-table tbody td.td-item {
        grid-column: 1 / -1;
    }
    .bill-item-table tbody td.td-item::before { display: none; }
    .bill-item-table tbody td.td-amt {
        grid-column: 1 / -1;
        font-weight: 700;
        color: var(--primary);
        border-top: 1px solid var(--border) !important;
        padding-top: .35rem !important;
    }
    .bill-item-table tbody td.td-del {
        grid-column: 1 / -1;
        text-align: right;
    }
    .bill-item-table tbody td.td-del::before { display: none; }
}

/* ── POS keypad modal (bottom sheet) ─────────────────────────── */
.modal-bottom .modal-dialog {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    margin: 0;
    max-width: 100%;
}
.modal-bottom .modal-content {
    border-radius: 1.25rem 1.25rem 0 0;
    border: none;
    box-shadow: 0 -4px 24px rgba(0,0,0,.15);
}
.modal-bottom.fade .modal-dialog  { transform: translateY(100%); transition: transform .3s ease-out; }
.modal-bottom.show .modal-dialog  { transform: translateY(0); }
.kp-btn {
    height: 60px;
    font-size: 1.4rem;
    font-weight: 600;
    border-radius: .5rem;
    width: 100%;
}

/* ═══════════════════════════════════════════════
   Spinner Overlay
   ═══════════════════════════════════════════════ */
#ipLoadingOverlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.78);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: .875rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
    backdrop-filter: blur(2px);
}
#ipLoadingOverlay.show {
    opacity: 1;
    pointer-events: all;
}
.ip-loading-spinner {
    width: 48px; height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: ip-spin .65s linear infinite;
}
@keyframes ip-spin { to { transform: rotate(360deg); } }
.ip-loading-text {
    color: var(--text-muted);
    font-size: .875rem;
    font-weight: 500;
}

/* ═══════════════════════════════════════════════
   Skeleton Loaders
   ═══════════════════════════════════════════════ */
.skeleton-row { pointer-events: none; }
.skeleton-row td { padding: .6rem .75rem !important; }
.skeleton-cell {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(
        90deg,
        #e2e8f0 25%,
        #f0f4f8 50%,
        #e2e8f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
.skeleton-row td:first-child .skeleton-cell { max-width: 90px; }
.skeleton-row td:last-child  .skeleton-cell { max-width: 80px; margin-left: auto; }
@keyframes skeleton-shimmer {
    0%   { background-position:  200% 0; }
    100% { background-position: -200% 0; }
}
