/* botgarden admin — design system (v3 UI) */

:root {
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --sidebar-bg: #0f172a;
  --sidebar-bg-active: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-text-dim: #64748b;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --sidebar-width: 260px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); }

h1, h2, h3, h4 { margin: 0 0 var(--sp-3); line-height: 1.3; }
h2 { font-size: 22px; }
h3 { font-size: 16px; }

p { margin: 0 0 var(--sp-2); }

.muted { color: var(--muted); font-size: 13px; }
.ok { color: var(--success); }
.bad { color: var(--danger); }

/* ---------- layout shell ---------- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 50;
  transition: left .25s ease;
}

.sidebar .brand {
  font-weight: 700;
  color: #fff;
  font-size: 17px;
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
}

.brand-logo {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
  vertical-align: middle;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0 var(--sp-2);
  gap: 2px;
}

.sidebar-footer { margin-top: auto; padding-bottom: var(--sp-4); }

.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, .08);
  margin: var(--sp-3) var(--sp-4);
}

.nav-link {
  display: flex;
  align-items: center;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  min-height: 44px;
  border-left: 3px solid transparent;
}

.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  vertical-align: -4px;
}

.nav-link .icon, .dropdown-item .icon { margin-right: 8px; }
.brand .icon { width: 22px; height: 22px; }

.nav-link.active {
  background: var(--sidebar-bg-active);
  color: #fff;
  font-weight: 600;
  border-left-color: var(--accent);
}

.bot-group summary {
  cursor: pointer;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  list-style: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.bot-group summary::-webkit-details-marker { display: none; }
.bot-group summary .chevron {
  color: #cbd5e1;
  transition: transform .15s ease;
}
.bot-group[open] summary .chevron { transform: rotate(180deg); }
.bot-group summary:hover { background: rgba(255, 255, 255, .06); }

.bot-group .nav-link { margin-left: var(--sp-2); }

.bot-group + .bot-group { margin-top: var(--sp-1); }

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 40;
}

.content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: var(--sp-3) var(--sp-6);
}

.hamburger {
  display: none;
  cursor: pointer;
  font-size: 20px;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.hamburger:hover { background: var(--bg); }

.page-title { font-weight: 700; font-size: 16px; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--sp-6);
}

/* ---------- mobile off-canvas ---------- */

@media (max-width: 900px) {
  .sidebar { left: calc(-1 * var(--sidebar-width)); }
  #nav-toggle:checked ~ .sidebar { left: 0; }
  #nav-toggle:checked ~ .scrim { display: block; }
  .content { margin-left: 0; }
  .hamburger { display: inline-flex; }
  main { padding: var(--sp-4); }
}

/* ---------- cards ---------- */

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: var(--sp-4) var(--sp-6);
  margin-bottom: var(--sp-4);
}

.card h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  margin: 0 0 var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
}

.cards-grid .card { margin-bottom: 0; }

@media (max-width: 1023px) {
  .cards-grid { grid-template-columns: 1fr; }
}

.big-number { font-size: 28px; font-weight: 700; }

/* ---------- online status ---------- */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}

.status-ok { color: var(--success); }
.status-bad { color: var(--danger); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: status-pulse 1.6s ease-in-out infinite;
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(22, 163, 74, .35); }
  50% { opacity: .45; box-shadow: 0 0 0 4px rgba(22, 163, 74, 0); }
}

.status-bad .status-dot { animation: none; }

/* ---------- card actions / dropdown ---------- */

.card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.dropdown { position: relative; }

.dropdown summary { list-style: none; }
.dropdown summary::-webkit-details-marker { display: none; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
  min-width: 200px;
  z-index: 40;
  padding: 4px;
  display: flex;
  flex-direction: column;
}

.dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--text);
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  min-height: 44px;
  text-decoration: none;
}

.dropdown-item:hover { background: #f1f5f9; }
.dropdown-item.danger { color: var(--danger); }

.dropdown-menu form { margin: 0; }

/* ---------- buttons ---------- */

.btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: var(--sp-2) var(--sp-4);
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease;
}

.btn:hover, button:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--bg); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

.btn-ok { background: var(--success); }
.btn-ok:hover { background: #15803d; }

/* ---------- badges ---------- */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #eef2ff;
  color: #3730a3;
}

.badge-ok { background: var(--success-bg); color: var(--success-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-muted { background: #f1f5f9; color: var(--muted); font-weight: 500; }

/* ---------- forms ---------- */

.form-row { margin-bottom: var(--sp-4); }

.form-row label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: var(--sp-1);
}

.form-row .muted { display: block; font-weight: 400; margin-top: 2px; }

input[type=text], input[type=number], input[type=file],
input[type=datetime-local], textarea, select {
  width: 100%;
  min-height: 44px;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--card-bg);
  color: var(--text);
}

textarea { min-height: unset; resize: vertical; }

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.inline-form { display: inline; }

/* ---------- flash messages ---------- */

.flash-ok, .flash-error {
  border-radius: var(--radius-sm);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  font-weight: 500;
  border-left: 4px solid transparent;
}

.flash-ok { background: var(--success-bg); color: var(--success-text); border-left-color: var(--success); }
.flash-error { background: var(--danger-bg); color: var(--danger-text); border-left-color: var(--danger); }

/* ---------- empty state ---------- */

.empty {
  text-align: center;
  color: var(--muted);
  padding: var(--sp-8) var(--sp-4);
  font-size: 15px;
}

.empty .empty-emoji { font-size: 32px; display: block; margin-bottom: var(--sp-2); }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }

.table-wrap table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
}

.table-wrap th, .table-wrap td {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.table-wrap th { color: var(--muted); font-weight: 600; }
.table-wrap th a { color: var(--muted); text-decoration: none; }
.table-wrap th a:hover { color: var(--text); }

pre {
  background: #f1f5f9;
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 12px;
}

/* ---------- переключатель периода (страница «Ресурсы») ---------- */

.period-switch {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.period-switch a, .period-switch .current {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  text-decoration: none;
}

.period-switch a:hover { background: var(--bg); }

.period-switch .current {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ---------- auth page ---------- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
}

.auth-card { max-width: 380px; width: 100%; text-align: center; }
.auth-brand { font-size: 20px; font-weight: 700; margin-bottom: var(--sp-3); }
.auth-brand .icon { width: 22px; height: 22px; }
