/* Reveo Diktofon — the shell and the shared primitives.
 *
 * Every colour, face, radius and shadow below is a custom property from
 * reveo-tokens.css. That file is Reveo's design system copied token for token
 * from reveo-suhbat; NOTHING here defines a colour of its own, because a
 * product-local hex is exactly how two Reveo products drift apart until
 * somebody moving between call.reveo.uz and diktofon.reveo.uz thinks they
 * changed vendor. If a value is missing, it gets added to kit.css upstream and
 * re-synced — not invented here.
 *
 * The @import is a safety net: index.html also links the token sheet, before
 * this file, so it is fetched in parallel. The import means app.css still
 * resolves if that link is ever dropped.
 *
 * The four surfaces live in pages.css, which loads after this file and depends
 * on it. No preprocessor and no CDN beyond the two webfonts: this is an
 * internal tool, read for eight hours a day by people looking for one
 * recording, so it is tuned for density and legibility over decoration. */

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

:root {
  /* Product shape, on top of the system's. The token sheet's --radius is 20px,
   * which is right for a marketing card and too round for a dense table of one
   * recording per row; the smaller two are the same scale, chosen per element
   * rather than redefined. */
  --topbar-h: 56px;
}

* {
  box-sizing: border-box;
}

/* The UA rule for [hidden] is `display: none`, which any class setting a
 * display value outranks — a hidden .btn (inline-flex) stays on screen. This
 * makes `el.hidden = true` mean what it says everywhere. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-b);
  font-size: var(--t-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-d);
  letter-spacing: -0.015em;
}

a {
  color: var(--brand-ink);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* Numbers you compare down a column get tabular figures. Nothing in this
 * product is set in mono because nothing is over in Suhbat either — except
 * identifiers you read left to right rather than magnitudes you compare, which
 * here means filenames and hashes. */
.num {
  font-variant-numeric: tabular-nums;
}
.mono {
  font-family: var(--font-m);
  font-size: 0.94em;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-d);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-size: 15.5px;
}
.mark:hover {
  text-decoration: none;
}
.mark-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.nav {
  display: flex;
  gap: 2px;
}
.nav a {
  padding: 6px 11px;
  border-radius: var(--radius-xs);
  color: var(--ink-2);
  font-weight: 600;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.nav a:hover {
  background: var(--surface-hover);
  color: var(--ink);
  text-decoration: none;
}
.nav a[aria-current='page'] {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-2);
  min-width: 0;
}
.whoami {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 34ch;
}

/* ── The live indicator ──────────────────────────────────────────────────── */

/* Quiet on purpose. A stream that is working is not news and must not compete
 * with the page; a stream that has dropped is, because every row on screen is
 * then a snapshot of some earlier moment and nothing will say so on its own. */
.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-small);
  color: var(--ink-3);
  white-space: nowrap;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  flex: none;
}
.live[data-state='reconnecting'] {
  color: var(--amber);
}
.live[data-state='reconnecting'] .live-dot {
  background: var(--amber);
  animation: live-pulse 1.4s ease-in-out infinite;
}
.live[data-state='offline'] {
  color: var(--red-ink);
}
.live[data-state='offline'] .live-dot {
  background: var(--red);
}
/* Connected is a dot and no words: the label would be furniture on every page
 * load, and the state that needs a sentence is the one that has none. */
.live[data-state='live'] .live-label {
  display: none;
}

@keyframes live-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

.view {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

.page-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 16px;
}
.page-head h1 {
  font-size: var(--t-h1);
  font-weight: 600;
  margin: 0;
}
.page-head .count {
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.page-head .spacer {
  margin-left: auto;
}

.loading {
  color: var(--ink-3);
  padding: 24px 16px;
}

.noscript {
  padding: 24px;
  color: var(--ink-2);
  font-family: var(--font-b);
}

/* ── Controls ────────────────────────────────────────────────────────────── */

input,
select,
button,
textarea {
  font: inherit;
  color: inherit;
}

.input,
.select {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-xs);
  padding: 7px 10px;
  min-width: 0;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.input:hover,
.select:hover {
  border-color: var(--line-strong);
}
.input:focus,
.select:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.btn:focus-visible,
.row:focus-visible,
.input:focus-visible,
.select:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* «Chiqish» wrapping to two lines inside a fixed-height top bar broke the
   * row at 390px. Nothing in this bar wraps. */
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-xs);
  padding: 7px 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease),
    box-shadow 0.16s var(--ease);
}
.btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--line-strong);
}
.btn:active:not(:disabled) {
  transform: translateY(0.5px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-ink);
  border-color: var(--brand-ink);
}
.btn-danger {
  color: var(--red-ink);
  border-color: var(--line-2);
}
.btn-danger:hover:not(:disabled) {
  background: var(--red-soft);
  border-color: var(--red);
}
.btn-sm {
  padding: 4px 9px;
  font-size: var(--t-small);
}

