/* Use Telegram theme variables when available, fallback to neutral palette. */
:root {
  --tg-bg: #ffffff;
  --tg-text: #111827;
  --tg-hint: #e5e7eb;
  --tg-secondary-bg: #f6f7f9;
  --tg-button: #3b82f6;
  --tg-button-text: #ffffff;
  --tg-link: #2563eb;

  /* ─── 9 статусов (WIZARD UX, 28.05.2026) ─── */
  --status-new:       #ef4444; /* red */
  --status-in-work:   #3b82f6; /* blue */
  --status-waiting:   #f97316; /* orange */
  --status-checking:  #eab308; /* yellow */
  --status-sending:   #a855f7; /* purple */
  --status-completed: #22c55e; /* green */
  --status-cancelled: #6b7280; /* gray */
  --status-on-hold:   #dc2626; /* red intense */
  --status-expired:   #9ca3af; /* faded */
}

html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* Hide scrollbars on the horizontal tab strip */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

/* Slight press feedback on buttons (mobile feel) */
button { transition: transform 80ms ease, background-color 120ms ease, opacity 120ms ease; }
button:active { transform: scale(0.97); }

/* Code reqs */
code { font-family: 'SF Mono', 'JetBrains Mono', Menlo, monospace; }

/* Pull-to-refresh visual hint */
.ptr-indicator {
  position: fixed;
  top: 0; left: 50%;
  transform: translate(-50%, -100%);
  padding: 6px 14px;
  background: var(--tg-button);
  color: var(--tg-button-text);
  border-radius: 0 0 12px 12px;
  font-size: 12px;
  transition: transform 200ms ease;
  z-index: 50;
}
.ptr-indicator.visible { transform: translate(-50%, 0); }

