/* ============================================================================
   Elsayad Management System — web design tokens + shell.
   Palette mirrors the desktop AppColors.cs (brand red #DC262B, dark-navy sidebar,
   slate neutrals). Layout uses CSS *logical* properties (padding-inline, inset-inline,
   margin-inline-start...) so the SAME rules flip correctly for RTL (Arabic) vs LTR,
   driven only by <html dir>. No webfonts (CSP-clean; matches the desktop's Segoe UI).
   ============================================================================ */

:root {
    /* Brand — fixed in both themes */
    --brand:            #DC262B;
    --brand-dark:       #9F1216;
    --brand-hover:      #EC4046;
    --brand-grad-start: #EF444A;
    --brand-grad-end:   #9D1016;
    --brand-soft:       #FEE2E2;

    /* Sidebar / dark surfaces — fixed */
    --sidebar-top:    #181C29;
    --sidebar-bottom: #0B0E16;
    --nav-hover:  #282E3F;
    --nav-text:   #C8CEDC;
    --nav-muted:  #6E768A;

    /* Semantic — fixed */
    --success: #16A34A;
    --warning: #EA580C;
    --error:   #DC2626;
    --info:    #2563EB;

    /* Themeable neutrals — LIGHT defaults (see dark override below) */
    --bg:           #F3F4F8;
    --surface:      #FFFFFF;
    --card:         #FFFFFF;
    --border:       #E8EBF2;
    --border-strong:#D4DAE4;
    --text:         #111624;
    --text-2:       #646D80;
    --text-muted:   #97A0B2;
    --grid-alt:     #F7F9FC;
    --grid-hover:   #F3F6FB;

    /* Elevation + geometry */
    --shadow-sm: 0 1px 2px rgba(17,24,39,.06), 0 1px 3px rgba(17,24,39,.05);
    --shadow-md: 0 4px 12px rgba(17,24,39,.08), 0 2px 4px rgba(17,24,39,.04);
    --radius:    12px;
    --radius-sm: 8px;
    --sidebar-w: 244px;

    --font: "Segoe UI", system-ui, -apple-system, "Tahoma", "Cairo", sans-serif;
    color-scheme: light;
}

/* Dark applies ONLY when explicitly selected (data-theme="dark"), mirroring the desktop's
   AppSettings "DarkMode"=="1". We deliberately do NOT follow the browser's OS dark preference,
   so the web matches the desktop's FIXED theme — which defaults to light (the slate palette). */
:root[data-theme="dark"] {
    --bg:           #14161E;
    --surface:      #1E2230;
    --card:         #1E2230;
    --border:       #303648;
    --border-strong:#40485E;
    --text:         #E7EAF2;
    --text-2:       #A0A8BC;
    --text-muted:   #788094;
    --grid-alt:     #242939;
    --grid-hover:   #2B3144;
    --brand-soft:   #3C2228;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 4px 14px rgba(0,0,0,.45);
    color-scheme: dark;
}

/* ---- reset / base ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.25; text-wrap: balance; color: var(--text); }
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---- boot / loading screen (shown before Blazor starts) ---- */
.app-boot {
    position: fixed; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 14px;
    background: linear-gradient(160deg, var(--sidebar-top), var(--sidebar-bottom));
    color: #fff;
}
.app-boot__logo { font-size: 40px; font-weight: 800; letter-spacing: .5px; }
.app-boot__logo::before { content: ""; display: block; width: 46px; height: 4px; margin: 0 auto 14px; background: var(--brand); border-radius: 3px; }
.app-boot__sub { color: #AAB2C6; font-size: 15px; }
.app-boot__bar { width: 220px; height: 5px; border-radius: 3px; background: #2A3048; overflow: hidden; margin-top: 6px; }
.app-boot__bar span { display: block; width: 40%; height: 100%; border-radius: 3px;
    background: linear-gradient(90deg, var(--brand-grad-start), var(--brand-grad-end));
    animation: boot-slide 1.1s ease-in-out infinite; }
.app-boot__msg { color: #8790A6; font-size: 12.5px; margin-top: 2px; }
@keyframes boot-slide { 0% { margin-inline-start: -40%; } 100% { margin-inline-start: 100%; } }
@media (prefers-reduced-motion: reduce) { .app-boot__bar span { animation: none; width: 100%; } }

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

.shell__sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-top), var(--sidebar-bottom));
    color: var(--nav-text);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.shell__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---- topbar ---- */
.topbar {
    height: 60px; flex-shrink: 0;
    display: flex; align-items: center; gap: 14px;
    padding-inline: 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky; top: 0; z-index: 5;
}
.topbar__title { font-size: 17px; font-weight: 650; }
.topbar__spacer { flex: 1; }

.content { padding: 24px; flex: 1; }

/* ---- sidebar nav ---- */
.brand { padding: 20px 20px 14px; display: flex; align-items: center; gap: 10px; }
.brand__logo { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: .3px; }
.brand__logo b { color: var(--brand); }
.brand__sub { font-size: 11.5px; color: var(--nav-muted); margin-top: 2px; }

.nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav__item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--nav-text); font-size: 14.5px; font-weight: 500;
    cursor: pointer; border: 0; background: transparent; width: 100%;
    text-align: start; transition: background .12s ease, color .12s ease;
}
.nav__item:hover { background: var(--nav-hover); color: #fff; }
.nav__item.is-active { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(220,38,43,.35); }
.nav__item.is-disabled { opacity: .45; pointer-events: none; }
.nav__icon { width: 22px; text-align: center; font-size: 16px; }
.nav__soon { margin-inline-start: auto; font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--nav-muted); }

