/* Component library — Melbet Rewards Store prototype */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 44px; padding: 0 var(--s-4);
  border: 1px solid transparent; border-radius: var(--r-control);
  font-size: 14px; font-weight: 500; line-height: 1;
  cursor: pointer; text-decoration: none; user-select: none;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: #27272A; }
.btn-secondary { background: var(--bg); color: var(--fg); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface); }
.btn-destructive { background: var(--destructive); color: #fff; }
.btn-ghost { background: transparent; color: var(--fg); }
.btn-ghost:hover { background: var(--surface); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 36px; padding: 0 var(--s-3); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 14px; font-weight: 500; }
.field .req { color: var(--destructive); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .hint.warn { color: var(--warning-fg); }
.input, .select, textarea.input {
  width: 100%; min-height: 44px; padding: 10px var(--s-3);
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--r-control);
  font: inherit; font-size: 14px;
}
textarea.input { resize: vertical; line-height: 1.45; }
.input::placeholder { color: var(--muted); }
.input:focus, .select:focus, textarea.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.input[aria-invalid="true"] { border-color: var(--destructive); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2371717A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.input-group { position: relative; }
.input-group .input { padding-right: 64px; }
.input-group .pass-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  min-height: 36px; padding: 0 10px; border: 0; background: none;
  font-size: 12px; font-weight: 500; color: var(--muted); cursor: pointer;
}

.checkbox { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 40px; height: 24px; border-radius: 999px; background: var(--border);
  position: relative; transition: background .15s; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(9,9,11,.2); transition: left .15s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { left: 18px; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1.4;
  background: var(--surface); border: 1px solid var(--border); color: var(--fg);
}
.badge-muted { color: var(--muted); }
.badge-geo { background: var(--surface); color: var(--muted); }

.status-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.status-created { background: var(--surface); border: 1px solid var(--border); color: var(--fg); }
.status-approved { background: #E0E7FF; color: #3730A3; }
.status-placed { background: var(--accent); color: var(--accent-fg); }
.status-delivered { background: var(--success-soft); color: #166534; }
.status-cancelled { background: var(--destructive-soft); color: #991B1B; }
.status-returned { background: var(--warning-bg); color: var(--warning-fg); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 var(--s-3);
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg); font-size: 14px; font-weight: 500; cursor: pointer;
}
.chip.is-active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* ---------- Cards ---------- */
.card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--shadow-card);
}
.card-pad { padding: var(--s-4); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--s-2);
  padding: 0 var(--s-2) 0 var(--s-1);
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 0; border-radius: var(--r-control);
  background: none; cursor: pointer; color: var(--fg); text-decoration: none; flex: none;
}
.icon-btn:hover { background: var(--surface); }
.topbar .brand { font-size: 15px; font-weight: 700; letter-spacing: .08em; text-decoration: none; }
.topbar .spacer { flex: 1; }
.count-badge {
  position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--accent); color: var(--accent-fg);
  font-size: 10px; font-weight: 600; line-height: 16px; text-align: center;
}
[data-heart] .heart-fill { display: none; }
[data-heart].is-active .heart-fill { display: block; }
[data-heart].is-active .heart-line { display: none; }

/* balance chip + popover */
.balance-wrap { position: relative; flex: none; }
.balance-chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 10px 0 var(--s-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer;
}
.balance-pop {
  display: none; position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  width: 220px; padding: var(--s-3) var(--s-4);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--shadow-overlay);
}
.balance-pop.is-open { display: block; }
.balance-pop .row { display: flex; justify-content: space-between; gap: var(--s-3); padding: 6px 0; font-size: 13px; }
.balance-pop .row b { font-variant-numeric: tabular-nums; }
.balance-pop .row.total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; font-weight: 600; }

