@import url('/css/tokens.css');

/* ═══════════════════════════════════════════════════════════════════════
   MOBIL SAVDO — boshqaruv paneli.
   Ranglar do'kon ilovasi bilan bir xil manbadan (tokens.css) keladi:
   dashboard va do'kon bitta tizimdek ko'rinishi kerak.
   ═══════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.45 var(--body);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--display); font-weight: 700; letter-spacing: -0.02em; }
p { margin: 0; }
ul, dl, dd, dt { margin: 0; padding: 0; }
ul { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
[hidden] { display: none !important; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

.num { font-family: var(--display); font-variant-numeric: tabular-nums; }

/* ─── Kirish ekrani ──────────────────────────────────────────────────── */

.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px; background: var(--surface);
  border-radius: var(--radius-lg); padding: 32px 26px;
  box-shadow: var(--shadow); text-align: center;
}
.login-mark { line-height: 0; margin-bottom: 16px; }
.login h1 { font-size: 20px; font-weight: 800; }
.login-sub { font-size: 12.5px; color: var(--muted); margin-top: 5px; margin-bottom: 24px; }
.login .label { text-align: left; display: block; }
.login .btn { width: 100%; margin-top: 18px; }

/* ─── Karkas ─────────────────────────────────────────────────────────── */

.shell { display: flex; min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; align-self: flex-start;
  width: 232px; flex: none; height: 100dvh;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 9px; padding: 0 8px 20px;
}
.sidebar-mark { line-height: 0; flex: none; }
.sidebar-title {
  font-family: var(--display); font-size: 14px; font-weight: 800; letter-spacing: 0.02em;
}
.sidebar-title span { color: var(--brand-600); }
[data-theme='dark'] .sidebar-title span { color: #7BA6FF; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-item {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 12px; border-radius: var(--ios-radius);
  color: var(--muted); font-size: 14px; font-weight: 500; text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.side-item:hover { background: var(--fill-tertiary); color: var(--text); }
.side-item.is-active { background: var(--brand-soft); color: var(--brand-700); font-weight: 600; }
[data-theme='dark'] .side-item.is-active { color: #9DBBFF; }
.side-icon { font-size: 15px; width: 18px; text-align: center; }
.side-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--danger); color: #fff; border-radius: 999px;
  font-family: var(--display); font-size: 11px; font-weight: 700; line-height: 20px;
  text-align: center;
}

.sidebar-foot {
  display: flex; flex-direction: column; gap: 2px;
  padding-top: 14px; border-top: 1px solid var(--line);
}
.side-link {
  display: block; min-height: 40px; padding: 0 12px; line-height: 40px;
  border-radius: var(--ios-radius); color: var(--muted);
  font-size: 13px; text-align: left; text-decoration: none;
}
.side-link:hover { background: var(--fill-tertiary); color: var(--text); }

.main { flex: 1; min-width: 0; padding: 26px 28px 60px; }

/* ─── Sahifa sarlavhasi ──────────────────────────────────────────────── */

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-head h2 { font-size: 22px; font-weight: 800; }
.page-head p { font-size: 13px; color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── Tugmalar ───────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 18px; border-radius: var(--ios-radius);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  transition: opacity 0.12s ease, background 0.12s ease;
}
.btn:active { opacity: 0.55; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-soft { background: var(--brand-soft); color: var(--brand-700); }
[data-theme='dark'] .btn-soft { color: #9DBBFF; }
.btn-ghost { background: var(--fill-tertiary); color: var(--text); }
.btn-danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn-sm { min-height: 36px; padding: 0 13px; font-size: 13px; }
.btn.is-loading { pointer-events: none; opacity: 0.6; }

/* ─── Maydonlar ──────────────────────────────────────────────────────── */

.label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--muted); margin-bottom: 6px;
}
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 13px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--ios-radius); font-size: 14px; outline: none;
  transition: border-color 0.12s ease;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-500); }
.input[type='number'] { font-family: var(--display); font-variant-numeric: tabular-nums; }
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 150px; }
.error { color: var(--danger); font-size: 12.5px; margin-top: 6px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }

.check { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand-600); }

/* ─── Ikki tilli maydon ──────────────────────────────────────────────── */

.bi-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bi-tabs { display: flex; gap: 2px; background: var(--fill-tertiary); border-radius: 999px; padding: 2px; }
.bi-tab {
  min-width: 34px; height: 26px; padding: 0 9px; border-radius: 999px;
  font-family: var(--display); font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em;
  color: var(--muted);
}
.bi-tab.is-active { background: var(--surface); color: var(--brand-600); box-shadow: var(--shadow-sm); }
[data-theme='dark'] .bi-tab.is-active { color: #7BA6FF; }
/* To'ldirilmagan til nuqta bilan belgilanadi — ruscha katalog jimgina
   yarim qolmasin */
.bi-tab.is-empty::after {
  content: ''; display: inline-block; width: 5px; height: 5px; margin-left: 4px;
  border-radius: 999px; background: var(--warn); vertical-align: middle;
}

/* ─── Kartochka / jadval ─────────────────────────────────────────────── */

.card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 20px; margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }

