/* ==========================================================================
   Confectionery POS — till styles
   Built for a 15" touch screen: large targets, high contrast, no hover-only
   affordances. The palette is warm (caramel and chocolate) to suit the shop.
   ========================================================================== */

:root {
    --brand:            #B45309;
    --brand-dark:       #92400E;
    --brand-light:      #FEF3C7;
    --accent:           #16A34A;
    --danger:           #DC2626;
    --warning:          #D97706;

    --bg:               #0F172A;
    --surface:          #1E293B;
    --surface-2:        #334155;
    --surface-3:        #475569;
    --border:           #334155;

    --text:             #F1F5F9;
    --text-muted:       #94A3B8;
    --text-inverse:     #0F172A;

    --radius:           14px;
    --radius-sm:        9px;
    --touch:            64px;      /* minimum comfortable finger target */
    --gap:              12px;

    --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-size: 17px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    font-size: var(--font-size);
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

input, button, select, textarea { font-family: inherit; font-size: inherit; }

.pos-shell { height: 100vh; overflow: hidden; }

/* ------------------------------------------------------------ login screen */

.login-screen {
    /* The sign-in screen is the one moment the shop introduces itself, so it
       leaves the cool slate of the sales screen behind for the warmth of the
       product: roasted, dark, with amber light above. Surfaces are re-declared
       here rather than globally, so the cashier cards warm up with it. */
    --surface:   #241C17;
    --surface-2: #2E241D;
    --surface-3: #3E3128;
    --border:    #3A2D25;
    --text:      #F5EDE3;
    --text-muted:#A8998A;

    min-height: 100vh;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* 'safe' keeps the top reachable if the content ever outgrows the screen;
       plain centring would clip it out of scroll range. */
    justify-content: safe center;
    gap: 26px;
    padding: 40px 24px;
    color: var(--text);
    background:
        radial-gradient(ellipse 70% 45% at 50% -5%, rgba(180, 83, 9, .28), transparent 65%),
        linear-gradient(180deg, #241B15 0%, #16110D 62%, #100C09 100%);
}

.login-header {
    display: grid;
    justify-items: center;
    gap: 4px;
    text-align: center;
}

.login-header h1 {
    margin: 16px 0 2px;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.022em;
    line-height: 1.1;
    color: #FAEFDF;
}

.login-tagline {
    margin: 0 0 6px;
    font-size: 1rem;
    color: #C6AF95;
}

.login-date { margin: 2px 0 0; color: var(--text-muted); font-size: 0.95rem; }

/* Which machine this is, stated once and quietly. */
.login-terminal {
    margin: 10px 0 0;
    display: inline-block;
    padding: 4px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .03);
    color: var(--text-muted);
    font-size: 0.82rem;
}
.login-hint { color: var(--text-muted); }
.login-alt { margin-top: 8px; }
.login-alt a { color: var(--text-muted); text-decoration: underline; cursor: pointer; }
.login-screen .link-button { color: #C6AF95; }

/* The grid must be given a width. As a flex child it would otherwise shrink to
   fit its content, and auto-fit would collapse to a single column. */
.cashier-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    width: 100%;
    max-width: 900px;
    justify-content: center;
}

.cashier-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 18px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.cashier-card:hover { background: var(--surface-2); border-color: var(--surface-3); }
.cashier-card:active { transform: scale(0.97); border-color: var(--card-color); }

.cashier-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--card-color, var(--brand));
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    font-weight: 600;
    color: #fff;
    overflow: hidden;
}
.cashier-avatar img { width: 100%; height: 100%; object-fit: cover; }

.cashier-name { font-weight: 600; text-align: center; line-height: 1.25; }
.cashier-role { font-size: 0.78rem; color: var(--text-muted); text-align: center; }
.cashier-badge {
    font-size: 0.78rem;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
}

.password-form { display: grid; gap: 12px; width: 320px; }

/* ---------------------------------------------------------------- PIN pad */

.pin-panel { display: flex; flex-direction: column; align-items: center; gap: 20px; position: relative; }
.pin-back { position: absolute; top: -8px; left: -8px; }
.pin-user { text-align: center; display: grid; gap: 8px; justify-items: center; }
.pin-user h2 { margin: 0; font-size: 1.3rem; }
.pin-user p { margin: 0; color: var(--text-muted); }