/* ---------- Overlays: burger drawer & cart sheet & modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 80; display: none;
  background: rgba(9, 9, 11, .45);
}
.overlay.is-open { display: block; }
body.no-scroll { overflow: hidden; }

.drawer {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: min(320px, 86vw);
  background: var(--bg); box-shadow: var(--shadow-overlay);
  display: flex; flex-direction: column;
}
.drawer .drawer-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4); border-bottom: 1px solid var(--border); }
.drawer nav { flex: 1; padding: var(--s-2) 0; overflow-y: auto; }
.drawer nav a {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  min-height: 48px; padding: 0 var(--s-4);
  font-size: 15px; font-weight: 500; text-decoration: none;
}
.drawer nav a:hover { background: var(--surface); }
.drawer nav .sep { border-top: 1px solid var(--border); margin: var(--s-2) 0; }
.drawer nav .n-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-fg); font-size: 11px; font-weight: 600; line-height: 20px; text-align: center; }
.drawer .drawer-user { border-top: 1px solid var(--border); padding: var(--s-4); display: flex; align-items: center; gap: var(--s-3); }
.drawer .avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-fg); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; flex: none; }
.drawer .drawer-user .who { min-width: 0; }
.drawer .drawer-user .who .name { font-size: 14px; font-weight: 600; }
.drawer .drawer-user .who .mail { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; top: 0;
  margin: 0 auto; max-width: var(--page-max);
  background: var(--bg); display: flex; flex-direction: column;
}
.sheet .sheet-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4); border-bottom: 1px solid var(--border); }
.sheet .sheet-body { flex: 1; overflow-y: auto; padding: var(--s-4); }
.sheet .sheet-foot { border-top: 1px solid var(--border); padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); background: var(--bg); }

.cart-item { display: grid; grid-template-columns: 64px 1fr auto; gap: var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--border); align-items: center; }
.cart-item .ph { width: 64px; height: 64px; }
.cart-item .ci-name { font-size: 14px; font-weight: 500; }
.cart-item .ci-price { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.total-row { display: flex; justify-content: space-between; align-items: baseline; }
.total-row .sum { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.after-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.stepper { display: inline-flex; align-items: center; gap: var(--s-2); }
.stepper button {
  width: 32px; height: 32px; border: 1px solid var(--border); border-radius: var(--r-control);
  background: var(--bg); font-size: 16px; line-height: 1; cursor: pointer;
}
.stepper .qty { min-width: 20px; text-align: center; font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; }

.modal-card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(360px, calc(100vw - 32px));
  background: var(--bg); border-radius: var(--r-card); box-shadow: var(--shadow-overlay);
  padding: var(--s-5) var(--s-4) var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-3);
}
.modal-card .m-actions { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-2); }

/* ---------- Alerts ---------- */
.alert {
  display: flex; gap: 10px; padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border); border-radius: var(--r-control);
  background: var(--surface); font-size: 13px; line-height: 1.5;
}
.alert .a-ic { flex: none; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; background: var(--accent); color: var(--accent-fg); }
.alert-warning { background: var(--warning-bg); border-color: #FDE68A; color: var(--warning-fg); }
.alert-warning .a-ic { background: var(--warning-fg); }
.alert-destructive { background: var(--destructive-soft); border-color: #FECACA; color: #991B1B; }
.alert-destructive .a-ic { background: var(--destructive); }
.alert-success { background: var(--success-soft); border-color: #BBF7D0; color: #166534; }
.alert-success .a-ic { background: var(--success); }

/* ---------- Product grid & cards ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); }
.ph { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--r-control); position: relative; overflow: hidden; }
.ph::after {
  content: ""; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%23D4D4D8' stroke-width='1.5'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='9' cy='9' r='2'/%3E%3Cpath d='m21 15-3.5-3.5L6 23'/%3E%3C/svg%3E") center / 24px no-repeat;
}

.product-card { position: relative; display: flex; flex-direction: column; gap: var(--s-2); }
.product-card .pc-img { aspect-ratio: 1; }
.product-card .pc-heart {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.9); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.product-card .pc-name { font-size: 14px; font-weight: 500; line-height: 1.35; }
.product-card .pc-price { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.product-card .pc-need { font-size: 12px; font-weight: 500; color: var(--warning-fg); }
.product-card--geo { opacity: .55; }

/* ---------- Category cards ---------- */
.cat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); }
.cat-card { display: flex; flex-direction: column; gap: var(--s-2); text-decoration: none; }
.cat-card .cc-img { aspect-ratio: 16/9; }
.cat-card .cc-name { font-size: 14px; font-weight: 600; }

/* ---------- Rows: transaction / notification / order item ---------- */
.row-tx { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--border); }
.row-tx .tx-what .t { font-size: 14px; font-weight: 500; }
.row-tx .tx-what .d { font-size: 12px; color: var(--muted); }
.row-tx .tx-amt { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-tx .tx-amt.plus { color: var(--success); }

.row-notif { display: grid; grid-template-columns: 12px 1fr auto; gap: var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--border); align-items: start; }
.row-notif .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; }
.row-notif.is-read .dot { background: transparent; }
.row-notif .n-title { font-size: 14px; font-weight: 500; }
.row-notif.is-read .n-title { font-weight: 400; color: var(--muted); }
.row-notif .n-sub { font-size: 12px; color: var(--muted); }
.row-notif .n-date { font-size: 12px; color: var(--muted); white-space: nowrap; }

