/* ============================================================
   Конкурс-бот — дизайн кабинета (поверх Bootstrap 5)
   ============================================================ */

:root {
  --brand: #6366f1;
  --brand-dark: #4f46e5;
  --brand-soft: #eef0ff;
  --ink: #0f172a;
  --ink-soft: #64748b;
  --bg: #f4f5fb;
  --card: #ffffff;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
}

html, body { height: 100%; }
body {
  background: var(--bg) !important;
  color: var(--ink);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
}

/* ---------- каркас: сайдбар + контент ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; flex-shrink: 0;
  background: linear-gradient(180deg, #111827 0%, #1e1b4b 100%);
  color: #cbd5e1;
  display: flex; flex-direction: column;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  color: #fff; font-weight: 700; font-size: 1.15rem;
  text-decoration: none; padding: 6px 12px 18px;
  display: flex; align-items: center; gap: 10px;
}
.sidebar .brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #a855f7);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  color: #94a3b8; text-decoration: none;
  padding: 10px 12px; border-radius: 10px;
  display: flex; align-items: center; gap: 10px;
  font-weight: 500; transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .user-box {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 14px 12px 4px; font-size: .9rem;
}
.sidebar .user-box .name { color: #e2e8f0; font-weight: 600; }
.sidebar .user-box a { color: #94a3b8; text-decoration: none; }
.sidebar .user-box a:hover { color: #fff; }

.content { flex: 1; min-width: 0; padding: 32px 36px 64px; }
.content > .container { max-width: 1200px; margin: 0; padding: 0; }

/* мобильные: сайдбар превращается в верхнюю панель */
@media (max-width: 991px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: row; align-items: center; gap: 8px;
    padding: 10px 14px;
  }
  .sidebar .brand { padding: 0 8px 0 0; }
  .sidebar nav { flex-direction: row; }
  .sidebar nav a { padding: 8px 10px; }
  .sidebar .spacer { display: none; }
  .sidebar .user-box { border: 0; padding: 0; margin-left: auto; }
  .content { padding: 20px 16px 48px; }
}

/* ---------- заголовки страниц ---------- */
h1 { font-weight: 700; font-size: 1.65rem; letter-spacing: -.02em; }
h2 { font-weight: 700; letter-spacing: -.01em; }

