/* Moomkin Socialbot dashboard — bitta qo'lda yozilgan CSS, framework yo'q.
   Qoida: accent = amallar, status ranglari = holatlar, hech qachon aralashmaydi. */

:root {
  --bg: #F8F7F5;
  --surface: #FFFFFF;
  --border: #E7E4E0;
  --ink: #1C1917;
  --ink-2: #78716C;
  --accent: #FF3355;
  --accent-ink: #FFFFFF;
  --accent-soft: #FFE7EC;
  --danger: #B91C1C;
  --ok: #15803D;
  /* status: text on tint */
  --st-new: #B45309;      --st-new-bg: #FEF3C7;
  --st-replied: #15803D;  --st-replied-bg: #DCFCE7;
  --st-filtered: #B91C1C; --st-filtered-bg: #FEE2E2;
  --st-skipped: #4B5563;  --st-skipped-bg: #F3F4F6;
  --st-error: #6D28D9;    --st-error-bg: #EDE9FE;
  --radius: 12px;
  --radius-s: 6px;
  --shadow: 0 1px 3px rgb(28 25 23 / 0.07);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 700; margin: 0 0 16px; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 12px; }
.muted { color: var(--ink-2); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── Top strip ─────────────────────────────────────────────── */
.topstrip {
  display: flex; align-items: center; gap: 12px;
  height: 48px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; }
.page-title { color: var(--ink-2); flex: 1; }
.logout-form { margin: 0; }

/* ── Nav: desktop top bar / mobile bottom tabs ─────────────── */
.mainnav {
  display: flex; gap: 4px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 12px;
}
.mainnav a {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 14px; min-height: 44px;
  color: var(--ink-2); font-weight: 500; text-decoration: none;
  border-bottom: 2px solid transparent; position: relative;
}
.mainnav a:hover { color: var(--ink); text-decoration: none; }
.mainnav a.active { color: var(--accent); border-bottom-color: var(--accent); }
.badge-count {
  background: var(--danger); color: #fff;
  font-size: 12px; font-weight: 600; line-height: 1;
  padding: 3px 7px; border-radius: 999px;
}
.badge-count.zero { display: none; }

.content { max-width: 1040px; margin: 0 auto; padding: 24px 16px 96px; }

@media (max-width: 767px) {
  .mainnav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    border-top: 1px solid var(--border); border-bottom: none;
    padding: 0; justify-content: space-around;
  }
  .mainnav a {
    flex-direction: column; gap: 2px; font-size: 11px;
    padding: 8px 4px; flex: 1; justify-content: center;
    border-bottom: none; border-top: 2px solid transparent;
  }
  .mainnav a.active { border-top-color: var(--accent); }
  .mainnav .ico { font-size: 18px; }
  .badge-count { position: absolute; top: 4px; right: 50%; transform: translateX(18px); }
  body { padding-bottom: 72px; }
}
@media (min-width: 768px) {
  .mainnav .ico { display: none; }
}

/* ── Cards / buttons ───────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px;
}
button, .btn-primary, .btn-ghost, .btn-danger {
  font: inherit; cursor: pointer; border-radius: var(--radius-s);
  min-height: 40px; padding: 8px 16px; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { filter: brightness(0.95); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--ink); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--surface); border-color: var(--st-filtered); color: var(--danger); }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
@media (max-width: 767px) { button, .btn-primary, .btn-ghost, .btn-danger { min-height: 44px; } }

/* ── Status badges ─────────────────────────────────────────── */
.badge {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 4px 8px; border-radius: 999px; white-space: nowrap;
}
.badge.st-new      { color: var(--st-new);      background: var(--st-new-bg); }
.badge.st-replied  { color: var(--st-replied);  background: var(--st-replied-bg); }
.badge.st-filtered { color: var(--st-filtered); background: var(--st-filtered-bg); }
.badge.st-skipped  { color: var(--st-skipped);  background: var(--st-skipped-bg); }
.badge.st-error    { color: var(--st-error);    background: var(--st-error-bg); }

/* ── Login page ────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 32px; width: min(360px, 90vw);
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card label { display: block; margin: 16px 0 6px; font-weight: 500; }
.login-card input {
  width: 100%; font: inherit; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-s);
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.login-card .btn-primary { width: 100%; margin-top: 16px; }
.login-error {
  color: var(--danger); background: var(--st-filtered-bg);
  padding: 8px 12px; border-radius: var(--radius-s); font-size: 14px;
}

/* ── Toast ─────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 50; padding: 10px 20px; border-radius: 999px;
  font-weight: 500; box-shadow: 0 4px 12px rgb(28 25 23 / 0.2);
}
#toast.good { background: var(--ink); color: #fff; }
#toast.bad { background: var(--danger); color: #fff; }
@media (max-width: 767px) { #toast { bottom: 84px; } }

/* ── Forms ─────────────────────────────────────────────────── */
textarea {
  width: 100%; font: inherit; line-height: 1.6;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-s);
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

/* HTMX loading holati */
.htmx-request { opacity: 0.5; transition: opacity 150ms; }

