/* ==========================================================================
   Easy Scan Systems — pastel design system
   Soft, low-contrast, minimalist. Built to be easy on the eye during long
   shifts at the till. Uses CSS logical properties so RTL (Arabic) mirrors
   automatically.
   ========================================================================== */

:root {
    /* Pastel palette */
    --blush:      #F7DDE2;
    --blush-deep: #EEBFC8;
    --sky:        #DCEBF5;
    --sky-deep:   #B9D6EA;
    --mint:       #DCEFE4;
    --mint-deep:  #AFDCC4;
    --butter:     #FBF0D9;

    /* Neutrals */
    --canvas:     #FEFBF9;
    --surface:    #FFFFFF;
    --ink:        #4A4048;
    --ink-soft:   #8B8089;
    --line:       #F0E6EA;
    --line-soft:  #F7F0F3;

    /* Semantic */
    --ok:         #5FAE86;
    --ok-bg:      #DCEFE4;
    --warn:       #C98A5A;
    --warn-bg:    #FBF0D9;
    --danger:     #C56B7B;
    --danger-bg:  #F7DDE2;

    /* Shape & depth */
    --r-sm: 10px;
    --r-md: 16px;
    --r-lg: 24px;
    --shadow-sm: 0 1px 2px rgba(74, 64, 72, 0.04), 0 2px 8px rgba(74, 64, 72, 0.04);
    --shadow-md: 0 2px 6px rgba(74, 64, 72, 0.06), 0 8px 24px rgba(74, 64, 72, 0.07);
    --shadow-lg: 0 8px 40px rgba(74, 64, 72, 0.10);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
            Arial, "Noto Sans", "Noto Sans Arabic", sans-serif;

    --sidebar-w: 232px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font);
    color: var(--ink);
    background: var(--canvas);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---- Typography helpers ---- */
.h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.h2 { font-size: 1.15rem; font-weight: 700; }
.eyebrow {
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.09em; color: var(--ink-soft);
}
.muted { color: var(--ink-soft); }
.tabular { font-variant-numeric: tabular-nums; }

/* ==========================================================================
   App shell
   ========================================================================== */
.app { display: flex; min-height: 100%; }

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-inline-end: 1px solid var(--line);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 10px 20px;
}
.brand-mark {
    width: 34px; height: 34px; border-radius: 11px;
    background: linear-gradient(135deg, var(--blush) 0%, var(--sky) 60%, var(--mint) 100%);
    display: grid; place-items: center; font-size: 18px;
    box-shadow: var(--shadow-sm);
}
.brand-name { font-weight: 700; font-size: 0.98rem; line-height: 1.15; }
.brand-name small { display: block; font-weight: 500; font-size: 0.72rem; color: var(--ink-soft); }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border-radius: var(--r-sm);
    color: var(--ink-soft); font-weight: 600; font-size: 0.92rem;
    transition: background 0.15s, color 0.15s;
    width: 100%; text-align: start;
}
.nav-item:hover { background: var(--line-soft); color: var(--ink); }
.nav-item.active { background: var(--blush); color: var(--ink); }
.nav-item .ico { width: 20px; text-align: center; font-size: 1.05rem; }

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.shop-chip { padding: 10px 12px; border-radius: var(--r-sm); background: var(--line-soft); }
.shop-chip .name { font-weight: 700; font-size: 0.85rem; }
.shop-chip .role { font-size: 0.72rem; color: var(--ink-soft); text-transform: capitalize; }

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

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 28px; gap: 16px;
}
.topbar .page-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content { padding: 4px 28px 40px; flex: 1; }

/* ---- Trial banner ---- */
.trial-banner {
    margin: 0 28px 16px; padding: 12px 16px;
    background: var(--butter); border-radius: var(--r-md);
    display: flex; align-items: center; gap: 12px; font-size: 0.9rem;
}
.trial-banner.lapsed { background: var(--danger-bg); }
.trial-banner .grow { flex: 1; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 18px; border-radius: var(--r-sm);
    font-weight: 600; font-size: 0.92rem;
    background: var(--line-soft); color: var(--ink);
    transition: transform 0.1s, background 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}
