/*
 * Supermarket POS — application styles.
 *
 * Plain CSS3 layered on top of the locally hosted Bootstrap 5 build. There is
 * no build step: this file is served straight from /public.
 */

:root {
    --pos-sidebar-width: 232px;
    --pos-topbar-height: 56px;
    --pos-surface: #ffffff;
    --pos-canvas: #f4f6f9;
    --pos-border: #dfe3e8;
    --pos-ink: #1f2933;
    --pos-muted: #62727f;
    --pos-accent: #1b7f4f;
    --pos-accent-dark: #14603b;
    --pos-danger: #b32d2e;
    --pos-warning: #9a6400;
}

body {
    background-color: var(--pos-canvas);
    color: var(--pos-ink);
    font-size: 0.94rem;
}

/* ---------------------------------------------------------------- Shell -- */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--pos-sidebar-width);
    flex: 0 0 var(--pos-sidebar-width);
    background: #12201a;
    color: #d7e3dc;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.app-sidebar .brand {
    display: block;
    padding: 1rem 1.1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.app-sidebar .brand small {
    display: block;
    font-weight: 400;
    font-size: 0.72rem;
    color: #8fae9d;
}

.app-sidebar .nav-section {
    padding: 0.85rem 1.1rem 0.3rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #7d9c8b;
}

.app-sidebar a.nav-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.48rem 1.1rem;
    color: #cfe0d6;
    text-decoration: none;
    font-size: 0.88rem;
    border-left: 3px solid transparent;
}

.app-sidebar a.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.app-sidebar a.nav-item.active {
    background: rgba(27, 127, 79, 0.22);
    border-left-color: var(--pos-accent);
    color: #fff;
    font-weight: 600;
}

.app-sidebar .nav-badge {
    margin-left: auto;
    font-size: 0.7rem;
    background: var(--pos-danger);
    color: #fff;
    border-radius: 999px;
    padding: 0 0.4rem;
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    height: var(--pos-topbar-height);
    background: var(--pos-surface);
    border-bottom: 1px solid var(--pos-border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-content {
    padding: 1.1rem;
    flex: 1 1 auto;
}

.page-title {
    font-size: 1.28rem;
    font-weight: 600;
    margin: 0;
}

.page-subtitle {
    color: var(--pos-muted);
    font-size: 0.84rem;
    margin: 0;
}

/* ---------------------------------------------------------------- Cards -- */

.card {
    border: 1px solid var(--pos-border);
    border-radius: 0.5rem;
    box-shadow: none;
}

.card-header {
    background: #fbfcfd;
    border-bottom: 1px solid var(--pos-border);
    font-weight: 600;
    font-size: 0.9rem;
}

.stat-card .stat-label {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--pos-muted);
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.stat-card .stat-hint {
    font-size: 0.78rem;
    color: var(--pos-muted);
}

/* --------------------------------------------------------------- Tables -- */

.table-compact th,
.table-compact td {
    padding: 0.45rem 0.6rem;
    vertical-align: middle;
}

.table thead th {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--pos-muted);
    border-bottom-width: 1px;
    white-space: nowrap;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.table-scroll {
    overflow-x: auto;
}

/* Status is never conveyed by colour alone: every badge carries a glyph. */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 0.3rem;
}

.status-badge .status-glyph {
    font-size: 0.8em;
}

/* ------------------------------------------------------------------ POS -- */

.pos-body {
    background: #0f1a15;
}

.pos-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 0.75rem;
    height: calc(100vh - var(--pos-topbar-height));
    padding: 0.75rem;
}

.pos-panel {
    background: var(--pos-surface);
    border-radius: 0.6rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.pos-scan-bar {
    padding: 0.75rem;
    border-bottom: 1px solid var(--pos-border);
    background: #f7f9fa;
}

#barcode-input {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    height: 3rem;
}

.pos-results {
    overflow-y: auto;
    flex: 1 1 auto;
    padding: 0.6rem;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 0.55rem;
}