.sidebar__foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); display: flex; flex-direction: column; gap: 8px; }
.conn { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--nav-muted); padding-inline: 4px; }
.conn__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--nav-muted); }
.conn__dot.is-up { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,.2); }
.conn__dot.is-down { background: var(--error); box-shadow: 0 0 0 3px rgba(220,38,38,.2); }

/* ---- language toggle ---- */
.lang-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: var(--radius-sm);
    background: transparent; color: var(--nav-text);
    border: 1px solid rgba(255,255,255,.14); font-size: 13.5px; font-weight: 600;
    cursor: pointer; transition: background .12s ease;
}
.lang-toggle:hover { background: var(--nav-hover); color: #fff; }
/* topbar variant (on light surface) */
.topbar .lang-toggle { color: var(--text-2); border-color: var(--border-strong); }
.topbar .lang-toggle:hover { background: var(--grid-hover); color: var(--text); }

/* ---- generic surfaces ---- */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px;
}
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 24px; }
.page-head p { margin: 6px 0 0; color: var(--text-2); font-size: 14.5px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
        box-shadow: var(--shadow-sm); padding: 18px 20px; }
.stat__label { font-size: 12.5px; color: var(--text-2); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.stat__value { font-size: 28px; font-weight: 750; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat__note { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.stat--brand { border-inline-start: 3px solid var(--brand); }
.stat--info  { border-inline-start: 3px solid var(--info); }
.stat--ok    { border-inline-start: 3px solid var(--success); }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: var(--radius-sm);
       border: 0; font-size: 14.5px; font-weight: 600; cursor: pointer; }
.btn--primary { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(220,38,43,.28); }
.btn--primary:hover { background: var(--brand-hover); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
        font-size: 12.5px; font-weight: 600; background: var(--brand-soft); color: var(--brand-dark); }

/* ---- blazor error strip ---- */
#blazor-error-ui {
    display: none; position: fixed; inset-inline: 0; bottom: 0; z-index: 1000;
    padding: 12px 20px; background: #fff5f5; color: #7a1216;
    border-top: 1px solid #f3c2c2; box-shadow: 0 -2px 10px rgba(0,0,0,.08);
    align-items: center; gap: 16px;
}
#blazor-error-ui .reload { color: var(--brand); font-weight: 600; }
#blazor-error-ui .dismiss { cursor: pointer; margin-inline-start: auto; }

/* ---- auth: full-screen login / enrolment ---- */
/* ── Split-panel branded login (mirrors the desktop LoginForm) ─────────────────── */
.login { min-height: 100vh; display: flex; }
.login__brand {
    flex: 0 0 46%; position: relative; overflow: hidden; color: #fff; padding: 56px 52px;
    display: flex; flex-direction: column; justify-content: center;
    background: radial-gradient(120% 120% at 15% 0%, #E23A3F 0%, #DC262B 42%, #A5171B 100%);
}
.login__brand::before {   /* soft brand-panel bubbles like the desktop art */
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(280px 280px at 82% 18%, rgba(255,255,255,.10), transparent 70%),
                radial-gradient(220px 220px at 12% 88%, rgba(255,255,255,.07), transparent 70%);
    pointer-events: none;
}
.login__imha { font-size: 22px; font-weight: 700; letter-spacing: 6px; opacity: .92; }
.login__logo { font-family: "Segoe Script", "Brush Script MT", "Lucida Handwriting", cursive;
    font-size: 88px; line-height: 1.05; margin: 6px 0 10px; text-shadow: 0 4px 18px rgba(0,0,0,.25); }
.login__tag { font-size: 18px; font-weight: 600; }
.login__since { font-size: 14px; font-style: italic; opacity: .9; margin-top: 2px; }
.login__vendor { position: absolute; inset-block-end: 26px; inset-inline-start: 52px; font-size: 12px; font-weight: 600; opacity: .85; }

.login__side { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px;
    background: var(--surface); }
.login__card { width: 100%; max-width: 380px; }
.login__title { font-size: 26px; font-weight: 800; color: var(--text); margin-bottom: 26px; }
.login__hint { color: var(--text-2); font-size: 13px; line-height: 1.6; margin: 0 0 8px; }
.login__label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-2); margin: 16px 0 6px; }
.login__input {
    width: 100%; padding: 12px 13px; font-size: 15px; font-family: inherit;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--bg); color: var(--text); transition: border-color .12s ease, box-shadow .12s ease;
}
.login__input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.login__pwd { position: relative; }
.login__eye { position: absolute; inset-inline-end: 6px; inset-block-start: 50%; transform: translateY(-50%);
    border: none; background: none; cursor: pointer; font-size: 16px; padding: 4px 6px; line-height: 1; }