.pin-dots { display: flex; gap: 14px; }
.pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--surface-3);
    transition: background 0.15s ease;
}
.pin-dot.filled { background: var(--brand); border-color: var(--brand); }

.pin-pad { display: grid; grid-template-columns: repeat(3, var(--touch)); gap: 14px; }
.pin-key {
    width: var(--touch);
    height: var(--touch);
    border-radius: 50%;
    border: none;
    background: var(--surface-2);
    color: var(--text);
    font-size: 1.4rem;
    cursor: pointer;
}
.pin-key:active { background: var(--brand); }
.pin-key-action { background: var(--surface); color: var(--text-muted); }

/* -------------------------------------------------------- sales screen grid */

.pos-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: 100vh;
}

/* -------------------------------------------------------------- cart panel */

.cart-panel {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-inline-end: 1px solid var(--border);
    overflow: hidden;
}

.cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-block-end: 1px solid var(--border);
}
.cart-user { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cart-user-name { font-weight: 600; }
.cart-terminal { font-size: 0.8rem; color: var(--text-muted); }

.cart-customer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-block-end: 1px solid var(--border);
    cursor: pointer;
    min-height: 56px;
}
.cart-customer:active { background: var(--surface-2); }
.cart-customer-empty { color: var(--text-muted); }
.cart-customer-name { display: block; font-weight: 600; }
.cart-customer-meta { display: block; font-size: 0.8rem; color: var(--text-muted); }

.cart-lines { flex: 1; overflow-y: auto; padding: 8px; }

.cart-empty { text-align: center; padding: 48px 16px; color: var(--text-muted); }
.cart-empty p { margin: 0 0 6px; font-size: 1.05rem; }
.cart-empty span { font-size: 0.85rem; }

.cart-line {
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-block-end: 6px;
    background: var(--surface-2);
    cursor: pointer;
}
.cart-line.selected { background: var(--surface-3); outline: 2px solid var(--brand); }

.cart-line-main { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.cart-line-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tabular numerals so the amounts down the cart line up digit under digit. */
.cart-line-total,
.summary-row span:last-child,
.payment-row strong,
.payment-row span:last-child,
.weight-value,
.weight-total,
.return-total strong {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    white-space: nowrap;
}
.cart-line-detail {
    display: flex;
    justify-content: space-between;
    margin-block-start: 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.cart-line-discount { color: var(--accent); }
.cart-line-actions { display: flex; gap: 6px; margin-block-start: 10px; }

.cart-summary { padding: 14px 16px; border-block-start: 1px solid var(--border); background: var(--surface); }
.summary-row { display: flex; justify-content: space-between; padding: 4px 0; color: var(--text-muted); }
.summary-discount { color: var(--accent); }
.summary-total {
    margin-block-start: 8px;
    padding-block-start: 10px;
    border-block-start: 1px solid var(--border);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
}

.cart-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-block-start: 12px; }
.btn-pay { grid-column: 1 / -1; height: var(--touch); font-size: 1.15rem; }

/* ----------------------------------------------------------- product panel */

.product-panel { display: flex; flex-direction: column; overflow: hidden; }

.product-header {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border-block-end: 1px solid var(--border);
}
.search-box { position: relative; flex: 1; }
.search-input { width: 100%; height: 52px; padding-inline: 16px 44px; font-size: 1.05rem; }
.search-clear { position: absolute; inset-inline-end: 6px; top: 8px; }
.header-actions { display: flex; gap: 8px; }

.category-strip {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    border-block-end: 1px solid var(--border);
}
.category-chip {
    flex: 0 0 auto;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}
.category-chip.active { background: var(--chip-color, var(--brand)); border-color: transparent; color: #fff; }

.product-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--gap);
    padding: 16px;
    align-content: start;
}

.product-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    text-align: start;
    transition: transform 0.1s ease;
}
.product-tile:active { transform: scale(0.97); border-color: var(--tile-color); }

.product-image { width: 100%; height: 108px; border-radius: var(--radius-sm); object-fit: cover; }
.product-image-placeholder {
    display: grid;
    place-items: center;
    background: var(--tile-color, var(--brand));
    color: #fff;
    font-size: 2rem;
    font-weight: 700;
}