.btn:hover { background: var(--line); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #362f34; }
.btn-accent { background: var(--blush-deep); color: var(--ink); }
.btn-accent:hover { background: #e8adb8; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--line-soft); }
.btn-lg { padding: 14px 22px; font-size: 1rem; border-radius: var(--r-md); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon { padding: 10px; width: 40px; height: 40px; border-radius: var(--r-sm); }

/* ==========================================================================
   Cards, surfaces
   ========================================================================== */
.card {
    background: var(--surface); border-radius: var(--r-md);
    box-shadow: var(--shadow-sm); padding: 20px;
}
.card-pad-lg { padding: 26px; }

.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
}
.stat {
    border-radius: var(--r-md); padding: 20px; box-shadow: var(--shadow-sm);
    background: var(--surface); position: relative; overflow: hidden;
}
.stat::after {
    content: ""; position: absolute; inset-block-start: -30px; inset-inline-end: -30px;
    width: 90px; height: 90px; border-radius: 50%; opacity: 0.5;
}
.stat.sales::after   { background: var(--mint); }
.stat.expenses::after{ background: var(--blush); }
.stat.profit::after  { background: var(--sky); }
.stat.pending::after { background: var(--butter); }
.stat .label { font-size: 0.8rem; color: var(--ink-soft); font-weight: 600; position: relative; }
.stat .value { font-size: 1.7rem; font-weight: 700; margin-top: 6px; position: relative; letter-spacing: -0.02em; }

/* ==========================================================================
   Forms
   ========================================================================== */
.field { margin-bottom: 14px; }
.field label {
    display: block; font-size: 0.8rem; font-weight: 600;
    color: var(--ink-soft); margin-bottom: 6px;
}
.input, .select {
    width: 100%; padding: 12px 14px;
    background: var(--canvas); border: 1.5px solid var(--line);
    border-radius: var(--r-sm); transition: border-color 0.15s, background 0.15s;
}
.input:focus, .select:focus {
    outline: none; border-color: var(--sky-deep); background: #fff;
}
.input::placeholder { color: #bcb2b8; }

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

/* ==========================================================================
   Tables / lists
   ========================================================================== */
.list { width: 100%; border-collapse: collapse; }
.list th {
    text-align: start; font-size: 0.72rem; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--ink-soft); font-weight: 700;
    padding: 10px 14px; border-bottom: 1.5px solid var(--line);
}
.list td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); }
.list tr:last-child td { border-bottom: none; }
.list .num { text-align: end; font-variant-numeric: tabular-nums; }
.list tbody tr { transition: background 0.12s; }
.list tbody tr:hover { background: var(--line-soft); }

.pill {
    display: inline-block; padding: 3px 11px; border-radius: 999px;
    font-size: 0.72rem; font-weight: 700; text-transform: capitalize;
}
.pill.draft { background: var(--sky); color: #4a7a99; }
.pill.sent  { background: var(--blush); color: #a8556a; }
.pill.paid  { background: var(--mint); color: #3e8b63; }

/* ==========================================================================
   POS screen
   ========================================================================== */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }

.scan-box { text-align: center; padding: 26px; }
.scan-hint { color: var(--ink-soft); font-size: 0.88rem; margin-top: 4px; }
.scan-input-wrap { display: flex; gap: 10px; margin-top: 18px; }
.scan-input-wrap .input { font-size: 1.05rem; padding: 14px 16px; }

#camera-stage { margin-top: 18px; border-radius: var(--r-md); overflow: hidden; display: none; background: #000; position: relative; }
#camera-stage.on { display: block; }
#camera-stage video { width: 100%; display: block; max-height: 320px; object-fit: cover; }
.cam-reticle {
    position: absolute; inset: 50% 12% auto; transform: translateY(-50%);
    height: 2px; background: rgba(255,255,255,0.85); box-shadow: 0 0 12px rgba(255,255,255,0.7);
}

.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 18px; }
.quick-item {
    padding: 14px 12px; border-radius: var(--r-md); background: var(--surface);
    box-shadow: var(--shadow-sm); text-align: start; transition: transform 0.1s, box-shadow 0.15s;
}
.quick-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.quick-item .qn { font-weight: 700; font-size: 0.9rem; }
.quick-item .qp { color: var(--ink-soft); font-size: 0.82rem; margin-top: 2px; }

/* Cart */
.cart { position: sticky; top: 20px; }
.cart-items { max-height: 46vh; overflow-y: auto; margin: 6px -6px; }
.cart-line { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid var(--line-soft); }
.cart-line .cl-name { flex: 1; font-weight: 600; font-size: 0.9rem; }
.cart-line .cl-price { color: var(--ink-soft); font-size: 0.82rem; }
.qty-stepper { display: flex; align-items: center; gap: 8px; }
.qty-stepper button { width: 26px; height: 26px; border-radius: 8px; background: var(--line-soft); font-weight: 700; }
.qty-stepper button:hover { background: var(--line); }
.qty-stepper .q { min-width: 20px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.cl-remove { color: var(--ink-soft); font-size: 1.1rem; padding: 2px 6px; }
.cl-remove:hover { color: var(--danger); }

.cart-total-card {
    margin-top: 14px; padding: 18px; border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--blush) 0%, var(--sky) 100%);
}
.cart-total-card .tt-row { display: flex; justify-content: space-between; align-items: baseline; }
.cart-total-card .tt-label { font-weight: 600; }
.cart-total-card .tt-value { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; }
.cart-total-card.bump { animation: bump 0.3s ease; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.03); } 100% { transform: scale(1); } }