/* ---------- карточки ---------- */
.card {
  border: 0 !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  background: transparent !important;
  border-bottom: 1px solid #eef0f5 !important;
  font-weight: 600; color: var(--ink);
  padding: 14px 20px;
}
.card-body { padding: 20px; }
.card.border-danger { box-shadow: 0 0 0 1px #fecaca, var(--shadow); }

/* ---------- кнопки ---------- */
.btn { border-radius: 10px; font-weight: 600; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border: 0;
}
.btn-primary:hover { filter: brightness(1.08); background: var(--brand-dark); }
.btn-success { background: #10b981; border: 0; }
.btn-success:hover { background: #059669; }
.btn-warning { background: #f59e0b; border: 0; color: #fff; }
.btn-warning:hover { background: #d97706; color: #fff; }
.btn-info { background: #06b6d4; border: 0; color: #fff; }
.btn-info:hover { background: #0891b2; color: #fff; }
.btn-outline-primary { color: var(--brand); border-color: #d9dcff; }
.btn-outline-primary:hover { background: var(--brand-soft); color: var(--brand-dark); border-color: var(--brand); }
.btn-outline-secondary { border-color: #e2e8f0; color: var(--ink-soft); }
.btn-outline-secondary:hover { background: #f1f5f9; color: var(--ink); border-color: #cbd5e1; }

/* ---------- таблицы ---------- */
.table {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  --bs-table-bg: var(--card);
}
.table thead th {
  background: #f8fafc; color: var(--ink-soft);
  font-size: .78rem; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid #eef0f5; padding: 12px 16px;
}
.table tbody td { padding: 13px 16px; border-color: #f1f5f9; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8faff; }

/* ---------- бейджи статусов ---------- */
.badge { border-radius: 999px; font-weight: 600; padding: .45em .9em; }
.badge.bg-success { background: #dcfce7 !important; color: #15803d; }
.badge.bg-secondary { background: #f1f5f9 !important; color: #64748b; }
.badge.bg-info { background: #e0f2fe !important; color: #0369a1; }
.badge.bg-primary { background: var(--brand-soft) !important; color: var(--brand-dark); }
.badge.bg-dark { background: #e2e8f0 !important; color: #334155; }
.badge.bg-danger { background: #fee2e2 !important; color: #b91c1c; }

/* ---------- формы ---------- */
.form-control, .form-select {
  border-radius: 10px; border-color: #e2e8f0; padding: .55rem .8rem;
}
/* стрелка выпадающих списков: рисуем сами, явно и без сюрпризов */
.form-select {
  padding-right: 2.5rem;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23475569' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
  background-repeat: no-repeat !important;
  background-position: right .8rem center !important;
  background-size: 14px 11px !important;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem rgba(99, 102, 241, .15);
}
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-label { font-weight: 600; color: var(--ink); }
.form-text, .text-muted { color: var(--ink-soft) !important; }

/* ---------- алерты ---------- */
.alert { border: 0; border-radius: 12px; box-shadow: var(--shadow); }
.alert-danger { background: #fef2f2; color: #b91c1c; }
.alert-warning { background: #fffbeb; color: #b45309; }
.alert-success { background: #f0fdf4; color: #15803d; }

/* ---------- каталог ботов ---------- */
.bot-card {
  height: 100%;
  transition: transform .15s ease, box-shadow .15s ease;
}
.bot-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(15,23,42,.05), 0 16px 40px rgba(99,102,241,.14);
}
.bot-card .bot-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--brand-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; margin-bottom: 14px;
}
.bot-card .card-title { font-weight: 700; }
.bot-card .desc { color: var(--ink-soft); font-size: .9rem; min-height: 3em; }

/* ---------- иконки-действия в таблицах ---------- */
.icon-btn {
  border: 0; background: transparent;
  padding: 6px 8px; border-radius: 8px;
  font-size: 1.05rem; line-height: 1; cursor: pointer;
  display: inline-block; vertical-align: middle;
}
.icon-btn:hover { background: var(--brand-soft); }

/* ---------- вкладки статусов ---------- */
.nav-tabs { border-bottom: 1px solid #e2e8f0; }
.nav-tabs .nav-link {
  border: 0; color: var(--ink-soft); font-weight: 600;
  padding: 10px 18px; background: transparent;
}
.nav-tabs .nav-link:hover { color: var(--ink); }
.nav-tabs .nav-link.active {
  color: var(--brand-dark); background: transparent;
  box-shadow: inset 0 -2px 0 var(--brand);
}
.nav-tabs .nav-link .badge { font-size: .7rem; }

/* ---------- поиск ---------- */
.search-box { max-width: 280px; }

/* модальные окна (наши самодельные) */
#schedule-modal .card, #cycle-modal .card, #csv-modal .card, #replies-modal .card {
  border-radius: var(--radius) !important;
}

/* подсказка «доступные переменные» в редакторе ответов */
.var-hint { background: #d6f3f8; color: #0f172a; }

/* ---------- переключатель темы (низ сайдбара) ---------- */
.theme-switch {
  display: flex; gap: 4px;
  background: rgba(255,255,255,.06);
  border-radius: 10px; padding: 4px;
  margin: 0 8px 10px;
  width: fit-content;
}
.theme-btn {
  border: 0; background: transparent; cursor: pointer;
  font-size: .95rem; line-height: 1;
  padding: 7px 10px; border-radius: 8px;
  opacity: .55; transition: opacity .15s, background .15s;
}
.theme-btn:hover { opacity: 1; }
.theme-btn.active { background: var(--brand); opacity: 1; }
@media (max-width: 991px) {
  .theme-switch { margin: 0 6px 0 auto; }
}

/* ============================================================
   ТЁМНАЯ ТЕМА (включается data-theme="dark" на <html>)
   ============================================================ */
[data-theme="dark"] {
  --ink: #e2e8f0;
  --ink-soft: #94a3b8;
  --bg: #0b1220;
  --card: #151e30;
  --brand-soft: rgba(99, 102, 241, .18);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}
[data-theme="dark"] body { background: var(--bg) !important; color: var(--ink); }
[data-theme="dark"] .card { background: var(--card); color: var(--ink); }
[data-theme="dark"] .card-header { border-bottom-color: #24304a !important; color: var(--ink); }
[data-theme="dark"] .table {
  --bs-table-bg: var(--card);
  --bs-table-color: var(--ink);
  --bs-table-hover-color: var(--ink);
  color: var(--ink);
}
[data-theme="dark"] .table thead th {
  background: #101828; color: var(--ink-soft); border-bottom-color: #24304a;
}
[data-theme="dark"] .table tbody td { border-color: #1f2a40; }
[data-theme="dark"] .table-hover tbody tr:hover { background: #1a2438; }
[data-theme="dark"] .form-control, [data-theme="dark"] .form-select,
[data-theme="dark"] textarea.form-control {
  background: #0f172a; border-color: #2b3650; color: var(--ink);
}
[data-theme="dark"] .form-control::placeholder { color: #64748b; }
/* светлая стрелка выпадающих списков для тёмной темы */
[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23cbd5e1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
}
[data-theme="dark"] .form-label { color: var(--ink); }
[data-theme="dark"] .btn-outline-secondary { border-color: #334155; color: #94a3b8; }
[data-theme="dark"] .btn-outline-secondary:hover { background: #1e293b; color: #e2e8f0; }
[data-theme="dark"] .btn-outline-primary { border-color: #3b3f77; }
[data-theme="dark"] .nav-tabs { border-bottom-color: #24304a; }
[data-theme="dark"] .alert-danger { background: #2a1216; color: #fca5a5; }
[data-theme="dark"] .alert-warning { background: #2a2110; color: #fcd34d; }
[data-theme="dark"] .alert-success { background: #0e2419; color: #86efac; }
[data-theme="dark"] .badge.bg-success { background: #14331f !important; color: #4ade80; }
[data-theme="dark"] .badge.bg-secondary { background: #1e293b !important; color: #94a3b8; }
[data-theme="dark"] .badge.bg-info { background: #0c2a3a !important; color: #38bdf8; }
[data-theme="dark"] .badge.bg-primary { background: #1d1f45 !important; color: #a5b4fc; }
[data-theme="dark"] .badge.bg-dark { background: #1e293b !important; color: #cbd5e1; }
[data-theme="dark"] .badge.bg-danger { background: #331416 !important; color: #f87171; }
[data-theme="dark"] .icon-btn { color: #cbd5e1; }
[data-theme="dark"] .icon-btn:hover { background: #26314b; }
[data-theme="dark"] .bot-card .bot-icon { background: #26314b; }
[data-theme="dark"] .var-hint { background: #10344a; color: #bae6fd; }
[data-theme="dark"] a { color: #8ab4f8; }
[data-theme="dark"] .btn { color: #fff; }
[data-theme="dark"] .btn-outline-primary { color: #a5b4fc; }
[data-theme="dark"] .btn-outline-danger { color: #f87171; }
[data-theme="dark"] .card.border-danger { box-shadow: 0 0 0 1px #7f1d1d, var(--shadow); }
[data-theme="dark"] .form-check-input { background-color: #1e293b; border-color: #334155; }
[data-theme="dark"] .form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
