:root {
    --sidebar-width: 260px;
}

body { background: #f4f6f9; }

.auth-body { background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 100%); }

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

#page-content { margin-left: var(--sidebar-width); min-height: 100vh; width: calc(100% - var(--sidebar-width)); }

.sidebar .nav-link { border-radius: 6px; margin-bottom: 2px; padding: 0.5rem 0.75rem; }
.sidebar .nav-link:hover { background: rgba(255,255,255,0.1); }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1035;
}

body.sidebar-open .sidebar-backdrop { display: block; }
body.sidebar-open { overflow: hidden; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    #page-content { margin-left: 0; width: 100%; }
    main.container-fluid { padding: 1rem !important; }
}

@media (max-width: 575.98px) {
    main.container-fluid { padding: 0.75rem !important; }
    h4 { font-size: 1.15rem; }
    .table { font-size: 0.875rem; }
    .btn-group.flex-wrap .btn { flex: 1 1 auto; }
}

/* ── POS ── */
body.pos-page main.container-fluid {
    padding-bottom: 5.5rem;
}

@media (min-width: 992px) {
    body.pos-page main.container-fluid {
        padding-bottom: 1.5rem;
    }
}

.pos-container {
    min-height: calc(100vh - 120px);
}

.pos-products {
    overflow-y: auto;
    max-height: min(50vh, 320px);
}

.pos-cart {
    overflow-y: auto;
    max-height: min(55vh, 420px);
}

@media (min-width: 992px) {
    .pos-cart {
        max-height: calc(100vh - 340px);
    }
    .pos-products {
        max-height: min(40vh, 280px);
    }
}

.pos-cart-item:last-child {
    border-bottom: none !important;
}

.pos-qty-group .form-control {
    min-width: 3rem;
    max-width: none;
    flex: 1 1 auto;
    font-weight: 600;
    font-size: 1rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.pos-qty-group .btn {
    min-width: 2.25rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    font-size: 1.1rem;
    line-height: 1;
}

.pos-disc-group .form-select {
    min-width: 3.5rem;
    max-width: 4.5rem;
    flex: 0 0 auto;
    padding-left: 0.35rem;
    padding-right: 1.5rem;
}

.pos-discount-input .form-select {
    min-width: 3.5rem;
    max-width: 5rem;
    flex: 0 0 auto;
}

.pos-pay-methods {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
}

.pos-pay-methods .btn-check + .btn {
    width: 100%;
    margin: 0;
    border-radius: 0.375rem !important;
    padding: 0.45rem 0.25rem;
    font-size: 0.8rem;
}

@media (min-width: 576px) {
    .pos-pay-methods {
        grid-template-columns: repeat(5, 1fr);
    }
    .pos-pay-methods .btn-check + .btn {
        font-size: 0.875rem;
    }
}

.pos-payment-card {
    position: sticky;
    top: 1rem;
}

@media (max-width: 991.98px) {
    .pos-payment-card {
        position: static;
    }
}

.pos-mobile-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    background: #fff;
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
    padding: 0.75rem 1rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}

.pos-customer-results {
    max-height: 200px;
    overflow-y: auto;
}

.search-result-item { cursor: pointer; transition: background 0.15s; }
.search-result-item:hover,
.search-result-item:active { background: #e9ecef; }

.min-w-0 { min-width: 0; }

@media (min-width: 1200px) {
    .pos-layout > .col-xl-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .pos-layout > .col-xl-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
}

/* ── Global tables mobile ── */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767.98px) {
    .table-responsive table {
        min-width: 560px;
    }
    .card-body .row.g-3 > [class*="col-"] {
        margin-bottom: 0.25rem;
    }
    .d-flex.flex-wrap.gap-2 .btn,
    .d-flex.gap-2 .btn {
        flex: 1 1 auto;
    }
}

/* ── Stats / misc ── */
.low-stock { background-color: #fff3cd !important; }
.critical-stock { background-color: #f8d7da !important; }

.stat-card.success { border-left-color: #198754; }
.stat-card.warning { border-left-color: #ffc107; }
.stat-card.danger { border-left-color: #dc3545; }

.table th a { text-decoration: none; color: inherit; }
.table th a:hover { color: #0d6efd; }

.loading-overlay {
    position: fixed; inset: 0; background: rgba(255,255,255,0.7);
    display: none; align-items: center; justify-content: center; z-index: 9999;
}
.loading-overlay.show { display: flex; }

/* Forms touch targets */
@media (max-width: 991.98px) {
    .form-control,
    .form-select,
    .btn {
        min-height: 44px;
    }
    .form-control-sm,
    .btn-sm {
        min-height: 38px;
    }
    .input-group-sm > .form-control,
    .input-group-sm > .form-select,
    .input-group-sm > .btn {
        min-height: 38px;
    }
    .pos-qty-group .form-control,
    .pos-qty-group .btn {
        min-height: 44px;
    }
}