.product-tile {
    border: 1px solid var(--pos-border);
    border-radius: 0.45rem;
    padding: 0.55rem;
    background: #fff;
    text-align: left;
    cursor: pointer;
    min-height: 96px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.product-tile:hover,
.product-tile:focus-visible {
    border-color: var(--pos-accent);
    box-shadow: 0 0 0 2px rgba(27, 127, 79, 0.16);
    outline: none;
}

.product-tile[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.product-tile .tile-name {
    font-weight: 600;
    font-size: 0.86rem;
    line-height: 1.25;
}

.product-tile .tile-meta {
    font-size: 0.72rem;
    color: var(--pos-muted);
}

.product-tile .tile-price {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.cart-lines {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
}

.cart-line {
    border-bottom: 1px solid var(--pos-border);
    padding: 0.5rem 0.65rem;
}

.cart-line.is-selected {
    background: #eaf5ef;
    box-shadow: inset 3px 0 0 var(--pos-accent);
}

.cart-line .line-name {
    font-weight: 600;
    font-size: 0.88rem;
}

.cart-line .line-meta {
    font-size: 0.72rem;
    color: var(--pos-muted);
}

.qty-control {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
}

.qty-control button {
    width: 2rem;
    height: 2rem;
    line-height: 1;
    font-weight: 700;
    padding: 0;
}

.qty-control input {
    width: 5rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.pos-totals {
    border-top: 2px solid var(--pos-border);
    background: #f7f9fa;
    padding: 0.65rem 0.75rem;
}

.pos-totals .total-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.86rem;
    padding: 0.1rem 0;
}

.pos-totals .grand {
    font-size: 1.45rem;
    font-weight: 800;
    border-top: 1px solid var(--pos-border);
    margin-top: 0.35rem;
    padding-top: 0.35rem;
}

.pos-actions .btn {
    font-weight: 600;
    min-height: 3rem;
}

.btn-pay {
    min-height: 3.5rem;
    font-size: 1.1rem;
    font-weight: 700;
}

.kbd {
    display: inline-block;
    border: 1px solid #b9c2c9;
    border-bottom-width: 2px;
    border-radius: 0.25rem;
    padding: 0 0.32rem;
    font-size: 0.7rem;
    font-family: inherit;
    background: #fff;
    color: var(--pos-muted);
}

.pos-toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 2050;
    max-width: 380px;
}

/* Touchscreen terminals: bigger hit targets. */
@media (pointer: coarse) {
    .qty-control button {
        width: 2.6rem;
        height: 2.6rem;
    }

    .product-tile {
        min-height: 112px;
    }
}

@media (max-width: 1200px) {
    .pos-layout {
        grid-template-columns: minmax(0, 1fr) 360px;
    }
}

@media (max-width: 991px) {
    .app-sidebar {
        position: fixed;
        left: -100%;
        z-index: 1040;
        transition: left 0.18s ease;
    }

    .app-sidebar.is-open {
        left: 0;
    }

    .pos-layout {
        grid-template-columns: minmax(0, 1fr);
        height: auto;
    }

    .pos-panel {
        max-height: 70vh;
    }
}

/* -------------------------------------------------------------- Receipt -- */

.receipt {
    width: 302px;
    margin: 0 auto;
    background: #fff;
    padding: 12px 14px;
    font-family: "DejaVu Sans Mono", "Courier New", monospace;
    font-size: 12px;
    line-height: 1.35;
    color: #000;
}

.receipt .receipt-store {
    text-align: center;
    margin-bottom: 6px;
}

.receipt .receipt-store .store-name {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.receipt table {
    width: 100%;
    border-collapse: collapse;
}

.receipt td,
.receipt th {
    padding: 1px 0;
    vertical-align: top;
}

.receipt .rule {
    border-top: 1px dashed #000;
    margin: 5px 0;
}

.receipt .right {
    text-align: right;
}

.receipt .receipt-total {
    font-size: 14px;
    font-weight: 700;
}

.receipt .receipt-footer {
    text-align: center;
    margin-top: 8px;
    font-size: 11px;
}

.receipt .reprint-mark {
    text-align: center;
    font-weight: 700;
    border: 1px solid #000;
    margin-bottom: 6px;
    padding: 2px;
}

@media print {
    .no-print,
    .app-sidebar,
    .app-topbar {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .receipt {
        width: auto;
        margin: 0;
        padding: 0;
    }

    @page {
        margin: 4mm;
    }
}

/* ---------------------------------------------------------------- Utils -- */

.filter-bar {
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: 0.5rem;
    padding: 0.7rem;
    margin-bottom: 0.9rem;
}

.empty-state {
    text-align: center;
    padding: 2.4rem 1rem;
    color: var(--pos-muted);
}

.empty-state .empty-title {
    font-weight: 600;
    color: var(--pos-ink);
}

.text-tabular {
    font-variant-numeric: tabular-nums;
}

.line-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 110px;
}

.line-chart .bar {
    flex: 1 1 auto;
    background: var(--pos-accent);
    border-radius: 2px 2px 0 0;
    min-height: 2px;
}

.line-chart .bar:hover {
    background: var(--pos-accent-dark);
}

.required::after {
    content: " *";
    color: var(--pos-danger);
}

/* ----------------------------------------------------------------- Auth -- */

/*
 * Sign-in, password reset and password-choice screens share one split shell:
 * a branded panel that sets context for staff, and a working column that
 * keeps the form at a comfortable reading width on any till or tablet.
 */

.auth-shell {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    min-height: 100vh;
}

.auth-brand {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    overflow: hidden;
    padding: 3rem 3.25rem;
    color: #dcebe2;
    background:
        radial-gradient(115% 85% at 14% 10%, rgba(27, 127, 79, 0.5) 0%, rgba(27, 127, 79, 0) 62%),
        linear-gradient(155deg, #10201a 0%, #14603b 62%, #1b7f4f 100%);
}

/* Faint till-receipt grid, faded out towards the edges. */
.auth-brand::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 46px 46px;
    -webkit-mask-image: radial-gradient(75% 65% at 32% 32%, #000 0%, transparent 80%);
    mask-image: radial-gradient(75% 65% at 32% 32%, #000 0%, transparent 80%);
}

.auth-brand-inner {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 430px;
}

.auth-brand-mark {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.auth-brand-mark img {
    border-radius: 0.8rem;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18), 0 10px 24px rgba(0, 0, 0, 0.3);
}

.auth-brand-name {
    display: block;
    font-size: 1.12rem;
    font-weight: 600;
    color: #fff;
}

.auth-brand-tag {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.11em;
    color: rgba(220, 235, 226, 0.72);
}

.auth-brand-lede {
    margin: 2.1rem 0 0;
    max-width: 20ch;
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.32;
    color: #fff;
}

.auth-feature-list {
    list-style: none;
    margin: 1.9rem 0 0;
    padding: 0;
    display: grid;
    gap: 1.05rem;
}

.auth-feature-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
}

.auth-feature-ico {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.55rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
}

.auth-feature-title {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
}

.auth-feature-text {
    display: block;
    font-size: 0.82rem;
    line-height: 1.45;
    color: rgba(220, 235, 226, 0.78);
}

.auth-brand-foot {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 2.3rem 0 0;
    font-size: 0.76rem;
    color: rgba(220, 235, 226, 0.62);
}

/* ------------------------------------------------------- Auth: form pane -- */

.auth-pane {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
}

.auth-panel {
    width: 100%;
    max-width: 400px;
}

.auth-heading {
    margin: 0 0 0.3rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.auth-sub {
    margin: 0 0 1.3rem;
    font-size: 0.88rem;
    color: var(--pos-muted);
}

.auth-card {
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 16px 34px -22px rgba(16, 24, 40, 0.45);
}

.auth-note {
    margin: 1.1rem 0 0;
    text-align: center;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--pos-muted);
}

.auth-link {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--pos-accent-dark);
    text-decoration: none;
}

.auth-link:hover,
.auth-link:focus-visible {
    color: var(--pos-accent-dark);
    text-decoration: underline;
}

/* --------------------------------------------------- Auth: form controls -- */

.auth-card .form-label {
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--pos-ink);
}

.auth-card .form-control {
    height: 46px;
    border-radius: 0.5rem;
    border-color: var(--pos-border);
    font-size: 0.95rem;
}

.auth-card .form-control:focus {
    border-color: var(--pos-accent);
    box-shadow: 0 0 0 3px rgba(27, 127, 79, 0.16);
}

.auth-card .form-control.is-invalid {
    border-color: var(--pos-danger);
    background-image: none;
    padding-right: 0.75rem;
}

.auth-card .form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(179, 45, 46, 0.16);
}

.field-row {
    margin-bottom: 1rem;
}

/* Input with a leading glyph, and optionally a trailing button. */
.input-affix {
    position: relative;
    display: block;
}

.input-affix-icon {
    position: absolute;
    top: 50%;
    left: 0.8rem;
    display: flex;
    transform: translateY(-50%);
    color: var(--pos-muted);
    pointer-events: none;
}

.input-affix .form-control {
    padding-left: 2.5rem;
}

.input-affix.has-action .form-control,
.input-affix.has-action .form-control.is-invalid {
    padding-right: 2.9rem;
}

.input-action {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
    padding: 0;
    border: 0;
    border-radius: 0.4rem;
    background: transparent;
    color: var(--pos-muted);
}

.input-action:hover {
    background: #eef1f4;
    color: var(--pos-ink);
}

.input-action:focus-visible {
    outline: 2px solid var(--pos-accent);
    outline-offset: 1px;
}

.input-action .icon-hide {
    display: none;
}

.input-action.is-revealed .icon-show {
    display: none;
}

.input-action.is-revealed .icon-hide {
    display: block;
}

.field-error {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--pos-danger);
}