.login__go { width: 100%; justify-content: center; margin-top: 26px; padding: 13px; font-size: 15px; }
.login__go:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.login__lang { margin-top: 26px; }
.login__lang .lang-toggle { color: var(--text-2); border-color: var(--border-strong); }
.login__lang .lang-toggle:hover { background: var(--grid-hover); color: var(--text); }

/* Update 26.72 — two-step sign-in + forgot-password steps on the same card */
.login__code { text-align: center; letter-spacing: 10px; font-size: 22px; font-weight: 800;
    font-variant-numeric: tabular-nums; }
.login__rule { margin-top: 6px; font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.login__link { display: block; width: 100%; margin-top: 14px; padding: 6px; border: none; background: none;
    color: var(--text-2); font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.login__link:hover { color: var(--brand); text-decoration: underline; }

.auth__err { margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-sm);
    background: var(--brand-soft); color: var(--brand-dark); font-size: 13.5px; font-weight: 500; }
.auth__ok { margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-sm);
    background: rgba(22,163,74,.12); color: var(--success); font-size: 13.5px; font-weight: 600; }
.auth__warn { margin-bottom: 18px; padding: 11px 13px; border-radius: var(--radius-sm);
    background: #FFF4E5; color: #9A5B00; border: 1px solid #F3D9AE; font-size: 13px; line-height: 1.5; }

@media (max-width: 760px) { .login__brand { display: none; } }

/* ---- topbar user + logout ---- */
.topbar__user { display: flex; align-items: center; gap: 8px; }
.topbar__uname { font-size: 14px; font-weight: 600; }
.topbar__uname--link { border: none; background: none; color: inherit; font-family: inherit; cursor: pointer;
    padding: 4px 6px; border-radius: var(--radius-sm); }
.topbar__uname--link:hover { background: var(--grid-hover); color: var(--brand); }
.topbar__logout {
    width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 16px; line-height: 1;
}
.topbar__logout:hover { background: var(--brand-soft); color: var(--brand-dark); border-color: var(--brand); }
.topbar__bell {
    width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 16px; line-height: 1; margin-inline-end: 4px;
}
.topbar__bell:hover { background: var(--brand-soft); color: var(--brand-dark); border-color: var(--brand); }

/* ---- sales screen ---- */
.sales { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.scan-row { display: flex; gap: 10px; margin-bottom: 14px; }
.scan-row__input {
    flex: 1; padding: 12px 14px; font-size: 15px; font-family: inherit; color: var(--text);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
}
.scan-row__input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.hits { padding: 8px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.hit { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; text-align: start; padding: 10px 12px;
       border: 0; background: transparent; border-radius: var(--radius-sm); cursor: pointer; width: 100%; }
.hit:hover { background: var(--grid-hover); }
.hit__name { font-weight: 600; }
.hit__meta { color: var(--text-2); font-size: 13px; }
.hit__qty { color: var(--text-muted); font-size: 12.5px; grid-column: 2; text-align: end; }
.cart { padding: 0; overflow: hidden; }
.cart__empty { padding: 48px 20px; text-align: center; color: var(--text-muted); font-size: 15px; }
.cart__table { width: 100%; border-collapse: collapse; }
.cart__table th { text-align: start; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-2);
                  padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--grid-alt); }
.cart__table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cart__table th.num, .cart__table td.num { text-align: end; font-variant-numeric: tabular-nums; }
.cart__table td.strong { font-weight: 700; }
.cart__name { font-weight: 600; }
.cart__sub { color: var(--text-2); font-size: 12.5px; }
.stepper { display: inline-flex; align-items: center; gap: 10px; }
.stepper button { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border-strong);
                  background: var(--surface); color: var(--text); cursor: pointer; font-size: 15px; line-height: 1; }