/* ── Chips ───────────────────────────────────────────────────────────────── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--pill);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.chip-ok {
  background: var(--green-soft);
  border-color: transparent;
  color: var(--green);
}
.chip-warn {
  background: var(--amber-soft);
  border-color: transparent;
  color: var(--amber);
}
.chip-danger {
  background: var(--red-soft);
  border-color: transparent;
  color: var(--red-ink);
}
.chip-accent {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand-ink);
}
.chip-info {
  background: var(--blue-soft);
  border-color: transparent;
  color: var(--blue);
}
.chip-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ── Progress ────────────────────────────────────────────────────────────── */

/* One bar shape, used on a list row and on the detail page. The fill is
 * transitioned rather than snapped because a chunk landing every second or two
 * otherwise reads as a bar that is broken and jumping. */
.progress {
  height: 4px;
  border-radius: var(--pill);
  background: var(--line-2);
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--brand);
  transition: width 0.35s var(--ease);
}
/* A transfer with no declared total cannot honestly claim a percentage, so it
 * says «something is moving» instead of guessing one. */
.progress[data-indeterminate='true'] > i {
  width: 35%;
  animation: progress-slide 1.3s ease-in-out infinite;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(320%);
  }
}

/* ── Empty, error and banner states ──────────────────────────────────────── */

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--ink-2);
}
.empty h2 {
  font-size: var(--t-h2);
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 6px;
}
.empty p {
  margin: 0 auto;
  max-width: 56ch;
}

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 13px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  background: var(--surface-2);
  margin-bottom: 14px;
}
.banner-danger {
  background: var(--red-soft);
  border-color: transparent;
  color: var(--red-ink);
}
.banner-warn {
  background: var(--amber-soft);
  border-color: transparent;
  color: var(--amber);
}
.banner-ok {
  background: var(--green-soft);
  border-color: transparent;
  color: var(--green);
}
.banner .close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
  padding: 0 2px;
}
.banner .close:hover {
  opacity: 1;
}

/* ── Toasts ──────────────────────────────────────────────────────────────── */

/* Bottom-left, not top-right: the top-right corner of this page is the
 * identity and the sign-out button, and a stack of notices over it during a
 * busy sync covers the one control somebody may be reaching for. */
.toasts {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.24s var(--ease);
}
.toast-title {
  font-family: var(--font-d);
  font-weight: 600;
  color: var(--ink);
}
.toast-body {
  min-width: 0;
}
.toast-detail {
  color: var(--ink-2);
  font-size: var(--t-small);
  margin-top: 2px;
}
.toast-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 7px;
  flex: none;
  background: var(--ink-4);
}
.toast[data-tone='ok'] .toast-icon {
  background: var(--brand);
}
.toast[data-tone='warn'] .toast-icon {
  background: var(--amber);
}
.toast[data-tone='danger'] .toast-icon {
  background: var(--red);
}
.toast .close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-3);
  padding: 0 2px;
  line-height: 1;
}
.toast .close:hover {
  color: var(--ink);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ── Responsive: the shell ───────────────────────────────────────────────── */

@media (max-width: 720px) {
  .topbar {
    gap: 10px;
    padding: 0 10px;
  }
  /* The identity is the first thing to go: on a phone the nav is what the top
   * bar is for, and the reader already knows who they are and what they may
   * do — the admin-only controls are on the page itself either way. The live
   * dot stays, because a dropped stream is a fact about the page. */
  .whoami,
  .topbar-right .chip-accent {
    display: none;
  }
  .view {
    padding: 14px 10px 48px;
  }
  .toasts {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
  }
}

/* Respect a reader who has asked for less motion; nothing here is essential. */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
