/* ------------------------------------------------------------------
   Multi-store POS — application styles

   Bootstrap 5 does the heavy lifting. This file does three things:
     1. defines the colour tokens (one place to re-tune the whole system)
     2. re-points Bootstrap's own variables at those tokens
     3. lays out the shell, the KPI tiles and the till screen

   Colour rules followed here:
     - chrome is deep slate, the single accent is teal
     - green and red are reserved for money and stock state, never decoration
     - every text colour clears 4.5:1 on the surface it sits on
   ------------------------------------------------------------------ */

:root {
    /* -- surfaces ------------------------------------------------- */
    --pos-page:        #f5f7f9;
    --pos-surface:     #ffffff;
    --pos-surface-2:   #fafbfc;   /* table headers, footers */
    --pos-border:      #e3e8ed;
    --pos-border-soft: #eef1f5;

    /* -- chrome --------------------------------------------------- */
    --pos-chrome:      #16283a;   /* top bar, 15:1 against white text */
    --pos-chrome-2:    #0f1d2b;   /* deeper step for the sign-in screen */

    /* -- accent (teal) -------------------------------------------- */
    --pos-accent:       #0d7c77;  /* 5.0:1 on white — safe for link text */
    --pos-accent-hover: #0a6b66;
    --pos-accent-ink:   #095f5b;  /* small text on a tinted background */
    --pos-accent-wash:  #e8f4f3;  /* active nav row, hovered result row */
    --pos-accent-rgb:   13, 124, 119;

    /* -- ink ------------------------------------------------------ */
    --pos-ink:        #16202e;    /* headings, figures */
    --pos-ink-body:   #2c3846;    /* body copy */
    --pos-ink-muted:  #5a6675;    /* labels, captions — 5.9:1, still legible */
    --pos-ink-faint:  #77828f;    /* decorative only, never load-bearing text */

    /* -- money & state -------------------------------------------- */
    --pos-good:     #0f6b45;
    --pos-warn:     #8a5a00;
    --pos-bad:      #b02a30;

    --pos-sidebar-width: 250px;
    --pos-radius: 0.6rem;

    /* -- Bootstrap re-points -------------------------------------- */
    --bs-primary:        #0d7c77;
    --bs-primary-rgb:    13, 124, 119;
    --bs-link-color:     #0d7c77;
    --bs-link-color-rgb: 13, 124, 119;
    --bs-link-hover-color: #0a6b66;
    --bs-body-color:     #2c3846;
    --bs-body-bg:        #f5f7f9;
    --bs-border-color:   #e3e8ed;
    --bs-emphasis-color: #16202e;
}

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

h1, h2, h3, h4, h5, h6, .kpi-value, .cart-total {
    color: var(--pos-ink);
}

/* Bootstrap's .text-muted is too light for small print at this size. */
.text-muted, .form-text {
    color: var(--pos-ink-muted) !important;
}

/* ------------------- Bootstrap component re-points ---------------- */
.btn-primary {
    --bs-btn-bg: var(--pos-accent);
    --bs-btn-border-color: var(--pos-accent);
    --bs-btn-hover-bg: var(--pos-accent-hover);
    --bs-btn-hover-border-color: var(--pos-accent-hover);
    --bs-btn-active-bg: var(--pos-accent-ink);
    --bs-btn-active-border-color: var(--pos-accent-ink);
    --bs-btn-disabled-bg: var(--pos-accent);
    --bs-btn-disabled-border-color: var(--pos-accent);
    --bs-btn-focus-shadow-rgb: var(--pos-accent-rgb);
}

.btn-outline-primary {
    --bs-btn-color: var(--pos-accent);
    --bs-btn-border-color: var(--pos-accent);
    --bs-btn-hover-bg: var(--pos-accent);
    --bs-btn-hover-border-color: var(--pos-accent);
    --bs-btn-active-bg: var(--pos-accent-hover);
    --bs-btn-active-border-color: var(--pos-accent-hover);
    --bs-btn-focus-shadow-rgb: var(--pos-accent-rgb);
}

/* "Apply"/"Print" buttons used .btn-dark; align them with the chrome. */
.btn-dark {
    --bs-btn-bg: var(--pos-chrome);
    --bs-btn-border-color: var(--pos-chrome);
    --bs-btn-hover-bg: var(--pos-chrome-2);
    --bs-btn-hover-border-color: var(--pos-chrome-2);
    --bs-btn-active-bg: var(--pos-chrome-2);
    --bs-btn-active-border-color: var(--pos-chrome-2);
}

.btn-outline-secondary {
    --bs-btn-color: var(--pos-ink-muted);
    --bs-btn-border-color: var(--pos-border);
    --bs-btn-hover-bg: var(--pos-surface-2);
    --bs-btn-hover-border-color: #cfd8df;
    --bs-btn-hover-color: var(--pos-ink);
    --bs-btn-active-bg: #eef1f5;
    --bs-btn-active-border-color: #cfd8df;
    --bs-btn-active-color: var(--pos-ink);
}