/* ── KPI kartalar ──────────────────────────────────────────── */
.kpi-grid {
  display: grid; gap: 12px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.kpi { display: flex; flex-direction: column; gap: 4px; margin-bottom: 0; color: inherit; }
a.kpi:hover { text-decoration: none; border-color: var(--accent); }
.kpi-alert { border-left: 4px solid var(--danger); }
.kpi-label { font-size: 13px; color: var(--ink-2); }
.kpi-num { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-num.danger { color: var(--danger); }
.kpi-small { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.kpi-sub { font-size: 13px; color: var(--ink-2); }
.gauge { display: block; height: 6px; background: var(--st-skipped-bg); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.gauge-fill { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.gauge-fill.amber { background: var(--st-new); }
.gauge-fill.red { background: var(--danger); }

/* ── Grafiklar ─────────────────────────────────────────────── */
.chart-pair { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 767px) { .chart-pair { grid-template-columns: 1fr; } }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; }

/* ── Faoliyat lentasi ──────────────────────────────────────── */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.feed li:last-child { border-bottom: none; }
.feed-author { font-weight: 600; white-space: nowrap; }
.feed-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.feed-time { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
@media (max-width: 767px) { .feed-time { display: none; } }

/* ── Filtr paneli ──────────────────────────────────────────── */
.filterbar {
  position: sticky; top: 48px; z-index: 10;
  background: var(--bg); padding: 8px 0 12px; margin-bottom: 8px;
}
.pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 14px; border-radius: 999px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--ink); font-size: 14px; font-weight: 500;
}
.pill small { color: var(--ink-2); font-size: 12px; }
.pill:hover { text-decoration: none; border-color: var(--accent); }
.pill.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.pill.active small { color: var(--accent); }
.filter-form { display: flex; gap: 8px; }
.filter-form input[type="search"] {
  flex: 1; font: inherit; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface);
}
.filter-form select {
  font: inherit; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface);
}

/* ── Izoh qatorlari ────────────────────────────────────────── */
.comment-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px;
  cursor: pointer;
  display: flex; gap: 12px; align-items: flex-start;
}
.comment-row:hover { border-color: var(--accent); }
.row-body { flex: 1; min-width: 0; }  /* min-width:0 → text clamp works inside flex */
.row-thumb {
  position: relative; flex-shrink: 0; display: block;
  width: 112px; height: 63px; border-radius: var(--radius-s);
  overflow: hidden; background: var(--st-skipped-bg);
}
.row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-thumb .play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; text-shadow: 0 1px 4px rgb(0 0 0 / 0.7); opacity: 0.9;
}
.row-thumb:hover .play { opacity: 1; }
@media (max-width: 767px) { .row-thumb { width: 88px; height: 50px; } }
.row-line1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-author { font-weight: 600; }
.row-time { margin-left: auto; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.row-text {
  margin: 6px 0 4px; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.row-meta { font-size: 13px; color: var(--ink-2); margin: 4px 0 0; }
.load-more { display: block; width: 100%; margin-top: 8px; }
.list-end { text-align: center; padding: 12px; }

/* ── Detal paneli ──────────────────────────────────────────── */
.detail { background: var(--bg); margin: -4px 0 8px; }
.detail-text { white-space: pre-wrap; margin-top: 0; }
.reply-quote {
  margin: 8px 0; padding: 8px 12px;
  background: var(--st-replied-bg); border-left: 3px solid var(--st-replied);
  border-radius: var(--radius-s);
}
.reply-quote p { margin: 0 0 4px; }
.reply-quote footer { font-size: 12px; }
.detail-actions { display: flex; align-items: center; gap: 16px; margin-top: 8px; }

/* ── Video kartalar ────────────────────────────────────────── */
.video-title { font-weight: 600; color: var(--ink); }
.video-title:hover { color: var(--accent); }
.video-summary { margin: 8px 0; font-size: 14px; color: var(--ink-2); }
.video-summary summary { cursor: pointer; list-style: none; }
.video-summary[open] summary { display: none; }
.video-summary p { white-space: pre-wrap; }
.held-note { color: var(--danger); }

/* ── Kutish navbati ────────────────────────────────────────── */
.queue-sub { margin-top: -8px; }
.held-card { border-left: 3px solid var(--st-filtered); }
.held-card.held-error { border-left-color: var(--st-error); }
.held-text { white-space: pre-wrap; margin: 8px 0; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.reply-open { flex-direction: column; align-items: stretch; }
.reply-open form { display: flex; flex-direction: column; gap: 6px; }
.form-actions { display: flex; gap: 8px; }
.form-error {
  color: var(--danger); background: var(--st-filtered-bg);
  padding: 8px 12px; border-radius: var(--radius-s); font-size: 14px; margin: 0 0 4px;
}
@media (max-width: 767px) {
  .form-actions { flex-direction: column; }
  .form-actions button { width: 100%; }
}
.held-stub {
  background: var(--st-replied-bg); color: var(--st-replied);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px;
  font-weight: 500; overflow: hidden;
  animation: stub-collapse 4s ease forwards;
}
@keyframes stub-collapse {
  0%, 70% { opacity: 1; max-height: 60px; }
  100% { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; margin-bottom: 0; }
}
.empty-emoji { font-size: 48px; margin: 0; }

/* ── Sozlamalar ────────────────────────────────────────────── */
.settings-card { max-width: 720px; }
.warn-banner {
  background: var(--st-new-bg); color: var(--st-new);
  padding: 10px 14px; border-radius: var(--radius-s);
  font-size: 14px; margin-bottom: 12px;
}
.settings-card textarea { min-height: 320px; }
.settings-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }

/* ── Bo'sh holatlar ────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 16px; color: var(--ink-2); }
.empty-state.big { font-size: 17px; }
