/* Oq Saroy admin dashboard. Plain CSS, same colors as the bot screen designs.
   Built for computers AND phones: below 760px wide, tables turn into cards, the page list folds
   behind a button, and everything you tap is at least 44px tall (Apple's and Google's advice). */

:root {
  --teal: #0B6E78;
  --teal-dark: #08525A;
  --teal-soft: #E3F1F2;
  --ink: #14212B;
  --text: #2E3B45;
  --muted: #56636D;
  --line: #D5DCE1;
  --line-strong: #C9D3D9;
  --bg: #F1F4F6;
  --card: #FFFFFF;
  --row-alt: #F7F9FA;
  --danger: #8A2620;
  --danger-soft: #FBE3E1;
  --ok: #1F5F2C;
  --ok-soft: #DDF0DF;
  --amber: #6B4A00;
  --amber-soft: #FBEBC8;
  --purple: #3F348A;
  --purple-soft: #E4E0F7;
  --radius: 10px;
  --font: "Rubik", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--text); background: var(--bg);
       -webkit-tap-highlight-color: rgba(11, 110, 120, 0.15); }
a { color: var(--teal); }
a:hover { color: var(--teal-dark); }
h1, h2 { color: var(--ink); line-height: 1.2; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 10px 20px; background: var(--card);
          border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; font-size: 17px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--teal); font-weight: 500; }
.brand-big { font-size: 26px; text-align: center; margin-bottom: 20px; }
.nav-panel { display: flex; align-items: center; gap: 16px; flex: 1; order: 2; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; white-space: nowrap; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.on { background: var(--teal-soft); color: var(--teal-dark); }
.whoami { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--muted); font-size: 14px; }
.lang-switch { order: 3; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 13px;
               font-weight: 500; text-decoration: none; white-space: nowrap; }
.lang-switch:hover { border-color: var(--teal); }
.nav-toggle { display: none; }