.product-badge {
    position: absolute;
    top: 8px;
    inset-inline-start: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 0.7rem;
}

.product-name {
    font-weight: 600;
    font-size: 0.92rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-price { font-weight: 700; color: var(--brand-light); }
.product-price small { font-weight: 400; color: var(--text-muted); }
.product-stock { font-size: 0.75rem; color: var(--text-muted); }
.product-stock.out { color: var(--danger); }

/* ------------------------------------------------------------------ modals */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    display: grid;
    place-items: center;
    z-index: 100;
    padding: 20px;
}

.modal {
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}
.modal-payment { max-width: 560px; }
.modal-weight { max-width: 420px; }
.modal-customer { max-width: 520px; }
.modal-shift { max-width: 480px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-block-end: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }

.modal-body { padding: 16px; overflow-y: auto; display: grid; gap: 14px; }
.modal-payment .modal-body { gap: 12px; }
.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px;
    border-block-start: 1px solid var(--border);
}

/* ---------------------------------------------------------- weight dialog */

.weight-display { text-align: center; display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.weight-value { font-size: 3rem; font-weight: 700; color: var(--brand-light); }
.weight-unit { color: var(--text-muted); }
.weight-total { text-align: center; font-size: 1.4rem; font-weight: 600; }
.weight-tare { text-align: center; font-size: 0.85rem; color: var(--text-muted); margin: 0; }

.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.numpad-key {
    height: 56px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
}
.numpad-key:active { background: var(--brand); }
.numpad-action { background: var(--surface); color: var(--text-muted); }

.quick-weights, .quick-amounts { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------- customer dialog */

.customer-results { display: grid; gap: 6px; max-height: 320px; overflow-y: auto; }
.customer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: none;
    color: var(--text);
    cursor: pointer;
    text-align: start;
}
.customer-row:active { background: var(--surface-3); }
.customer-name { display: block; font-weight: 600; }
.customer-mobile { display: block; font-size: 0.82rem; color: var(--text-muted); }
.customer-meta { display: flex; gap: 8px; align-items: center; font-size: 0.82rem; color: var(--text-muted); }
.quick-create { display: grid; gap: 10px; margin-block-start: 12px; }

/* ---------------------------------------------------------- payment dialog */

.payment-summary { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 6px; }
.payment-row { display: flex; justify-content: space-between; }
.payment-remaining { font-size: 1.2rem; color: var(--brand-light); }

.payment-list { display: grid; gap: 6px; }
.payment-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

.method-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); gap: 8px; }
.method-tile {
    height: 50px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
}
.method-tile.active { background: var(--method-color); border-color: transparent; color: #fff; }

.amount-entry { display: grid; gap: 8px; }
.amount-entry label { font-size: 0.85rem; color: var(--text-muted); }
.input-amount { font-size: 1.5rem; text-align: center; height: 56px; }

/* The footer explains itself when the primary action cannot yet run, so the
   cashier is never staring at a disabled button with no reason given. */
.modal-footer-stacked { flex-direction: column; align-items: stretch; gap: 10px; }
.modal-footer-actions { display: flex; gap: 10px; justify-content: flex-end; }

.payment-hint {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-muted);
}

/* ------------------------------------------------------------ shift dialog */

.shift-summary { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 4px; }
.field-label { font-size: 0.85rem; color: var(--text-muted); }

/* ------------------------------------------------------------- common bits */

.input {
    height: 48px;
    padding-inline: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--surface-3);
    background: var(--surface-2);
    color: var(--text);
    outline: none;
    width: 100%;
}
.input:focus { border-color: var(--brand); }

