/* ============================================================
   KangePOS Design Tokens
   Dark charcoal base with a brushed-gold accent -- built to sit
   next to LEVOK's dark/gold identity so the two feel like one
   product family, not two different vendors.
   ============================================================ */
:root {
    --ink:            #0E0C09;
    --surface:        #17140F;
    --surface-raised: #1E1A14;
    --surface-hover:  #26211A;
    --border:         #2E2820;
    --gold:           #C9A24B;
    --gold-bright:    #E4C271;
    --gold-dim:       #8A6F35;
    --text:           #F1EDE3;
    --text-dim:       #B8AFA0;
    --text-faint:     #7A7368;
    --success:        #5FAE72;
    --success-bg:     #16241A;
    --error:          #D96C6C;
    --error-bg:       #2A1616;
    --warning:        #E0A94E;
    --warning-bg:     #2A2112;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --font-display: 'Iowan Old Style', 'Georgia', 'Times New Roman', serif;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Consolas', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--ink);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--gold); text-decoration: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0 0 8px; color: var(--text); }

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

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar__brand {
    display: flex; align-items: center; gap: 10px;
    padding: 22px 20px;
    border-bottom: 1px solid var(--border);
}
.sidebar__brand-mark {
    width: 34px; height: 34px; border-radius: 8px;
    background: linear-gradient(145deg, var(--gold-bright), var(--gold-dim));
    color: var(--ink); font-family: var(--font-display); font-weight: 700;
    display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.sidebar__brand-name { font-family: var(--font-display); font-size: 18px; letter-spacing: .3px; }
.sidebar__brand-name em { color: var(--gold); font-style: normal; }

.sidebar__nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.sidebar__link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--text-dim); font-size: 13.5px; font-weight: 500;
    transition: background .15s, color .15s;
}
.sidebar__link:hover { background: var(--surface-hover); color: var(--text); }
.sidebar__link.is-active { background: linear-gradient(90deg, rgba(201,162,75,.16), transparent); color: var(--gold-bright); border-left: 2px solid var(--gold); padding-left: 10px; }
.sidebar__icon { width: 16px; height: 16px; border-radius: 3px; background: currentColor; opacity: .55; mask: radial-gradient(circle, #000 40%, transparent 41%) 0 0/6px 6px; -webkit-mask: none; }
.sidebar__footer { padding: 16px 20px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-faint); display: flex; justify-content: space-between; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    display: flex; align-items: center; gap: 16px;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.topbar__menu-btn { display: none; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; padding: 6px; }
.topbar__menu-btn span { width: 20px; height: 2px; background: var(--text); display: block; }
.topbar__title { font-size: 18px; margin: 0; }
.topbar__spacer { flex: 1; }
.topbar__user { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; margin-right: 4px; }
.topbar__user-name { font-size: 13px; font-weight: 600; }
.topbar__user-role { font-size: 11px; color: var(--text-faint); }
.topbar__branch { margin-right: 8px; }

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

/* ---------- Badges / Alerts ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge--gold { background: rgba(201,162,75,.15); color: var(--gold-bright); border: 1px solid rgba(201,162,75,.3); }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; border: 1px solid transparent; }
.alert--success { background: var(--success-bg); color: var(--success); border-color: rgba(95,174,114,.3); }
.alert--error { background: var(--error-bg); color: var(--error); border-color: rgba(217,108,108,.3); }
.alert--warning { background: var(--warning-bg); color: var(--warning); border-color: rgba(224,169,78,.3); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
    font-family: var(--font-body);
}
.btn--primary { background: linear-gradient(145deg, var(--gold-bright), var(--gold)); color: var(--ink); }
.btn--primary:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn--ghost:hover { border-color: var(--gold-dim); color: var(--text); }
.btn--danger { background: var(--error-bg); color: var(--error); border-color: rgba(217,108,108,.4); }
.btn--sm { padding: 6px 12px; font-size: 12px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Cards / KPIs ---------- */
.grid { display: grid; gap: 16px; }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 18px 20px;
}
.kpi-card__label { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.kpi-card__value { font-family: var(--font-display); font-size: 26px; color: var(--gold-bright); }
.kpi-card__sub { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 10px 12px; background: var(--surface-raised);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-size: 13.5px; font-family: var(--font-body);
}
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--gold-dim); box-shadow: 0 0 0 3px rgba(201,162,75,.12); }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 180px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
    text-align: left; padding: 12px 14px; background: var(--surface-raised);
    color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
    border-bottom: 1px solid var(--border);
}
table.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text-dim); }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: var(--surface-hover); color: var(--text); }

/* ---------- Login page ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 30% 20%, #211c14, var(--ink) 60%); }
.auth-card { width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 36px 32px; }
.auth-card__logo { text-align: center; margin-bottom: 8px; font-family: var(--font-display); font-size: 28px; }
.auth-card__logo em { color: var(--gold); font-style: normal; }
.auth-card__tagline { text-align: center; color: var(--text-faint); font-size: 12.5px; margin-bottom: 28px; }

/* ---------- POS screen ---------- */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 18px; height: calc(100vh - 110px); }
.pos-catalog { display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
.pos-search { display: flex; gap: 10px; }
.pos-product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; overflow-y: auto; padding-right: 4px; }
.pos-product {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 12px; cursor: pointer; transition: border-color .15s, transform .1s; text-align: left;
}
.pos-product:hover { border-color: var(--gold-dim); transform: translateY(-2px); }
.pos-product__name { font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 4px; min-height: 32px; }
.pos-product__price { font-size: 13px; color: var(--gold-bright); font-weight: 700; }
.pos-product__stock { font-size: 10.5px; color: var(--text-faint); margin-top: 2px; }
.pos-product__stock--low { color: var(--warning); }

.pos-cart { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); display: flex; flex-direction: column; overflow: hidden; }
.pos-cart__header { padding: 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.pos-cart__items { flex: 1; overflow-y: auto; padding: 8px 16px; }
.pos-cart-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--border); gap: 8px; }
.pos-cart-item__name { font-size: 12.5px; font-weight: 600; }
.pos-cart-item__meta { font-size: 11px; color: var(--text-faint); }
.pos-cart-item__qty { display: flex; align-items: center; gap: 6px; }
.pos-cart-item__qty button { width: 22px; height: 22px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface-raised); color: var(--text); cursor: pointer; }
.pos-cart__totals { padding: 14px 16px; border-top: 1px solid var(--border); font-size: 13px; }
.pos-cart__totals-row { display: flex; justify-content: space-between; padding: 4px 0; color: var(--text-dim); }
.pos-cart__totals-row--grand { font-size: 18px; color: var(--gold-bright); font-family: var(--font-display); padding-top: 10px; border-top: 1px solid var(--border); margin-top: 6px; }
.pos-cart__actions { padding: 14px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; z-index: 100; }
.modal-backdrop.is-open { display: flex; }
.modal { width: 420px; max-width: 92vw; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; max-height: 88vh; overflow-y: auto; }
.modal__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal__close { background: none; border: none; color: var(--text-faint); font-size: 20px; cursor: pointer; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .pos-layout { grid-template-columns: 1fr; height: auto; }
    .sidebar { position: fixed; left: -240px; z-index: 50; transition: left .2s; }
    .sidebar.is-open { left: 0; }
    .topbar__menu-btn { display: flex; }
}