/* Smooth list enter */
article { animation: cardIn 180ms ease both; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Карточка заявки: цветовая полоса слева по статусу ─── */
article.order-card { position: relative; overflow: hidden; }
article.order-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--card-accent, var(--tg-hint));
}
article.order-card[data-status="new"]       { --card-accent: var(--status-new); }
article.order-card[data-status="in_work"]   { --card-accent: var(--status-in-work); }
article.order-card[data-status="waiting"]   { --card-accent: var(--status-waiting); }
article.order-card[data-status="checking"]  { --card-accent: var(--status-checking); }
article.order-card[data-status="sending"]   { --card-accent: var(--status-sending); }
article.order-card[data-status="completed"] { --card-accent: var(--status-completed); }
article.order-card[data-status="cancelled"] { --card-accent: var(--status-cancelled); }
article.order-card[data-status="on_hold"]   { --card-accent: var(--status-on-hold); }
article.order-card[data-status="expired"]   { --card-accent: var(--status-expired); }

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--card-accent, var(--tg-hint));
}
.status-badge[data-status="checking"] { color: #1f1f1f; } /* yellow → тёмный текст */
.status-badge[data-status="expired"]  { color: #1f1f1f; }

/* Tab pill colored dot */
.tab-dot { width: 6px; height: 6px; border-radius: 999px; display: inline-block; }
.tab-dot[data-s="new"]       { background: var(--status-new); }
.tab-dot[data-s="in_work"]   { background: var(--status-in-work); }
.tab-dot[data-s="waiting"]   { background: var(--status-waiting); }
.tab-dot[data-s="checking"]  { background: var(--status-checking); }
.tab-dot[data-s="sending"]   { background: var(--status-sending); }
.tab-dot[data-s="completed"] { background: var(--status-completed); }
.tab-dot[data-s="cancelled"] { background: var(--status-cancelled); }
.tab-dot[data-s="on_hold"]   { background: var(--status-on-hold); }
.tab-dot[data-s="expired"]   { background: var(--status-expired); }

/* ─── Urgent / pulse states ─── */
@keyframes pulse-warn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}
@keyframes blink-urgent {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
article.order-card[data-status="on_hold"] {
  animation: pulse-warn 2s infinite;
}
article.order-card.urgent .status-badge {
  animation: blink-urgent 1.4s ease-in-out infinite;
}
article.order-card.urgent::before {
  width: 6px; /* акцентная полоса жирнее у горящих */
}

/* ─── Primary action button (Wizard) ─── */
.btn-primary-wizard {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  background: var(--btn-accent, var(--tg-button));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.btn-primary-wizard:active { transform: scale(0.98); }

.btn-secondary-wizard {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--tg-text);
}
.btn-dots {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 18px;
  line-height: 1;
  background: rgba(0, 0, 0, 0.05);
}

/* ─── Bottom sheet («⋯» меню вторичных действий) ─── */
.bsheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 180ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.bsheet {
  width: 100%;
  max-width: 480px;
  background: var(--tg-bg, #fff);
  border-radius: 16px 16px 0 0;
  padding: 12px 14px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp 220ms cubic-bezier(0.2, 0.7, 0.3, 1);
  max-height: 80vh;
  overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.bsheet-grip {
  width: 40px; height: 4px;
  background: var(--tg-hint);
  border-radius: 4px;
  margin: 4px auto 12px;
}
.bsheet-title {
  font-size: 12px;
  opacity: 0.55;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  padding: 0 6px;
}
.bsheet-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px;
  border-radius: 12px;
  background: var(--tg-secondary-bg, #f6f7f9);
  margin-bottom: 6px;
}
.bsheet-item:hover { background: rgba(0, 0, 0, 0.05); }
.bsheet-item .icon { font-size: 18px; line-height: 1.1; }
.bsheet-item .label { font-weight: 600; font-size: 14px; }
.bsheet-item .hint { font-size: 11px; opacity: 0.6; margin-top: 2px; }
.bsheet-item.destructive .label { color: #dc2626; }

/* ─── Heatmap (7×24) ─── */
.heatmap { display: grid; grid-template-columns: 32px repeat(24, 1fr); gap: 2px; font-size: 10px; }
.heatmap .cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: rgba(34, 197, 94, var(--alpha, 0));
  cursor: pointer;
}
.heatmap .day-lbl { display: flex; align-items: center; justify-content: flex-end; padding-right: 4px; opacity: 0.6; }
.heatmap .hr-lbl  { text-align: center; opacity: 0.4; font-size: 9px; }

/* ─── Dark scheme ─── */
html[data-tg-theme="dark"] {
  --tg-bg: #17212b;
  --tg-text: #f5f5f5;
  --tg-hint: #2a3a4c;
  --tg-secondary-bg: #1f2c3a;
  --tg-button: #5288c1;
  --tg-button-text: #ffffff;
  --tg-link: #6ab3f3;
}


/* ════════════════════════════════════════════════════════════════
   DESKTOP / широкий экран (Telegram Desktop, планшет) — [03.06.2026]
   Раньше @media не было: на компе всё тянулось на всю ширину, а табы
   статусов (overflow-x) мышью было не прокрутить → вкладки недостижимы.
   ════════════════════════════════════════════════════════════════ */
@media (min-width: 720px) {
  body { background: var(--tg-secondary-bg, #f6f7f9); }
  header { background: var(--tg-bg, #fff) !important; }
  header > div,
  header > nav,
  main { max-width: 820px; margin-left: auto; margin-right: auto; }
  header > nav { flex-wrap: wrap; overflow-x: visible; row-gap: 6px; }
  header > nav button { padding-top: 7px; padding-bottom: 7px; }
  main[x-show*="orders"] > .space-y-3 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
  }
  main[x-show*="orders"] > .space-y-3 > * { margin-top: 0 !important; }
  article.order-card { transition: box-shadow 140ms ease, transform 140ms ease; }
  article.order-card:hover { box-shadow: 0 4px 18px rgba(0,0,0,0.08); transform: translateY(-1px); }
}
@media (min-width: 1180px) {
  header > div, header > nav, main { max-width: 1120px; }
  main[x-show*="orders"] > .space-y-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