.pay-methods { display: flex; gap: 8px; margin: 14px 0; }
.pay-methods button {
    flex: 1; padding: 10px; border-radius: var(--r-sm); background: var(--surface);
    border: 1.5px solid var(--line); font-weight: 600; font-size: 0.85rem; transition: all 0.15s;
}
.pay-methods button.sel { border-color: var(--ink); background: var(--ink); color: #fff; }

.empty-cart { text-align: center; color: var(--ink-soft); padding: 40px 20px; }
.empty-cart .big { font-size: 2.4rem; opacity: 0.5; }

/* ==========================================================================
   Empty states, toasts, modal
   ========================================================================== */
.empty {
    text-align: center; padding: 60px 20px; color: var(--ink-soft);
}
.empty .big { font-size: 2.8rem; opacity: 0.45; margin-bottom: 10px; }
.empty .btn { margin-top: 16px; }

.toast-wrap { position: fixed; inset-block-end: 24px; inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 100; pointer-events: none; }
.toast {
    background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
    font-size: 0.88rem; font-weight: 600; box-shadow: var(--shadow-lg);
    animation: toast-in 0.25s ease; pointer-events: auto;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.modal-backdrop {
    position: fixed; inset: 0; background: rgba(74, 64, 72, 0.28);
    display: none; align-items: center; justify-content: center; z-index: 90; padding: 20px;
    backdrop-filter: blur(2px);
}
.modal-backdrop.on { display: flex; }
.modal {
    background: var(--surface); border-radius: var(--r-lg); padding: 26px;
    width: 100%; max-width: 440px; box-shadow: var(--shadow-lg);
    animation: modal-in 0.2s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal h3 { font-size: 1.15rem; margin-bottom: 4px; }
.modal .sub { color: var(--ink-soft); font-size: 0.88rem; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* ==========================================================================
   Auth screen
   ========================================================================== */
.auth-screen {
    min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background:
        radial-gradient(circle at 15% 20%, var(--blush) 0%, transparent 40%),
        radial-gradient(circle at 85% 15%, var(--sky) 0%, transparent 38%),
        radial-gradient(circle at 75% 85%, var(--mint) 0%, transparent 42%),
        var(--canvas);
}
.auth-card {
    background: var(--surface); border-radius: var(--r-lg); padding: 34px;
    width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.auth-brand .brand-mark { width: 40px; height: 40px; font-size: 21px; }
.auth-title { font-size: 1.35rem; font-weight: 700; margin: 18px 0 4px; }
.auth-sub { color: var(--ink-soft); font-size: 0.9rem; margin-bottom: 22px; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 0.88rem; color: var(--ink-soft); }
.auth-switch button { color: var(--ink); font-weight: 700; }
.auth-error { background: var(--danger-bg); color: #a04e5e; padding: 11px 14px; border-radius: var(--r-sm); font-size: 0.85rem; margin-bottom: 14px; }

/* Language toggle */
.lang-toggle { display: flex; background: var(--line-soft); border-radius: 999px; padding: 3px; }
.lang-toggle button { padding: 5px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); }
.lang-toggle button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ==========================================================================
   RTL adjustments (Arabic)
   ========================================================================== */
[dir="rtl"] .cam-reticle { inset-inline: 12%; }

/* ==========================================================================
   Responsive — phone/tablet first-class (this is a POS)
   ========================================================================== */
.hamburger { display: none; }
.sidebar-scrim { display: none; }

@media (max-width: 960px) {
    .pos-layout { grid-template-columns: 1fr; }
    .cart { position: static; }
}

@media (max-width: 760px) {
    .sidebar {
        position: fixed; inset-inline-start: 0; inset-block: 0; z-index: 80;
        transform: translateX(-100%); transition: transform 0.25s ease;
        box-shadow: var(--shadow-lg);
    }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-scrim.on { display: block; position: fixed; inset: 0; background: rgba(74,64,72,0.2); z-index: 70; }
    .hamburger { display: inline-flex; }
    .topbar { padding: 14px 18px; }
    .content { padding: 4px 18px 32px; }
    .trial-banner { margin: 0 18px 14px; }
    .topbar .page-title { font-size: 1.15rem; }
}


/* Support contact line — login screen and app footer. Deliberately quiet so it
   reassures without competing with the shopkeeper's actual work. */
.support-bar {
    margin-top: 18px;
    padding: 12px 16px;
    text-align: center;
    font-size: .85rem;
    color: var(--ink-soft);
    border-top: 1px solid var(--line-soft);
}
.support-bar a { color: var(--ink); }