/* An anchor is inline by default and carries the browser's underline, so a
   link wearing .btn came out as a stretched piece of text rather than a
   button. Setting the box and killing the underline fixes both. */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 48px;
    padding-inline: 18px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
    font-size: inherit;
    transition: filter 0.1s ease;
}
.btn:hover { color: var(--text); text-decoration: none; }
.btn:active { filter: brightness(1.2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-secondary { background: var(--surface-3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-block { width: 100%; }
.btn-lg { height: 56px; font-size: 1.1rem; }
.btn-sm { height: 38px; padding-inline: 12px; font-size: 0.85rem; }
.btn-icon { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; background: transparent; font-size: 1.2rem; }

.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 0.9rem; }
.alert-error { background: rgba(220, 38, 38, 0.15); color: #FCA5A5; }
.alert-success { background: rgba(22, 163, 74, 0.15); color: #86EFAC; }
.alert-warning { background: rgba(217, 119, 6, 0.15); color: #FCD34D; }

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 22px;
    border-radius: var(--radius);
    font-weight: 500;
    z-index: 200;
    animation: toast-in 0.2s ease;
}
.toast-success { background: var(--accent); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }

@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.loading, .empty-state { padding: 40px; text-align: center; color: var(--text-muted); }
.empty-state h1, .empty-state h2 { color: var(--text); }

.tag { padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; background: var(--surface-3); }
.tag-success { background: rgba(22, 163, 74, 0.2); color: #86EFAC; }
.tag-danger { background: rgba(220, 38, 38, 0.2); color: #FCA5A5; }
.tag-warning { background: rgba(217, 119, 6, 0.2); color: #FCD34D; }
.tag-muted { background: var(--surface-3); color: var(--text-muted); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------- MVC additions */

.hidden { display: none !important; }

.link-button {
    background: none;
    border: none;
    color: var(--text-muted);
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.cashier-card { text-align: center; }

.inline-form { display: flex; gap: 6px; align-items: center; }
.input-inline { height: 34px; width: 150px; font-size: 0.82rem; }

/* ------------------------------------------------- holds and returns */

.held-count {
    display: inline-block;
    min-width: 20px;
    padding: 1px 6px;
    margin-inline-start: 6px;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

.held-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    margin-block-end: 6px;
}
.held-row-main { flex: 1; min-width: 0; }
.held-row-label { display: block; font-weight: 600; }
.held-row-meta { display: block; font-size: 0.8rem; color: var(--text-muted); }

.d-flex-gap { display: flex; gap: 8px; }
.d-flex-gap .input { flex: 1; }

.modal-return { max-width: 620px; }

.return-meta {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-block-end: 12px;
}
.return-meta strong { color: var(--text); }

.return-lines { display: grid; gap: 6px; max-height: 280px; overflow-y: auto; }

.return-line {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}
.return-line-name { font-weight: 600; }
.return-line-meta { font-size: 0.8rem; color: var(--text-muted); }
.return-line input { height: 42px; text-align: right; }
.return-line.spent { opacity: 0.45; }

.return-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-block-start: 14px;
    padding-block-start: 12px;
    border-block-start: 1px solid var(--border);
    font-size: 1.25rem;
}
.return-total strong { color: var(--brand-light); }

/* ------------------------------------------------------ shop identity */

/* The logo sits on the colour of receipt paper — the shop's own material —
   rather than on a grey wash. The warm glow is the amber above it landing on
   the plate, which is why it is a shadow and not a border. */
.login-logo {
    display: grid;
    place-items: center;
    width: 138px;
    height: 138px;
    padding: 16px;
    border-radius: 28px;
    background: #FFFCF4;
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, .10),
        0 2px 6px rgba(0, 0, 0, .35),
        0 22px 48px -20px rgba(0, 0, 0, .9),
        0 0 70px -14px rgba(180, 83, 9, .55);
}

/* A grid item defaults to min-height: auto, so a tall image insists on its own
   intrinsic height and pushes straight out of the plate. Explicit zero minimums
   are what let object-fit do its job; max-height alone never gets a chance. */
.login-logo img,
img.login-logo {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    object-fit: contain;
}

.login-logo-letter {
    background: linear-gradient(150deg, #C2620B 0%, #8A3D06 100%);
    color: #FFF6E8;
    font-size: 3.4rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* One reveal on load, and only one. Everything after this is a response to
   something the cashier did. */
.login-header { animation: brand-in .45s cubic-bezier(.2, .7, .3, 1) both; }

@keyframes brand-in {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .login-header { animation: none; }
}

.cart-logo {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    object-fit: contain;
    background: #FFFCF4;
    padding: 3px;
    margin-inline-end: 10px;
    flex: 0 0 auto;
}