.stepper button:hover { border-color: var(--brand); color: var(--brand); }
.cart__del { border: 0; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 15px; }
.cart__del:hover { color: var(--error); }
.sales__side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 84px; }
.side__label { font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--text-2); margin-bottom: 10px; }
.side__note { color: var(--text-muted); font-size: 12.5px; margin-top: 8px; }
.cust-lookup { display: flex; gap: 8px; }
.cust-chip { display: flex; align-items: center; justify-content: space-between; gap: 10px;
             padding: 10px 12px; background: var(--brand-soft); border-radius: var(--radius-sm); }
.cust-chip__name { font-weight: 700; color: var(--brand-dark); }
.cust-chip__meta { font-size: 12.5px; color: var(--brand-dark); opacity: .85; }
.cust-chip__x { border: 0; background: transparent; color: var(--brand-dark); cursor: pointer; font-size: 15px; }
.totals__row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14.5px; color: var(--text-2); }
.totals__grand { font-size: 19px; font-weight: 750; color: var(--text); border-top: 1px solid var(--border); margin-top: 6px; padding-top: 12px; }
.confirm-btn { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }
.confirm-btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.sale-done { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--success); color: #fff; font-size: 14px; font-weight: 600; }
@media (max-width: 860px) { .sales { grid-template-columns: 1fr; } .sales__side { position: static; } }

@media (max-width: 760px) {
    .shell__sidebar { width: 68px; }
    .brand__logo, .brand__sub, .nav__item span:not(.nav__icon), .nav__soon, .conn span, .lang-toggle span { display: none; }
    .content { padding: 16px; }
}

/* ── client-printed 80mm receipt (no install, no server PDF) ─────────────────── */
.sale-done__print { margin-top: 10px; width: 100%; }
.receipt-print { display: none; }                 /* on-screen: hidden; only rendered when printing */
.receipt-print .rcpt__hdr { text-align: center; }
.receipt-print .rcpt__name { font-size: 14px; font-weight: 700; }
.receipt-print .rcpt__sub { font-size: 10px; }
.receipt-print .rcpt__rule { border-block-start: 1px dashed #000; margin: 5px 0; }
.receipt-print .rcpt__meta > div,
.receipt-print .rcpt__trow,
.receipt-print .rcpt__qty { display: flex; justify-content: space-between; gap: 8px; }
.receipt-print .rcpt__qty span:last-child,
.receipt-print .rcpt__trow span:last-child { text-align: end; white-space: nowrap; }
.receipt-print .rcpt__item { font-weight: 600; margin-block-start: 3px; }
.receipt-print .rcpt__grand { font-size: 13px; font-weight: 700; margin-block-start: 3px; }
.receipt-print .rcpt__oncredit { font-weight: 700; }
.receipt-print .rcpt__foot { text-align: center; margin-block-start: 6px; }

/* ── client-printed 80mm warranty ticket (mirrors desktop TicketPrintService) ──── */
.ticket-print { display: none; }                  /* on-screen: hidden; only rendered when printing */
.ticket-print .tkt__hdr { text-align: center; }
.ticket-print .tkt__name { font-size: 14px; font-weight: 700; }
.ticket-print .tkt__sub { font-size: 10px; }
.ticket-print .tkt__title { font-size: 10px; font-weight: 700; margin-block-start: 3px; }
.ticket-print .tkt__rule { border-block-start: 1px dashed #000; margin: 5px 0; }
.ticket-print .tkt__meta > div,
.ticket-print .tkt__line { display: flex; justify-content: space-between; gap: 8px; }
.ticket-print .tkt__meta span:last-child,
.ticket-print .tkt__line span:last-child { text-align: end; }
.ticket-print .tkt__code span:last-child,
.ticket-print .tkt__status span:last-child { font-weight: 700; }
.ticket-print .tkt__issue { margin-block-start: 3px; }
.ticket-print .tkt__ticketcode { text-align: center; font-size: 15px; font-weight: 700; letter-spacing: 2px; }
.ticket-print .tkt__foot { text-align: center; font-size: 10px; margin-block-start: 4px; }

@media print {
    body * { visibility: hidden; }                /* hide the whole app… */
    .receipt-print, .receipt-print *,
    .ticket-print, .ticket-print * { visibility: visible; }   /* …show only the slip */
    .receipt-print, .ticket-print {
        display: block; position: absolute; inset-block-start: 0; inset-inline-start: 0;
        width: 72mm; padding: 3mm; color: #000; background: #fff;
        font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11px; line-height: 1.35;
    }
    @page { size: 80mm auto; margin: 0; }
}