.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px;
}
.toolbar .input, .toolbar .select { width: auto; min-width: 160px; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); padding: 0 12px 10px;
}
.table td { padding: 11px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: var(--surface-2); }
.table-scroll { overflow-x: auto; }

.thumb {
  width: 44px; height: 44px; border-radius: 10px; object-fit: contain;
  background: var(--surface-2); flex: none;
}
.thumb-empty {
  width: 44px; height: 44px; border-radius: 10px; background: var(--fill-tertiary);
  display: grid; place-items: center; color: var(--muted); font-size: 16px; flex: none;
}

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1.2;
  background: var(--fill-tertiary); color: var(--muted);
}
.pill-new { background: var(--brand-soft); color: var(--brand-700); }
.pill-used { background: var(--warn-soft); color: var(--warn); }
.pill-off { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.pill-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
[data-theme='dark'] .pill-new { color: #9DBBFF; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ─── Hamkor logosi ──────────────────────────────────────────────────── */

.partner-thumb {
  max-width: 84px; max-height: 34px; object-fit: contain;
  display: block;
}
/* Logo yo'q — nom brend rangida, checkoutdagi ko'rinish bilan bir xil */
.partner-thumb-word {
  display: inline-block; max-width: 84px;
  font-family: var(--display); font-size: 12px; font-weight: 800;
  letter-spacing: -0.02em; line-height: 1.15;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ─── Tartiblash ─────────────────────────────────────────────────────── */

.sort-btns { display: flex; flex-direction: column; gap: 2px; }
.sort-btn {
  width: 28px; height: 22px; border-radius: 6px;
  background: var(--fill-tertiary); color: var(--muted);
  font-size: 11px; line-height: 1;
  display: grid; place-items: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.sort-btn:hover:not(:disabled) { background: var(--brand-soft); color: var(--brand-600); }
.sort-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ─── Takrorlanuvchi qatorlar (variant, rang, xususiyat) ─────────────── */

.repeat { display: flex; flex-direction: column; gap: 10px; }
.repeat-row {
  display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap;
  padding: 12px; background: var(--surface-2); border-radius: var(--ios-radius);
}
.repeat-row .input { min-height: 40px; }
.repeat-grow { flex: 1; min-width: 120px; }
.repeat-del {
  width: 40px; height: 40px; flex: none; border-radius: var(--ios-radius);
  background: var(--fill-tertiary); color: var(--danger);
  display: grid; place-items: center; font-size: 15px;
}
.repeat-add { align-self: flex-start; }

.swatch-input { display: flex; align-items: center; gap: 8px; }
.swatch-input input[type='color'] {
  width: 40px; height: 40px; padding: 0; border: 1px solid var(--line);
  border-radius: 10px; background: none; cursor: pointer; flex: none;
}

/* ─── Rasm boshqaruvi ────────────────────────────────────────────────── */

.media-grid { display: flex; gap: 10px; flex-wrap: wrap; }
/* Rasm + uning izohi bitta ustunda. Ilgari `.media-item` 104px balandlikda
   va `overflow: hidden` edi — izoh maydonlari ichiga sig'masdi. */
.media-item { display: flex; flex-direction: column; gap: 5px; width: 132px; }
.media-thumb {
  position: relative; width: 132px; height: 104px; border-radius: var(--ios-radius);
  background: var(--surface-2); overflow: hidden; border: 1px solid var(--line);
}
.media-thumb img { width: 100%; height: 100%; object-fit: contain; }
.media-thumb.is-main { border-color: var(--brand-600); border-width: 2px; }
.media-alt { display: flex; flex-direction: column; gap: 4px; }
.media-alt .input { font-size: 11px; padding: 5px 7px; min-height: 0; }
.media-main-tag {
  position: absolute; left: 5px; bottom: 5px;
  padding: 2px 7px; border-radius: 999px;
  background: var(--brand-600); color: #fff; font-size: 10px; font-weight: 700;
}
.media-del {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px;
  border-radius: 999px; background: rgba(10, 16, 32, 0.62); color: #fff;
  display: grid; place-items: center; font-size: 13px;
}
.media-add {
  width: 132px; height: 104px; border-radius: var(--ios-radius);
  border: 1.5px dashed var(--line); color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  font-size: 12px; background: none;
}
.media-add:hover { border-color: var(--brand-500); color: var(--brand-600); }

/* ─── Qoldiq jadvali ─────────────────────────────────────────────────── */

.stock-grid { display: flex; flex-direction: column; gap: 8px; }
.stock-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; background: var(--surface-2); border-radius: var(--ios-radius);
}
.stock-row span { flex: 1; font-size: 13.5px; }
.stock-row .input { width: 96px; min-height: 40px; text-align: center; }

/* ─── Buyurtmalar ────────────────────────────────────────────────────── */

.order-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.order-box { background: var(--surface); border-radius: var(--radius-lg); padding: 17px; }
.order-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.order-id { font-family: var(--display); font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.order-when { font-size: 11px; color: var(--muted); margin-top: 2px; }
.order-lines { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.order-lines li { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.order-lines span { color: var(--muted); }
.order-facts { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; font-size: 12.5px; }
.order-facts > div { display: flex; justify-content: space-between; gap: 10px; }
.order-facts dt { color: var(--muted); }
.order-facts dd { font-family: var(--display); font-weight: 600; text-align: right; }
.order-pills { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex: none; }

/* Fiskal chek yaratilmagan buyurtma — soliq masalasi. Sabab qizil
   turadi, aks holda menejer uni boshqa faktlar orasida ko'rmaydi. */
.order-fiscal-error dd { color: #DC2626; font-weight: 600; max-width: 60%; }

.order-verify {
  display: flex; align-items: center; gap: 10px; margin-top: 9px;
  padding-top: 9px; border-top: 1px solid var(--line);
}
.order-verify span { font-size: 12.5px; color: var(--muted); flex: none; }
.order-verify .select { flex: 1; min-height: 38px; }

.order-foot { display: flex; gap: 8px; flex-wrap: wrap; }
.order-foot .select { flex: 1; min-width: 130px; min-height: 40px; }

.order-history-btn {
  margin-top: 10px; min-height: 32px; padding: 0 4px;
  color: var(--muted); font-size: 12px; font-weight: 500;
}
.order-history-btn:hover { color: var(--brand-600); }
.order-history {
  margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 9px;
}
.order-event {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  font-size: 12.5px;
}
.order-event time {
  color: var(--muted); font-family: var(--display);
  font-variant-numeric: tabular-nums; font-size: 11.5px;
}
.order-event p { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }

/* ─── Bo'sh holat ────────────────────────────────────────────────────── */

.empty {
  text-align: center; padding: 56px 20px; background: var(--surface);
  border-radius: var(--radius-lg);
}
.empty-icon { font-size: 36px; color: var(--muted); opacity: 0.5; margin-bottom: 12px; }
.empty h3 { font-size: 16px; margin-bottom: 6px; }
.empty p { font-size: 13px; color: var(--muted); margin-bottom: 18px; }

.notice {
  background: var(--warn-soft); color: var(--warn);
  border-radius: var(--ios-radius); padding: 13px 16px;
  font-size: 13px; line-height: 1.45; margin-bottom: 18px;
}
.notice code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
}

/* ─── Skelet ─────────────────────────────────────────────────────────── */

.sk { background: var(--fill-tertiary); border-radius: 8px; animation: sk 1.4s ease-in-out infinite; }
.sk-row { height: 52px; margin-bottom: 8px; }
@keyframes sk { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ─── Toast ──────────────────────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 18px);
  z-index: 300; max-width: min(440px, calc(100vw - 32px));
  padding: 13px 18px; border-radius: var(--ios-radius);
  background: var(--text); color: var(--surface);
  font-size: 13.5px; font-weight: 500; line-height: 1.4;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); color: #fff; }

/* ─── Modal ──────────────────────────────────────────────────────────── */

.sheet {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(10, 16, 32, 0.5);
  display: grid; place-items: center; padding: 20px;
}
.sheet-card {
  width: 100%; max-width: 420px; background: var(--surface);
  border-radius: var(--radius-lg); padding: 24px;
  box-shadow: var(--shadow-lg);
}
.sheet-card h3 { font-size: 17px; margin-bottom: 8px; }
.sheet-card p { font-size: 13.5px; color: var(--muted); line-height: 1.45; margin-bottom: 20px; }
.sheet-actions { display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; }

/* ─── Telefon ────────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    position: static; width: 100%; height: auto; flex-direction: row;
    align-items: center; gap: 10px; padding: 10px 12px;
    border-right: none; border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .sidebar-brand { padding: 0 6px 0 0; flex: none; }
  .sidebar-title { display: none; }
  .sidebar-nav { flex-direction: row; flex: 1; gap: 4px; }
  .side-item { white-space: nowrap; padding: 0 11px; font-size: 13px; }
  .sidebar-foot { flex-direction: row; padding-top: 0; border-top: none; flex: none; }
  .side-link { padding: 0 10px; font-size: 12px; }
  .main { padding: 18px 14px 48px; }
  .page-head h2 { font-size: 19px; }
}

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