.order-row { display: flex; flex-direction: column; gap: 6px; padding: var(--s-4); text-decoration: none; }
.order-row .o-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.order-row .o-num { font-size: 14px; font-weight: 600; }
.order-row .o-what { font-size: 13px; color: var(--muted); }
.order-row .o-bottom { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.order-row .o-sum { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.order-row .o-date { font-size: 12px; color: var(--muted); }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.tl-step { display: grid; grid-template-columns: 20px 1fr; gap: var(--s-3); }
.tl-step .tl-rail { display: flex; flex-direction: column; align-items: center; }
.tl-step .tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 4px; }
.tl-step .tl-line { width: 2px; flex: 1; background: var(--border); min-height: 20px; }
.tl-step:last-child .tl-line { display: none; }
.tl-step .tl-body { padding-bottom: var(--s-4); }
.tl-step .tl-name { font-size: 14px; font-weight: 600; }
.tl-step .tl-date { font-size: 12px; color: var(--muted); }
.tl-step.upcoming .tl-dot { background: var(--surface); border: 2px solid var(--border); }
.tl-step.upcoming .tl-name { color: var(--muted); font-weight: 400; }
.tl-step.stopped .tl-dot { background: var(--destructive); }

/* ---------- Empty state ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
  padding: var(--s-6) var(--s-4); text-align: center;
}
.empty .e-ic {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.empty h3 { font-size: 16px; }
.empty p { font-size: 14px; color: var(--muted); max-width: 280px; }

/* ---------- Load more ---------- */
.load-more { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding: var(--s-4) 0; }
.load-more .lm-count { font-size: 12px; color: var(--muted); }

/* ---------- Page helpers ---------- */
main.page--center { display: flex; flex-direction: column; justify-content: center; gap: var(--s-4); }
.logo-mark {
  width: 48px; height: 48px; border-radius: 12px; margin: 0 auto;
  background: var(--accent); color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700;
}
.center-text { text-align: center; }
.gallery-dots { display: flex; justify-content: center; gap: 6px; padding-top: var(--s-2); }
.gallery-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.gallery-dots i.on { background: var(--accent); }
.hero-3 { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: var(--s-3); align-items: end; }
.hero-3 .k { font-size: 12px; color: var(--muted); display: block; }
.hero-3 .v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hero-3 .v.big { font-size: 22px; font-weight: 700; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); align-items: center; }

/* ---------- Utilities ---------- */
.stack { display: flex; flex-direction: column; }
.gap-1 { gap: var(--s-1); } .gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); } .gap-4 { gap: var(--s-4); } .gap-5 { gap: var(--s-5); }
.hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-4) 0; }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }

/* state visibility: elements bound to ?state= are hidden until app.js activates them */
[data-state] { display: none; }
[data-state].state-on { display: revert; }
