/* RetailPOS — app shell styles (Bootstrap 5.3 base). Brand colour comes from
   tenant settings via --rpos-primary on <html>; nothing customer-specific here. */

:root {
    --rpos-primary: #4f46e5;
    --rpos-sidebar-w: 264px;
    --rpos-topbar-h: 60px;
    --rpos-radius: 14px;
    --rpos-sidebar-bg: #0f172a;
    --rpos-sidebar-fg: #cbd5e1;
    --rpos-sidebar-muted: #64748b;
    --bs-primary: var(--rpos-primary);
    --bs-link-color: var(--rpos-primary);
    --bs-link-hover-color: color-mix(in srgb, var(--rpos-primary) 80%, #000);
    --bs-border-radius: 10px;
    --bs-font-sans-serif: "Inter", "Segoe UI", system-ui, -apple-system, "Noto Sans Sinhala", "Noto Sans Tamil", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Bootstrap's .d-flex etc. use !important and would otherwise override the hidden attribute */
[hidden] { display: none !important; }

[data-bs-theme="light"] body { background: #f4f6fb; }
[data-bs-theme="dark"] body { background: #0b1120; }
[data-bs-theme="dark"] { --rpos-sidebar-bg: #020617; }

.btn-primary {
    --bs-btn-bg: var(--rpos-primary);
    --bs-btn-border-color: var(--rpos-primary);
    --bs-btn-hover-bg: color-mix(in srgb, var(--rpos-primary) 85%, #000);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--rpos-primary) 85%, #000);
    --bs-btn-active-bg: color-mix(in srgb, var(--rpos-primary) 75%, #000);
    --bs-btn-active-border-color: color-mix(in srgb, var(--rpos-primary) 75%, #000);
    --bs-btn-disabled-bg: var(--rpos-primary);
    --bs-btn-disabled-border-color: var(--rpos-primary);
}
.btn-outline-primary {
    --bs-btn-color: var(--rpos-primary);
    --bs-btn-border-color: var(--rpos-primary);
    --bs-btn-hover-bg: var(--rpos-primary);
    --bs-btn-hover-border-color: var(--rpos-primary);
    --bs-btn-active-bg: var(--rpos-primary);
    --bs-btn-active-border-color: var(--rpos-primary);
    --bs-btn-disabled-color: var(--rpos-primary);
    --bs-btn-disabled-border-color: var(--rpos-primary);
}
.btn-check:checked + .btn-outline-primary { color: #fff; }
.text-primary { color: var(--rpos-primary) !important; }
.text-bg-primary { background-color: var(--rpos-primary) !important; color: #fff !important; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: color-mix(in srgb, var(--rpos-primary) 60%, #fff);
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--rpos-primary) 22%, transparent);
}
.form-check-input:checked { background-color: var(--rpos-primary); border-color: var(--rpos-primary); }

.card { border: 0; border-radius: var(--rpos-radius); box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .04); }
[data-bs-theme="dark"] .card { background: #111827; box-shadow: none; }

/* ------------------------------------------------------------- shell layout */
.rpos-shell { min-height: 100vh; }

.rpos-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--rpos-sidebar-w);
    background: var(--rpos-sidebar-bg); color: var(--rpos-sidebar-fg);
    display: flex; flex-direction: column; z-index: 1040;
    transition: transform .25s ease;
    padding-bottom: env(safe-area-inset-bottom);
}
.rpos-brand {
    display: flex; align-items: center; gap: .75rem; height: var(--rpos-topbar-h);
    padding: 0 1.25rem; color: #fff; text-decoration: none; font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.rpos-brand:hover { color: #fff; }
.rpos-brand-logo { width: 34px; height: 34px; object-fit: contain; border-radius: 8px; background: rgba(255, 255, 255, .08); }
.rpos-brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rpos-nav { flex: 1; overflow-y: auto; padding: .75rem .75rem 1rem; }
.rpos-nav-heading {
    display: flex; align-items: center; gap: .75rem; padding: 1rem .75rem .35rem;
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--rpos-sidebar-muted);
}
.rpos-nav-link {
    display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; margin: 2px 0;
    color: var(--rpos-sidebar-fg); text-decoration: none; border-radius: 10px; font-size: .94rem;
}
.rpos-nav-link i { font-size: 1.1rem; opacity: .85; }
.rpos-nav-link.sub { padding-left: 1rem; }
.rpos-nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.rpos-nav-link.active {
    background: var(--rpos-primary); color: #fff;
    box-shadow: 0 6px 18px color-mix(in srgb, var(--rpos-primary) 40%, transparent);
}
.rpos-sidebar-foot { padding: .75rem 1.25rem; color: var(--rpos-sidebar-muted) !important; }

.rpos-main { margin-left: var(--rpos-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.rpos-topbar {
    position: sticky; top: 0; z-index: 1030; height: var(--rpos-topbar-h);
    display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem;
    background: color-mix(in srgb, var(--bs-body-bg) 85%, transparent);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--bs-border-color-translucent);
}
.rpos-page-title { font-weight: 600; font-size: 1.05rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rpos-topbar-actions { display: flex; align-items: center; gap: .35rem; }
.btn-icon { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; font-size: 1.15rem; }
.btn-icon:hover { background: var(--bs-tertiary-bg); }
.rpos-user-btn { display: flex; align-items: center; gap: .5rem; border-radius: 999px; padding: .25rem .75rem .25rem .25rem; }
.rpos-avatar {
    width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: var(--rpos-primary); color: #fff; font-weight: 600; font-size: .9rem;
}
.rpos-content { padding: 1.5rem; flex: 1; outline: none; }
.rpos-content:focus-visible { outline: none; }

.rpos-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 23, .5); z-index: 1035; }

.rpos-progress {
    position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 2000;
    background: var(--rpos-primary); box-shadow: 0 0 8px var(--rpos-primary);
}
.rpos-progress.run { animation: rpos-progress 1.2s ease-out forwards; }
@keyframes rpos-progress { from { width: 0; } to { width: 85%; } }

@media (max-width: 991.98px) {
    .rpos-sidebar { transform: translateX(-100%); }
    .rpos-sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
    .rpos-main { margin-left: 0; }
    .rpos-content { padding: 1rem; }
    .rpos-topbar { padding: 0 .75rem; }
}

/* ------------------------------------------------------------- components */
.rpos-hero {
    position: relative; overflow: hidden; border-radius: var(--rpos-radius); padding: 1.75rem;
    color: #fff; display: flex; align-items: center; justify-content: space-between;
    background: linear-gradient(135deg, var(--rpos-primary), color-mix(in srgb, var(--rpos-primary) 55%, #0f172a));
}
.rpos-hero-icon { font-size: 4rem; opacity: .25; }
.rpos-stat .card-body { padding: 1.25rem; }
.rpos-stat-icon {
    width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--rpos-primary) 12%, transparent); color: var(--rpos-primary);
    font-size: 1.25rem; margin-bottom: .75rem;
}
.rpos-stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.rpos-stat-label { color: var(--bs-secondary-color); font-size: .88rem; }
.rpos-steps li { margin-bottom: .4rem; }

.rpos-icon-circle {
    width: 64px; height: 64px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.8rem; color: var(--rpos-primary); background: color-mix(in srgb, var(--rpos-primary) 12%, transparent);
}
.rpos-icon-circle.success { color: var(--bs-success); background: color-mix(in srgb, var(--bs-success) 12%, transparent); }
.rpos-qr { width: 200px; height: 200px; margin: 0 auto; background: #fff; border-radius: 12px; padding: 6px; }
.rpos-qr svg { width: 100%; height: 100%; }
.rpos-otp { letter-spacing: .35em; font-weight: 600; font-variant-numeric: tabular-nums; }
.rpos-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.rpos-codes code { display: block; padding: .5rem; border-radius: 8px; background: var(--bs-tertiary-bg); font-size: 1rem; user-select: all; }

.rpos-plugin { transition: box-shadow .2s ease; }
.rpos-plugin.is-enabled { box-shadow: inset 3px 0 0 var(--bs-success), 0 1px 2px rgba(15, 23, 42, .06); }
.rpos-plugin-icon {
    width: 40px; height: 40px; flex: 0 0 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--rpos-primary) 12%, transparent); color: var(--rpos-primary); font-size: 1.2rem;
}
.rpos-logo-preview { max-width: 180px; max-height: 120px; object-fit: contain; }
.rpos-sticky-actions {
    position: sticky; bottom: 0; padding: .75rem 0; display: flex; justify-content: flex-end;
    background: linear-gradient(to top, var(--bs-body-bg) 60%, transparent);
}
[data-bs-theme="light"] .rpos-sticky-actions { background: linear-gradient(to top, #f4f6fb 60%, transparent); }

/* ------------------------------------------------------------- lists */
.rpos-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.rpos-filter { display: flex; flex-wrap: wrap; gap: .5rem; flex: 1 1 420px; max-width: 760px; }
.rpos-filter .input-group { flex: 1 1 240px; }
.rpos-filter .form-select { flex: 0 1 180px; }
.rpos-table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); font-weight: 600; background: transparent; }
.rpos-table td, .rpos-table th { padding: .8rem 1rem; }
.rpos-table .rpos-avatar { width: 34px; height: 34px; flex: 0 0 34px; }
.rpos-max-300 { max-width: 300px; }
.rpos-avatar-lg { width: 64px; height: 64px; font-size: 1.6rem; flex: 0 0 64px; }
.text-uppercase::placeholder { text-transform: none; }
.pagination { --bs-pagination-active-bg: var(--rpos-primary); --bs-pagination-active-border-color: var(--rpos-primary); --bs-pagination-color: var(--rpos-primary); }
.min-w-0 { min-width: 0; }
.rpos-perm-group .card-header { padding: .75rem 1rem; }
.rpos-sticky-card { position: sticky; top: calc(var(--rpos-topbar-h) + 1rem); }
.rpos-indent { display: inline-block; width: calc(var(--d, 0) * 1.25rem); }
.rpos-thumb {
    width: 42px; height: 42px; flex: 0 0 42px; border-radius: 10px; overflow: hidden; display: inline-flex;
    align-items: center; justify-content: center; background: var(--bs-tertiary-bg); color: var(--bs-secondary-color);
}
.rpos-thumb img { width: 100%; height: 100%; object-fit: cover; }
.rpos-product-image {
    width: 100%; aspect-ratio: 1; max-width: 260px; margin: 0 auto; border-radius: 14px; overflow: hidden;
    display: flex; align-items: center; justify-content: center; background: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color); font-size: 3rem;
}
.rpos-product-image.sm { width: 110px; max-width: 110px; font-size: 2rem; margin: 0; }
.rpos-product-image img { width: 100%; height: 100%; object-fit: cover; }
.rpos-suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 1050; max-height: 360px; overflow-y: auto; margin-top: 4px; }
@media (max-width: 1199.98px) { .rpos-sticky-card { position: static; } }
.rpos-w-50 { width: 50px; }
.rpos-w-130 { width: 130px; }
.rpos-w-180 { width: 180px; }
.rpos-progress-sm { height: 6px; }
.rpos-progress-sm .progress-bar { background: var(--rpos-primary); }
.rpos-flash { animation: rpos-flash .6s ease; }
@keyframes rpos-flash { from { background: color-mix(in srgb, var(--rpos-primary) 18%, transparent); } to { background: transparent; } }
.rpos-last-scan { padding: .5rem .75rem; border-radius: 10px; background: var(--bs-tertiary-bg); }

/* ------------------------------------------------------------- labels */
.rpos-barcode { width: 100%; height: 100%; display: block; fill: #000; }
.rpos-label-preview { display: flex; flex-wrap: wrap; gap: 8px; }
.rpos-label-preview .lbl { width: 200px; height: 110px; border: 1px dashed var(--bs-border-color); border-radius: 6px; background: #fff; color: #000; }
.lbl { box-sizing: border-box; padding: var(--lbl-pad, 2mm 3mm); display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; text-align: center; font-family: Arial, "Noto Sans Sinhala", "Noto Sans Tamil", sans-serif; }
.lbl-biz { font-size: 7pt; text-transform: uppercase; letter-spacing: .04em; }
.lbl-name { font-size: var(--lbl-name-size, 8pt); font-weight: 600; line-height: 1.1; max-height: 2.3em; overflow: hidden; width: 100%; }
.lbl-price { font-size: var(--lbl-price-size, 12pt); font-weight: 800; line-height: 1.2; }
.lbl-bc { width: 90%; height: var(--lbl-bc-h, 9mm); margin-top: 1mm; flex-shrink: 0; }
.lbl-code { font-size: var(--lbl-code-size, 7pt); font-family: "Courier New", monospace; }
/* designed templates (barcode-labels) preview at their real size */
.rpos-label-preview.lbl-real .lbl { width: var(--lbl-w); height: var(--lbl-h); border-radius: 0; }
.lbl-small .lbl-price { font-size: 10pt; }
.lbl-small .lbl-bc { height: 7mm; }
.lbl-shelf .lbl-price { font-size: 20pt; }
.lbl-shelf .lbl { border-bottom: 1px solid #000; }
.rpos-label-sheet { display: none; }
@media print {
    body.rpos-printing-labels > *:not(#rpos-label-sheet) { display: none !important; }
    body.rpos-printing-labels { background: #fff !important; margin: 0; }
    body.rpos-printing-labels .rpos-label-sheet {
        display: grid; grid-template-columns: repeat(var(--lbl-cols), var(--lbl-w)); grid-auto-rows: var(--lbl-h);
        column-gap: var(--lbl-gx, 0); row-gap: var(--lbl-gy, 0);
    }
    .rpos-label-sheet .lbl { width: var(--lbl-w); height: var(--lbl-h); break-inside: avoid; }
    .rpos-label-sheet.lbl-roll .lbl { break-after: page; }
    .rpos-label-sheet .lbl-blank { visibility: hidden; }
}
@media (max-width: 575.98px) {
    .rpos-filter .form-select { flex: 1 1 45%; }
    .rpos-toolbar > .btn, .rpos-toolbar > div > .btn { width: 100%; }
}

/* ------------------------------------------------------------- auth & installer */
.rpos-auth {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--rpos-primary) 30%, transparent), transparent 60%),
        radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--rpos-primary) 22%, transparent), transparent 60%),
        var(--bs-body-bg);
}
.rpos-auth-wrap { width: 100%; max-width: 440px; padding: 1.5rem 1rem; display: flex; flex-direction: column; align-items: center; }
.rpos-auth-wrap.wide { max-width: 760px; }
.rpos-auth-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.rpos-auth-logo { width: 44px; height: 44px; object-fit: contain; }
.rpos-auth-name { font-weight: 700; font-size: 1.25rem; }
.rpos-auth-card { width: 100%; border-radius: 20px; }
.rpos-password { position: relative; }
.rpos-reveal { position: absolute; right: .35rem; top: .55rem; z-index: 5; color: var(--bs-secondary-color); border: 0; }
.rpos-password .form-control { padding-right: 3rem; }

.rpos-wizard { display: flex; list-style: none; padding: 0; gap: .5rem; counter-reset: step; }
.rpos-wizard li {
    flex: 1; display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; border-radius: 10px;
    background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); font-weight: 500; font-size: .9rem;
}
.rpos-wizard li span {
    width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: var(--bs-secondary-bg); font-size: .8rem;
}
.rpos-wizard li b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rpos-wizard li { min-width: 0; }
.rpos-wizard li.active { background: color-mix(in srgb, var(--rpos-primary) 14%, transparent); color: var(--rpos-primary); }
.rpos-wizard li.active span, .rpos-wizard li.done span { background: var(--rpos-primary); color: #fff; }
@media (max-width: 575.98px) {
    .rpos-wizard li { flex: 0 0 auto; }
    .rpos-wizard li.active { flex: 1 1 auto; }
    .rpos-wizard li:not(.active) b { display: none; }
}

/* selectable option cards (radio) */
.rpos-choice {
    display: block; height: 100%; padding: 1rem; cursor: pointer; border-radius: 12px;
    border: 2px solid var(--bs-border-color); background: var(--bs-body-bg); color: var(--bs-body-color);
    transition: border-color .15s ease, background-color .15s ease;
}
.rpos-choice small { color: var(--bs-secondary-color); }
.rpos-choice:hover { border-color: color-mix(in srgb, var(--rpos-primary) 50%, var(--bs-border-color)); }
.btn-check:checked + .rpos-choice {
    border-color: var(--rpos-primary);
    background: color-mix(in srgb, var(--rpos-primary) 8%, var(--bs-body-bg));
}
.btn-check:checked + .rpos-choice strong { color: var(--rpos-primary); }
.btn-check:focus-visible + .rpos-choice { box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--rpos-primary) 25%, transparent); }