/* ---------- page layout ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 24px 20px 48px; }
.page-narrow { max-width: 720px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.back { margin: 0 0 8px; font-size: 14px; }
.back a { text-decoration: none; display: inline-block; padding: 4px 0; }
.page > h1 { margin-bottom: 12px; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 16px; display: block; }
.muted { color: var(--muted); }
.empty { color: var(--muted); margin: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 .card { margin-bottom: 0; }
.grid-2 + .card { margin-top: 16px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; }
.tabs a { padding: 6px 12px; border-radius: 7px; text-decoration: none; color: var(--text); font-weight: 500; font-size: 14px;
          white-space: nowrap; text-align: center; }
.tabs a.on { background: var(--teal); color: #FFFFFF; }

/* ---------- tables ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; margin-bottom: 16px; }
.card .table-wrap { border: 0; border-radius: 0; margin: 0 -20px -18px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--row-alt); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #FAFBFC; }
.table.compact th, .table.compact td { padding: 7px 8px; }
.table tfoot td { border-bottom: 0; color: var(--muted); }
.table tfoot .total td { color: var(--ink); font-weight: 600; border-top: 1px solid var(--line); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.code { font-weight: 600; text-decoration: none; white-space: nowrap; }
.row-off td { color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.stars { color: #C98A00; letter-spacing: 1px; white-space: nowrap; }

/* ---------- order details ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 12px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.note { background: var(--amber-soft); color: var(--amber); padding: 2px 8px; border-radius: 6px; }
.paid-form { margin-top: 14px; }
.btn-call { margin-top: 16px; }

/* ---------- status chips ---------- */
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--bg); color: var(--muted); }
.st-placed { background: #F2B33D; color: var(--ink); }
.st-confirmed { background: var(--teal-soft); color: var(--teal-dark); }
.st-preparing { background: var(--amber-soft); color: var(--amber); }
.st-ready { background: #D7EEF7; color: #0E4E66; }
.st-out_for_delivery { background: var(--purple-soft); color: var(--purple); }
.st-delivered, .pay-paid { background: var(--ok-soft); color: var(--ok); }
.st-cancelled { background: #E7EBEE; color: var(--muted); }
.st-rejected, .pay-unpaid { background: var(--danger-soft); color: var(--danger); }
.pay-problem { background: var(--amber-soft); color: var(--amber); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: 8px;
       border: 1px solid var(--line-strong); background: var(--card); color: var(--teal); font: 500 14px var(--font);
       text-decoration: none; cursor: pointer; white-space: nowrap; touch-action: manipulation; }
.btn:hover { border-color: var(--teal); color: var(--teal-dark); }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #FFFFFF; }
.btn-primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); color: #FFFFFF; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.btn-small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row form { margin: 0; }
.btn:focus-visible, .nav a:focus-visible, .tabs a:focus-visible, .lang-switch:focus-visible, .nav-toggle:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #8CC8CE; outline-offset: 1px; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-card h2 { margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; color: var(--ink); }
.field .muted, .field .hint { font-weight: 400; }
.field .hint { margin: 0; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 8px;
  font: 400 15px var(--font); color: var(--ink); background: #FFFFFF; }
input[type=date] { -webkit-appearance: none; appearance: none; }
textarea { resize: vertical; }
input.invalid { border-color: var(--danger); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--ink); }
.check input { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--teal); }
.error { color: var(--danger); font-size: 13px; font-weight: 500; }

/* ---------- past orders: filters, totals, page links ---------- */
.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 2fr) auto; gap: 12px; align-items: end; }
.filters .field { font-size: 14px; min-width: 0; }
.filters input, .filters select { min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 12px 16px; }
.stat-number { font-size: 22px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-warn { border-color: #E9C46A; background: #FFF8E6; }
.stat-warn .stat-number { color: var(--amber); }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 8px 0 0; }

/* ---------- messages ---------- */
.flashes { margin-bottom: 4px; }
.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; font-weight: 500; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-err { background: var(--danger-soft); color: var(--danger); }

/* ---------- login and error pages ---------- */
.login-body { display: flex; min-height: 100vh; min-height: 100dvh; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login-lang { display: flex; justify-content: flex-end; margin-bottom: 8px; }

/* Laptops: Uzbek page names are longer, so drop the email next to "Log out" to keep the bar on one line. */
@media (min-width: 761px) and (max-width: 1400px) {
  .whoami span { display: none; }
  .nav a { padding: 8px 10px; }
}

/* =====================================================================================
   Phones and small tablets
   ===================================================================================== */
@media (max-width: 760px) {
  body { font-size: 16px; }
  h1 { font-size: 22px; }

  /* Top bar stays at the top while you scroll. The page list folds behind the "Pages" button. */
  .topbar { position: sticky; top: 0; z-index: 10; gap: 10px; padding: 8px 16px;
            padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .brand { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .lang-switch { order: 0; min-height: 36px; display: inline-flex; align-items: center; }
  .nav-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong);
                border-radius: 8px; background: var(--card); color: var(--ink); font: 500 15px var(--font); cursor: pointer; }
  .nav-toggle-icon, .nav-toggle-icon::before, .nav-toggle-icon::after { display: block; width: 18px; height: 2px; background: currentColor;
                border-radius: 2px; position: relative; content: ""; }
  .nav-toggle-icon::before { position: absolute; top: -6px; }
  .nav-toggle-icon::after { position: absolute; top: 6px; }
  .nav-panel { order: 4; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 8px; padding: 4px 0 8px; }
  .js .nav-panel { display: none; }
  .js .topbar.open .nav-panel { display: flex; }
  .nav { flex-direction: column; gap: 2px; }
  .nav a { min-height: 48px; display: flex; align-items: center; padding: 0 12px; font-size: 16px; }
  .whoami { justify-content: space-between; border-top: 1px solid var(--line); padding-top: 10px; }
  .whoami span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .whoami .btn { min-height: 44px; }

  .page { padding: 16px 16px 40px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .card { padding: 16px; }
  .grid-2, .field-row { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: 96px minmax(0, 1fr); }
  .hide-sm { display: none !important; }

  /* Bigger things to tap. 16px text in inputs stops iPhones from zooming in when you tap a field. */
  .btn { min-height: 44px; font-size: 15px; }
  .btn-small { min-height: 40px; font-size: 14px; padding: 0 12px; }
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], select, textarea {
    font-size: 16px; min-height: 46px; }
  .check { min-height: 44px; }
  .back a { padding: 8px 0; }

  /* Order tabs: 2 x 2 grid, all four visible without scrolling sideways. */
  .page-head .tabs { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .tabs a { min-height: 40px; display: flex; align-items: center; justify-content: center; white-space: normal; line-height: 1.2; }

  /* Buttons in a .btn-stack sit full width, one under another (status buttons, Save / Cancel). */
  .btn-stack { flex-direction: column; align-items: stretch; }
  .btn-stack .btn { width: 100%; }
  .btn-call { width: 100%; }
  .page-head .btn-row { width: 100%; }
  .page-head .btn-row .btn, .page-head > .btn { flex: 1; }

  /* ---- Tables become cards: one card per row. Each cell shows its column name (data-label) on the left. */
  .table-wrap { background: none; border: 0; border-radius: 0; overflow: visible; }
  .card .table-wrap { margin: 0; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards thead { display: none; }
  .table-cards tr { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
                    padding: 10px 14px; margin-bottom: 10px; }
  .card .table-cards tr { background: var(--row-alt); }
  .table-cards tbody tr:hover td { background: none; }
  .table-cards td, .table.compact.table-cards td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
                    padding: 5px 0; border: 0; text-align: right; min-height: 32px; }
  .table-cards td::before { content: attr(data-label); color: var(--muted); font-size: 14px; font-weight: 500; text-align: left; flex-shrink: 0; }
  .table-cards td.cell-title { justify-content: flex-start; text-align: left; font-size: 17px; font-weight: 600; color: var(--ink);
                    padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
  .table-cards td.cell-title::before, .table-cards td.row-actions::before { display: none; }
  .table-cards td.cell-wrap { flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
  .table-cards td.cell-break { overflow-wrap: anywhere; }
  .table-cards td.row-actions { justify-content: stretch; gap: 8px; padding-top: 10px; }
  .table-cards td.row-actions > * { flex: 1 1 0; }
  .table-cards td.row-actions .btn { width: 100%; }
  .table-cards td.row-actions > .muted { text-align: center; align-self: center; }
  .table-cards .code { font-size: 17px; }

  /* Order lists: tapping anywhere on the card opens the order (the order code link stretches over the card). */
  .tap-rows td.cell-title a.code::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
  .tap-rows tr:active { background: var(--teal-soft); }

  /* Past orders filters: dates side by side, the rest full width. */
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .filters-search, .filters-buttons, .filters .field:nth-child(3) { grid-column: 1 / -1; }
  .filters-buttons .btn { flex: 1; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:first-child { grid-column: 1 / -1; }
  .stat-number { font-size: 20px; }
}

/* Small phones: the top bar keeps only "Oq Saroy", so the language link and the Pages button fit. */
@media (max-width: 420px) {
  .topbar .brand span { display: none; }
}