.form-control:focus,
.form-select:focus {
    border-color: #7fbdb9;
    box-shadow: 0 0 0 0.2rem rgba(var(--pos-accent-rgb), 0.15);
}

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

.form-check-input:focus {
    border-color: #7fbdb9;
    box-shadow: 0 0 0 0.2rem rgba(var(--pos-accent-rgb), 0.15);
}

a { text-decoration-thickness: 1px; text-underline-offset: 0.15em; }

/* Money and stock state. These four are reserved — nothing decorative
   may use green or red, so a colour on a figure always means something. */
.text-success, .text-success-emphasis { color: var(--pos-good) !important; }
.text-danger,  .text-danger-emphasis  { color: var(--pos-bad)  !important; }
.text-warning, .text-warning-emphasis { color: var(--pos-warn) !important; }

/* ---------------------------- Top bar --------------------------- */
.app-topbar {
    background: var(--pos-chrome);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 1px 3px rgba(16, 32, 46, 0.18);
}

.app-topbar .navbar-brand,
.app-topbar .btn-outline-light {
    color: #fff;
}

.app-topbar .navbar-brand { letter-spacing: 0.01em; }

.app-topbar .btn-outline-light {
    border-color: rgba(255, 255, 255, 0.28);
}

.app-topbar .btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.45);
    color: #fff;
}

.app-topbar .shop-switcher {
    min-width: 210px;
    background-color: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.24);
    color: #fff;
}

/* The dropdown list itself renders on white, so its options need dark text. */
.app-topbar .shop-switcher option { color: var(--pos-ink); }

.notification-menu {
    width: 340px;
    max-height: 26rem;
    overflow-y: auto;
}

.notification-item {
    border-bottom: 1px solid var(--pos-border-soft);
    padding-block: 0.45rem;
}

.notification-item:last-child {
    border-bottom: 0;
}

/* ---------------------------- Shell ----------------------------- */
.app-shell {
    display: flex;
    align-items: flex-start;
    min-height: calc(100vh - 56px);
}

.app-sidebar {
    width: var(--pos-sidebar-width);
    flex: 0 0 var(--pos-sidebar-width);
    background: var(--pos-surface);
    border-right: 1px solid var(--pos-border);
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
}

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

.app-main > .app-content { flex: 1 0 auto; }

@media (max-width: 991.98px) {
    .app-main { padding: 1rem; }
}

/* ---------------------------- Footer ---------------------------- */
.app-footer {
    flex-shrink: 0;
    margin-top: 2.5rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--pos-border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--pos-ink-muted);
}

.app-footer .footer-brand {
    color: var(--pos-ink-muted);
    text-decoration: none;
    font-weight: 600;
}

.app-footer .footer-brand:hover { color: var(--pos-accent); }

.app-footer .footer-mark {
    display: inline-grid;
    place-items: center;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 0.25rem;
    background: var(--pos-accent);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    margin-right: 0.35rem;
    vertical-align: -0.15em;
    letter-spacing: 0;
}

/* --------------------------- Sidebar nav ------------------------- */
.app-nav .app-nav-heading {
    font-size: 0.68rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--pos-ink-faint);
    padding: 0.9rem 1rem 0.3rem;
    font-weight: 600;
}

.app-nav .nav-link {
    color: var(--pos-ink-body);
    padding: 0.5rem 1rem;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
}

.app-nav .nav-link i {
    width: 1.1rem;
    text-align: center;
    color: var(--pos-ink-faint);
}

.app-nav .nav-link:hover {
    background: var(--pos-surface-2);
    color: var(--pos-accent);
}

.app-nav .nav-link:hover i { color: var(--pos-accent); }

.app-nav .nav-link.active {
    background: var(--pos-accent-wash);
    border-left-color: var(--pos-accent);
    color: var(--pos-accent-ink);
    font-weight: 600;
}

.app-nav .nav-link.active i { color: var(--pos-accent); }

/* ---------------------------- KPI tiles ------------------------- */
.kpi-tile {
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: var(--pos-radius);
    padding: 0.95rem 1.05rem;
    height: 100%;
}

.kpi-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--pos-ink-muted);
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.kpi-value {
    font-size: 1.42rem;
    font-weight: 650;
    line-height: 1.15;
    color: var(--pos-ink);
}

.kpi-sub { font-size: 0.78rem; color: var(--pos-ink-muted); }
.kpi-delta.up   { color: var(--pos-good); font-weight: 600; }
.kpi-delta.down { color: var(--pos-bad);  font-weight: 600; }
.kpi-delta.flat { color: var(--pos-ink-muted); }