/* SweetAlert2 uses the brand colour */
.swal2-styled.swal2-confirm { background-color: var(--rpos-primary) !important; }
.swal2-container { z-index: 2100; }
[data-bs-theme="dark"] .swal2-popup { background: #111827; color: #e5e7eb; }

@media print {
    .rpos-sidebar, .rpos-topbar, .rpos-sticky-actions { display: none !important; }
    .rpos-main { margin: 0; }
}

/* Settings -> Email: SMTP conversation shown when a test fails */
.rpos-mail-log { white-space: pre-wrap; word-break: break-all; max-height: 240px; overflow: auto; }

/* Audit log */
.rpos-filter input[type="date"] { flex: 0 1 150px; }
.rpos-audit tbody tr { position: relative; }
.rpos-audit-summary { max-width: 380px; }
@media (max-width: 575.98px) { .rpos-filter input[type="date"] { flex: 1 1 45%; } }

/* Wording & translations */
.rpos-progress-thin { height: 6px; }
.rpos-wording td { vertical-align: top; }
.rpos-wording label { font-weight: 400; }

/* SaaS platform & subscription */
.rpos-pre-line { white-space: pre-line; }
.rpos-plan-plugins { max-height: 320px; overflow: auto; }
.rpos-notice { padding-left: 1rem; padding-right: 1rem; }
