/* ============================================================
   GiftBot admin — яркая светлая тема (вдохновлено socialpost.ru)
   Электрик-синий + коралл + полный спектр градиентов.
   Контракт классов из app.js сохранён; легаси-переменные —
   алиасы на новую палитру (инлайн-стили в app.js не ломаются).
   ============================================================ */

:root {
  /* спектр */
  --blue:   #3b6ef6;
  --indigo: #6d5efc;
  --violet: #8b5cf6;
  --coral:  #ff5d6c;
  --pink:   #ff6bce;
  --green:  #14c79a;
  --teal:   #0fb9c9;
  --amber:  #ffb02e;
  --cyan:   #21c7e6;

  /* поверхности (светлая тема) */
  --bg:       #e9eefb;
  --ink:      #18203c;
  --muted:    #6b76a0;
  --surface:  #ffffff;
  --panel:    #ffffff;       /* legacy */
  --panel-2:  #f3f6fe;       /* legacy (инпуты, вложенные карточки) */
  --line:     #e5eaf7;       /* legacy (бордеры) */
  --text:     #18203c;       /* legacy */
  --accent:   #3b6ef6;       /* legacy */
  --accent-2: #14c79a;       /* legacy */
  --danger:   #ff5d6c;       /* legacy */
  --warn:     #ffb02e;       /* legacy */

  /* градиенты */
  --grad-primary: linear-gradient(135deg, #5b8cff 0%, #6d5efc 100%);
  --grad-ok:      linear-gradient(135deg, #2fe0a6 0%, #14b890 100%);
  --grad-danger:  linear-gradient(135deg, #ff8a93 0%, #ff5d6c 100%);
  --grad-brand:   linear-gradient(120deg, #3b6ef6 0%, #6d5efc 45%, #ff5d6c 100%);

  --grad-s1: linear-gradient(135deg, #5b8cff, #3b6ef6);
  --grad-s2: linear-gradient(135deg, #9b7bff, #6d5efc);
  --grad-s3: linear-gradient(135deg, #ff8aa0, #ff5d6c);
  --grad-s4: linear-gradient(135deg, #38e0a8, #12b58c);
  --grad-s5: linear-gradient(135deg, #ffc24d, #ff9a2e);
  --grad-s6: linear-gradient(135deg, #44d6f1, #1fb6d6);

  --radius:    16px;
  --radius-lg: 22px;
  --shadow:    0 14px 38px rgba(43, 66, 130, .12);
  --shadow-sm: 0 6px 18px rgba(43, 66, 130, .09);
  --shadow-color: 0 10px 24px rgba(59, 110, 246, .30);
  --ring: 0 0 0 4px rgba(59, 110, 246, .16);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(59, 110, 246, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 110, 246, .05) 1px, transparent 1px);
  background-size: 34px 34px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
/* мягкие цветные «облака» на фоне */
body::before, body::after {
  content: ""; position: fixed; z-index: 0; pointer-events: none;
  width: 46vw; height: 46vw; border-radius: 50%; filter: blur(70px); opacity: .5;
}
body::before { top: -14vw; right: -10vw; background: radial-gradient(circle, #b9c8ff, transparent 65%); }
body::after  { bottom: -16vw; left: -12vw; background: radial-gradient(circle, #ffc2cf, transparent 65%); }

#login, #app { position: relative; z-index: 1; }

a { color: var(--blue); text-decoration: none; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

/* ---------- кнопки ---------- */
button {
  font: inherit; font-weight: 600; cursor: pointer; border: none;
  border-radius: 11px; padding: 9px 16px; color: #fff;
  background: var(--grad-primary); box-shadow: var(--shadow-color);
  transition: transform .14s ease, box-shadow .14s ease, filter .14s ease;
}
button:hover { transform: translateY(-1px); filter: brightness(1.04); box-shadow: 0 14px 30px rgba(59, 110, 246, .38); }
button:active { transform: translateY(0); }
button.ghost {
  background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--line); box-shadow: var(--shadow-sm);
}
button.ghost:hover { border-color: #c9d4f3; box-shadow: var(--shadow); }
button.danger { background: var(--grad-danger); box-shadow: 0 10px 24px rgba(255, 93, 108, .32); }
button.ok { background: var(--grad-ok); color: #03291f; box-shadow: 0 10px 24px rgba(20, 199, 154, .32); }
button.sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }

input, textarea, select {
  font: inherit; width: 100%; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line);
  border-radius: 11px; padding: 11px 13px; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
textarea { min-height: 96px; resize: vertical; }
label { display: block; margin: 12px 0 5px; color: var(--muted); font-size: 13px; font-weight: 600; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 130px; }
.checkbox { display: flex; align-items: center; gap: 9px; margin: 9px 0; }
.checkbox input, .chip input { width: auto; accent-color: var(--blue); transform: scale(1.15); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- раскладка: шапка + сайдбар + контент ---------- */
#app {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "hd hd" "nav main";
  min-height: 100vh;
}
header {
  grid-area: hd; position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px;
  background: rgba(255, 255, 255, .72); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
header .brand { font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
header .brand, header .brand span {
  background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent;
}
header .actions { display: flex; align-items: center; gap: 12px; }
#bot-name {
  font-weight: 600; font-size: 13px; color: var(--blue);
  background: #eaf0ff; padding: 5px 12px; border-radius: 999px;
}

nav {
  grid-area: nav; position: sticky; top: 64px; align-self: start;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px; min-height: calc(100vh - 64px);
  background: rgba(255, 255, 255, .6); border-right: 1px solid var(--line);
}
nav button {
  background: transparent; color: var(--muted); box-shadow: none;
  text-align: left; padding: 11px 14px; border-radius: 12px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
nav button::before { font-size: 16px; }
nav button[data-tab="dashboard"]::before  { content: "📊"; }
nav button[data-tab="giveaways"]::before   { content: "🎁"; }
nav button[data-tab="broadcasts"]::before   { content: "📣"; }
nav button[data-tab="channels"]::before     { content: "📡"; }
nav button[data-tab="base"]::before         { content: "👥"; }
nav button:hover { transform: none; background: #eef3ff; color: var(--ink); }
nav button.active {
  background: var(--grad-primary); color: #fff; box-shadow: var(--shadow-color);
}

main { grid-area: main; padding: 26px; max-width: 1180px; width: 100%; }

/* ---------- карточки ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 22px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm); animation: rise .4s ease both;
}
.card h3 { margin: 0 0 14px; font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- статистика: полный спектр ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.stat {
  position: relative; overflow: hidden; color: #fff;
  border-radius: var(--radius); padding: 20px 18px;
  box-shadow: var(--shadow); animation: rise .45s ease both;
  transition: transform .16s ease, box-shadow .16s ease;
}
.stat:hover { transform: translateY(-3px); box-shadow: 0 20px 42px rgba(43, 66, 130, .2); }
.stat::after {
  content: ""; position: absolute; right: -24px; top: -24px;
  width: 96px; height: 96px; border-radius: 50%; background: rgba(255, 255, 255, .16);
}
.stat .n { font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.stat .l { color: rgba(255, 255, 255, .9); font-size: 13px; font-weight: 600; margin-top: 8px; }
.grid .stat:nth-child(6n+1) { background: var(--grad-s1); }
.grid .stat:nth-child(6n+2) { background: var(--grad-s2); }
.grid .stat:nth-child(6n+3) { background: var(--grad-s3); }
.grid .stat:nth-child(6n+4) { background: var(--grad-s4); }
.grid .stat:nth-child(6n+5) { background: var(--grad-s5); }
.grid .stat:nth-child(6n+6) { background: var(--grad-s6); }
.grid .stat:nth-child(2) { animation-delay: .04s; }
.grid .stat:nth-child(3) { animation-delay: .08s; }
.grid .stat:nth-child(4) { animation-delay: .12s; }
.grid .stat:nth-child(5) { animation-delay: .16s; }
.grid .stat:nth-child(6) { animation-delay: .2s; }

/* ---------- таблицы ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: #f5f8ff; }
td code { font-size: 11px; }

/* ---------- бейджи ---------- */
.badge {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: #fff; vertical-align: middle;
}
.badge.draft { background: #aab4d4; }
.badge.active, .badge.running { background: var(--grad-ok); color: #03291f; }
.badge.finished, .badge.done { background: var(--grad-s2); }
.badge.cancelled, .badge.stopped, .badge.failed { background: var(--grad-danger); }

/* ---------- списки ---------- */
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 12px; background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s;
  animation: rise .4s ease both;
}
.list-item:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d4deff; }
.list-item b { font-size: 15px; }
.list-item .meta { color: var(--muted); font-size: 13px; margin-top: 5px; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* ---------- прогресс ---------- */
.progress { height: 10px; background: #e9eefb; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress > div {
  height: 100%; width: 0; border-radius: 999px;
  background: var(--grad-primary); background-size: 200% 100%;
  transition: width .4s ease; animation: flow 1.6s linear infinite;
}
@keyframes flow { from { background-position: 0 0; } to { background-position: 200% 0; } }

/* ---------- чипы / конструктор кнопок ---------- */
.btn-add { background: #eef3ff; color: var(--blue); border: 1.5px dashed #b9c8ff; box-shadow: none; width: 100%; }
.btn-add:hover { background: #e3ecff; transform: none; }
.kbd-row { display: flex; gap: 8px; margin-bottom: 8px; }
.kbd-row input { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 6px; }
.chip {
  display: flex; align-items: center; gap: 8px; background: #fff;
  border: 1.5px solid var(--line); padding: 8px 12px; border-radius: 11px; cursor: pointer;
  transition: border-color .12s, background .12s; font-weight: 500;
}
.chip:hover { border-color: #b9c8ff; background: #f7f9ff; }

/* ---------- экран входа ---------- */
#login {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
  background: linear-gradient(130deg, #3b6ef6 0%, #6d5efc 48%, #ff5d6c 110%);
}
#login::before, #login::after {
  content: ""; position: fixed; border-radius: 50%; filter: blur(10px); opacity: .35;
  background: #fff;
}
#login::before { width: 220px; height: 220px; top: 8%; left: 10%; }
#login::after  { width: 300px; height: 300px; bottom: 6%; right: 8%; opacity: .22; }
#login .box {
  width: 360px; max-width: 100%; z-index: 2;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px);
  border: none; border-radius: var(--radius-lg); box-shadow: 0 30px 70px rgba(20, 25, 60, .4);
  padding: 32px 30px; animation: rise .5s ease both;
}
#login .box h3 {
  font-size: 24px; font-weight: 800; margin: 0 0 8px; text-align: center;
  background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- тост ---------- */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 60;
  background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--blue);
  padding: 14px 20px; border-radius: 14px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(12px); transition: opacity .3s, transform .3s;
  max-width: 380px; font-weight: 600;
}
#toast.show { opacity: 1; transform: translateY(0); }

/* ---------- адаптив ---------- */
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; grid-template-areas: "hd" "nav" "main"; }
  nav {
    flex-direction: row; overflow-x: auto; min-height: 0; top: 60px;
    border-right: none; border-bottom: 1px solid var(--line); padding: 10px 14px;
  }
  nav button { white-space: nowrap; }
  main { padding: 18px; }
}