/* ----------------------------- Cards ---------------------------- */
.card {
    border: 1px solid var(--pos-border);
    border-radius: var(--pos-radius);
    background: var(--pos-surface);
}

.card-header {
    background: var(--pos-surface);
    border-bottom: 1px solid var(--pos-border-soft);
    font-weight: 600;
    font-size: 0.92rem;
    padding: 0.7rem 1rem;
    color: var(--pos-ink);
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.page-head h1 {
    font-size: 1.35rem;
    font-weight: 650;
    margin: 0;
}

.page-head .subtitle { font-size: 0.83rem; color: var(--pos-ink-muted); }

/* ----------------------------- Tables --------------------------- */
.table {
    font-size: 0.875rem;
    margin-bottom: 0;
    --bs-table-hover-bg: var(--pos-surface-2);
}

.table > thead > tr > th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--pos-ink-muted);
    font-weight: 650;
    white-space: nowrap;
    background: var(--pos-surface-2);
    border-bottom-color: var(--pos-border);
}

.table > tbody > tr > td { border-bottom-color: var(--pos-border-soft); }

.table-sticky thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

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

.table tfoot td {
    font-weight: 650;
    background: var(--pos-surface-2);
    color: var(--pos-ink);
}

/* -------------------------- Till screen ------------------------- */
.pos-grid {
    display: grid;
    /* The cart needs real width: item names must not wrap one word per line. */
    grid-template-columns: minmax(0, 1fr) minmax(420px, 0.8fr);
    gap: 1rem;
    align-items: start;
}

@media (min-width: 1600px) {
    .pos-grid { grid-template-columns: minmax(0, 1fr) minmax(480px, 0.7fr); }
}

@media (max-width: 1199.98px) {
    .pos-grid { grid-template-columns: 1fr; }
}

.pos-search input {
    font-size: 1.05rem;
    padding: 0.65rem 0.85rem;
}

.pos-results {
    max-height: 58vh;
    overflow-y: auto;
}

.pos-product {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
    border: 0;
    border-bottom: 1px solid var(--pos-border-soft);
    background: var(--pos-surface);
    padding: 0.55rem 0.8rem;
    cursor: pointer;
}

.pos-product:hover, .pos-product:focus {
    background: var(--pos-accent-wash);
    color: var(--pos-accent-ink);
}

.pos-product.out-of-stock { opacity: 0.55; }

.cart-table th:first-child,
.cart-table td:first-child {
    min-width: 11rem;
}

.cart-table input {
    width: 4.75rem;
    text-align: right;
    padding: 0.2rem 0.4rem;
    font-size: 0.85rem;
}

/* Hide the browser's number spinners — they steal width and nobody taps them. */
.cart-table input[type="number"]::-webkit-outer-spin-button,
.cart-table input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cart-table input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.cart-total {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--pos-ink);
}

.line-row .btn-remove {
    border: 0;
    background: transparent;
    color: var(--pos-bad);
    padding: 0 0.25rem;
}

/* --------------------------- Auth screen ------------------------ */
.auth-body {
    background:
        radial-gradient(ellipse at 50% -10%, rgba(13, 124, 119, 0.35), transparent 60%),
        var(--pos-chrome-2);
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.auth-wrap { width: 100%; max-width: 25rem; }

.auth-card {
    background: var(--pos-surface);
    border-radius: 0.9rem;
    padding: 1.75rem;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
}

.auth-logo {
    width: 3rem; height: 3rem;
    border-radius: 0.75rem;
    background: var(--pos-accent);
    color: #fff;
    display: grid; place-items: center;
    font-size: 1.4rem;
    margin: 0 auto 0.85rem;
}

/* --------------------------- Utilities -------------------------- */
.chart-box { position: relative; height: 280px; }
.chart-box-sm { position: relative; height: 210px; }

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

.stat-inline {
    display: flex; flex-wrap: wrap; gap: 1.5rem;
}

.stat-inline > div > span {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--pos-ink-muted);
    font-weight: 600;
}

.stat-inline > div > strong { font-size: 1.05rem; color: var(--pos-ink); }

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

.empty-state i { font-size: 1.75rem; display: block; margin-bottom: 0.5rem; color: var(--pos-ink-faint); }

/* Long staff names must not push the top-bar controls off a phone screen. */
@media (max-width: 575.98px) {
    .app-topbar .dropdown-toggle {
        max-width: 8.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-topbar .navbar-brand {
        font-size: 0.95rem;
        max-width: 11rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-footer { justify-content: center; text-align: center; }
}

/* Nothing in the shell belongs on paper. */
@media print {
    .app-topbar, .app-sidebar, .app-footer, .offcanvas { display: none !important; }
    .app-main { padding: 0; }
    body { background: #fff; }
}