.caps-hint {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0.4rem 0 0;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--pos-warning);
}

.auth-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0.1rem 0 1.2rem;
}

.auth-options .form-check {
    margin: 0;
    min-height: auto;
}

.auth-options .form-check-input {
    width: 1.05rem;
    height: 1.05rem;
    margin-top: 0.14rem;
    border-color: #c3cad2;
}

.auth-options .form-check-input:checked {
    background-color: var(--pos-accent);
    border-color: var(--pos-accent);
}

.auth-options .form-check-input:focus {
    border-color: var(--pos-accent);
    box-shadow: 0 0 0 3px rgba(27, 127, 79, 0.16);
}

.auth-options .form-check-label {
    font-size: 0.85rem;
    color: var(--pos-ink);
    cursor: pointer;
}

.auth-card .btn-success {
    --bs-btn-bg: var(--pos-accent);
    --bs-btn-border-color: var(--pos-accent);
    --bs-btn-hover-bg: var(--pos-accent-dark);
    --bs-btn-hover-border-color: var(--pos-accent-dark);
    --bs-btn-active-bg: var(--pos-accent-dark);
    --bs-btn-active-border-color: var(--pos-accent-dark);
    --bs-btn-disabled-bg: var(--pos-accent);
    --bs-btn-disabled-border-color: var(--pos-accent);
}

.btn-auth {
    height: 46px;
    border-radius: 0.5rem;
    font-weight: 600;
}

.auth-help {
    margin: 1.15rem 0 0;
    padding-top: 1.05rem;
    border-top: 1px solid var(--pos-border);
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--pos-muted);
}

/* ------------------------------------------------------ Auth: responsive -- */

@media (max-width: 991.98px) {
    .auth-shell {
        grid-template-columns: 1fr;
        min-height: 100vh;
    }

    .auth-brand {
        padding: 1.15rem 1.25rem;
        justify-content: flex-start;
    }

    .auth-brand-inner {
        max-width: none;
    }

    .auth-brand-lede,
    .auth-feature-list,
    .auth-brand-foot {
        display: none;
    }

    .auth-pane {
        align-items: flex-start;
        padding: 1.75rem 1rem 2.5rem;
    }

    .auth-card {
        padding: 1.25rem;
    }
}
