/* ==========================================================================
   CoderDao — админ-панель
   ========================================================================== */

:root {
  --a-bg: #05060b;
  --a-bg2: #0a0c16;
  --a-surface: rgba(17, 21, 34, 0.72);
  --a-surface2: rgba(24, 29, 46, 0.9);
  --a-stroke: rgba(255, 255, 255, 0.08);
  --a-stroke2: rgba(255, 255, 255, 0.16);
  --a-green: #00ffcc;
  --a-purple: #b026ff;
  --a-blue: #00aaff;
  --a-red: #ff003c;
  --a-amber: #ffb020;
  --a-text: #eef1ff;
  --a-dim: #9aa3c4;
  --a-mute: #667096;
  --a-font: 'Inter', system-ui, sans-serif;
  --a-code: 'Fira Code', ui-monospace, monospace;
  --a-r: 14px;
  --a-side: 244px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--a-bg);
  color: var(--a-text);
  font-family: var(--a-font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(800px 500px at 8% -6%, rgba(0, 255, 204, 0.07), transparent 60%),
    radial-gradient(700px 480px at 96% 4%, rgba(176, 38, 255, 0.09), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--a-green); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--a-bg2); }
::-webkit-scrollbar-thumb { background: #2a3149; border-radius: 20px; border: 2px solid var(--a-bg2); }
::-webkit-scrollbar-thumb:hover { background: #3a4260; }

/* ---------- вход ---------- */
.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  padding: 38px 34px 30px;
  border-radius: 22px;
  background: var(--a-surface2);
  border: 1px solid var(--a-stroke);
  backdrop-filter: blur(20px);
  box-shadow: 0 40px 90px -40px #000;
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute;
  top: -60%; left: -20%;
  width: 140%; height: 60%;
  background: radial-gradient(circle, rgba(0, 255, 204, 0.16), transparent 70%);
  pointer-events: none;
}
.login-logo {
  width: 62px; height: 62px;
  border-radius: 18px;
  object-fit: cover;
  border: 1px solid var(--a-stroke2);
  box-shadow: 0 0 26px rgba(0, 255, 204, 0.4);
  margin-bottom: 18px;
}
.login-card h1 {
  font-family: var(--a-code);
  font-size: 1.5rem;
  margin-bottom: 6px;
}
.login-card .sub { color: var(--a-mute); font-size: 0.9rem; margin-bottom: 26px; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-family: var(--a-code);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--a-mute);
  margin-bottom: 7px;
}
.input, .textarea, select.input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--a-stroke);
  border-radius: 11px;
  color: var(--a-text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus, .textarea:focus, select.input:focus {
  outline: none;
  border-color: var(--a-green);
  box-shadow: 0 0 0 3px rgba(0, 255, 204, 0.13);
}
.textarea { min-height: 96px; resize: vertical; font-family: var(--a-code); font-size: 0.88rem; }
select.input { appearance: none; cursor: pointer; }
select.input option { background: var(--a-bg2); }
.hint { font-size: 0.78rem; color: var(--a-mute); margin-top: 6px; }
.pw-row { position: relative; }
.pw-row .toggle {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--a-mute);
  padding: 6px 8px;
  border-radius: 8px;
}
.pw-row .toggle:hover { color: var(--a-text); background: rgba(255, 255, 255, 0.06); }

/* ---------- кнопки ---------- */
.btn {
  --b: var(--a-green);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  font-family: var(--a-code);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-radius: 11px;
  border: 1px solid var(--b);
  background: color-mix(in srgb, var(--b) 10%, transparent);
  color: var(--b);
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  white-space: nowrap;
}
.btn:hover { background: var(--b); color: #04060b; transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 0.72rem; border-radius: 9px; }
.btn.ghost { --b: rgba(255, 255, 255, 0.42); color: var(--a-dim); background: rgba(255, 255, 255, 0.035); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.9); color: #04060b; }
.btn.blue { --b: var(--a-blue); }
.btn.purple { --b: var(--a-purple); }
.btn.red { --b: var(--a-red); }
.btn.amber { --b: var(--a-amber); }

/* ---------- каркас ---------- */
.shell { position: relative; z-index: 1; display: flex; min-height: 100vh; }

.sidebar {
  width: var(--a-side);
  flex: 0 0 var(--a-side);
  background: rgba(8, 10, 18, 0.86);
  border-right: 1px solid var(--a-stroke);
  backdrop-filter: blur(18px);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 8px 18px;
  font-family: var(--a-code);
  font-weight: 700;
  font-size: 1.06rem;
}
.sidebar .brand img { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; border: 1px solid var(--a-stroke2); }
.sidebar .brand .accent { color: var(--a-green); }
.sidebar .brand small {
  display: block;
  font-family: var(--a-font);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--a-mute);
  font-weight: 600;
}
.navitem {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border-radius: 11px;
  color: var(--a-dim);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.92rem;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  width: 100%;
}
.navitem:hover { background: rgba(255, 255, 255, 0.045); color: var(--a-text); }
.navitem.active {
  background: rgba(0, 255, 204, 0.1);
  border-color: rgba(0, 255, 204, 0.3);
  color: var(--a-green);
}
.navitem .ic { font-size: 1.05rem; width: 20px; text-align: center; }
.navitem .pill {
  margin-left: auto;
  background: var(--a-red);
  color: #fff;
  font-size: 0.66rem;
  padding: 1px 7px;
  border-radius: 20px;
  font-family: var(--a-code);
}
.sidebar .spacer { flex: 1; }
.sidebar .whoami {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--a-stroke);
  font-size: 0.8rem;
  color: var(--a-dim);
}
.sidebar .whoami b { color: var(--a-text); font-family: var(--a-code); font-size: 0.86rem; }
.sidebar .whoami .dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--a-green);
  margin-right: 6px;
  box-shadow: 0 0 8px var(--a-green);
}

.main { flex: 1; min-width: 0; padding: 24px clamp(16px, 3vw, 34px) 60px; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--a-stroke);
}
.topbar h1 { font-family: var(--a-code); font-size: 1.5rem; }
.topbar .crumbs { color: var(--a-mute); font-size: 0.82rem; font-family: var(--a-code); }
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.mobile-toggle {
  display: none;
  position: fixed;
  bottom: 18px; right: 18px;
  z-index: 200;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid var(--a-stroke2);
  background: var(--a-surface2);
  color: var(--a-text);
  font-size: 1.3rem;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

/* ---------- карточки/панели ---------- */
.panel {
  background: var(--a-surface);
  border: 1px solid var(--a-stroke);
  border-radius: var(--a-r);
  backdrop-filter: blur(14px);
  padding: 22px;
}
.panel + .panel { margin-top: 18px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.panel-head h2, .panel-head h3 {
  font-family: var(--a-code);
  font-size: 1rem;
  letter-spacing: 0.02em;
}
.panel-head .sub { color: var(--a-mute); font-size: 0.82rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  position: relative;
  padding: 20px;
  border-radius: var(--a-r);
  background: var(--a-surface);
  border: 1px solid var(--a-stroke);
  overflow: hidden;
  transition: transform 0.3s, border-color 0.3s;
}
.stat-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--sc) 45%, transparent); }
.stat-card::after {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: var(--sc, var(--a-green));
  filter: blur(48px);
  opacity: 0.18;
}
.stat-card .lbl {
  font-family: var(--a-code);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--a-mute);
  margin-bottom: 10px;
}
.stat-card .val {
  font-family: var(--a-code);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--sc, var(--a-green));
}
.stat-card .hint2 { font-size: 0.78rem; color: var(--a-mute); margin-top: 8px; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }

/* ---------- таблица ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--a-r); border: 1px solid var(--a-stroke); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 720px; }
table.data th {
  text-align: left;
  font-family: var(--a-code);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--a-mute);
  padding: 13px 14px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid var(--a-stroke);
  white-space: nowrap;
}
table.data td { padding: 13px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.045); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: rgba(255, 255, 255, 0.025); }
.cell-title { display: flex; align-items: center; gap: 11px; min-width: 220px; }
.cell-title .thumb {
  width: 38px; height: 38px;
  border-radius: 10px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-family: var(--a-code);
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--a-stroke);
  overflow: hidden;
}
.cell-title .thumb img { width: 100%; height: 100%; object-fit: cover; }
.cell-title .t { font-family: var(--a-code); font-size: 0.92rem; }
.cell-title .s { color: var(--a-mute); font-size: 0.76rem; }
.row-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--a-code);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 7px;
  border: 1px solid var(--a-stroke2);
  color: var(--a-dim);
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}
.badge.pub { color: var(--a-green); border-color: rgba(0, 255, 204, 0.4); background: rgba(0, 255, 204, 0.08); }
.badge.draft { color: var(--a-amber); border-color: rgba(255, 176, 32, 0.4); background: rgba(255, 176, 32, 0.08); }
.badge.feat { color: var(--a-purple); border-color: rgba(176, 38, 255, 0.4); background: rgba(176, 38, 255, 0.1); }
.badge.new { color: var(--a-blue); border-color: rgba(0, 170, 255, 0.4); background: rgba(0, 170, 255, 0.08); }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar .grow { flex: 1; min-width: 180px; }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--a-mute);
  border: 1px dashed var(--a-stroke2);
  border-radius: var(--a-r);
}
.empty-state .big { font-size: 2.4rem; margin-bottom: 10px; }

/* ---------- редактор ---------- */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.checkline { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.checkline input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--a-green); cursor: pointer; }
.checkline label { color: var(--a-dim); font-size: 0.9rem; cursor: pointer; }

 /* блоки */
.blocks-editor { display: grid; gap: 14px; }
.block-item {
  border: 1px solid var(--a-stroke);
  border-radius: var(--a-r);
  background: rgba(0, 0, 0, 0.22);
  overflow: hidden;
  transition: border-color 0.2s;
}
.block-item:hover { border-color: var(--a-stroke2); }
.block-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--a-stroke);
  cursor: grab;
}
.block-head:active { cursor: grabbing; }
.block-head .drag { color: var(--a-mute); letter-spacing: -2px; }
.block-head .type {
  font-family: var(--a-code);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--a-green);
}
.block-head .grow { flex: 1; }
.block-head button {
  background: transparent;
  border: 0;
  color: var(--a-mute);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 7px;
  line-height: 1;
}
.block-head button:hover { color: var(--a-text); background: rgba(255, 255, 255, 0.07); }
.block-body { padding: 14px; display: grid; gap: 12px; }
.block-item.dragover { border-color: var(--a-green); box-shadow: 0 0 0 2px rgba(0, 255, 204, 0.2); }

.feature-row { display: flex; gap: 9px; align-items: center; }
.feature-row .ico { width: 62px; text-align: center; }
.feature-row .grow { flex: 1; }
.feature-row button {
  background: transparent;
  border: 1px solid var(--a-stroke);
  color: var(--a-mute);
  border-radius: 9px;
  cursor: pointer;
  padding: 10px 12px;
}
.feature-row button:hover { color: var(--a-red); border-color: rgba(255, 0, 60, 0.4); }

.block-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 6px;
}
.block-picker button {
  font-family: var(--a-code);
  font-size: 0.74rem;
  padding: 8px 13px;
  border-radius: 9px;
  border: 1px dashed var(--a-stroke2);
  background: rgba(255, 255, 255, 0.03);
  color: var(--a-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.block-picker button:hover { border-color: var(--a-green); color: var(--a-green); background: rgba(0, 255, 204, 0.07); }

.preview-box {
  border: 1px solid var(--a-stroke);
  border-radius: var(--a-r);
  padding: 18px;
  background: rgba(0, 0, 0, 0.3);
  max-height: 560px;
  overflow-y: auto;
  font-size: 0.94rem;
  color: var(--a-dim);
}
.preview-box h2, .preview-box h3 { font-family: var(--a-code); color: var(--a-text); margin: 20px 0 10px; font-size: 1.2rem; }
.preview-box h3 { font-size: 1.02rem; }
.preview-box p { margin-bottom: 12px; }
.preview-box ul { margin: 0 0 14px 20px; }
.preview-box li { margin-bottom: 6px; }
.preview-box .blk-features { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 9px; }
.preview-box .feature-item { display: flex; gap: 9px; padding: 11px 13px; border: 1px solid var(--a-stroke); border-radius: 10px; background: rgba(255, 255, 255, 0.03); }
.preview-box pre { background: rgba(0, 0, 0, 0.5); padding: 14px; border-radius: 10px; overflow-x: auto; font-family: var(--a-code); font-size: 0.82rem; }
.preview-box blockquote { border-left: 3px solid var(--a-purple); padding-left: 14px; font-style: italic; color: var(--a-text); }
.preview-box .blk-note { border: 1px solid rgba(255, 176, 32, 0.35); background: rgba(255, 176, 32, 0.08); padding: 12px; border-radius: 10px; display: flex; gap: 9px; }
.preview-box img { border-radius: 10px; }
.preview-box hr { border: 0; height: 1px; background: var(--a-stroke2); margin: 20px 0; }

.upload-drop {
  border: 1px dashed var(--a-stroke2);
  border-radius: 11px;
  padding: 14px;
  text-align: center;
  color: var(--a-mute);
  cursor: pointer;
  font-size: 0.84rem;
  transition: all 0.2s;
}
.upload-drop:hover, .upload-drop.over { border-color: var(--a-green); color: var(--a-green); background: rgba(0, 255, 204, 0.05); }

.icon-preview {
  width: 74px; height: 74px;
  border-radius: 16px;
  border: 1px solid var(--a-stroke2);
  background: rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-family: var(--a-code);
  font-size: 1.4rem;
  color: var(--a-green);
  margin-bottom: 10px;
}
.icon-preview img { width: 100%; height: 100%; object-fit: cover; }

.sticky-actions {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 10px;
}

.msg-item {
  border: 1px solid var(--a-stroke);
  border-radius: var(--a-r);
  padding: 16px;
  margin-bottom: 12px;
  background: rgba(0, 0, 0, 0.2);
}
.msg-item.unread { border-left: 3px solid var(--a-green); }
.msg-item .head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.msg-item .who { font-family: var(--a-code); font-size: 0.88rem; }
.msg-item .when { color: var(--a-mute); font-size: 0.78rem; }
.msg-item .body { color: var(--a-dim); white-space: pre-wrap; font-size: 0.92rem; }
.msg-item .actions { margin-top: 12px; display: flex; gap: 8px; }

.log-list { display: grid; gap: 9px; }
.log-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 10px 13px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--a-stroke);
  font-size: 0.86rem;
  flex-wrap: wrap;
}
.log-row .act { font-family: var(--a-code); color: var(--a-green); font-size: 0.78rem; }
.log-row .when { margin-left: auto; color: var(--a-mute); font-size: 0.76rem; }

/* ---------- тосты и модалка ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 10px; z-index: 500; max-width: min(380px, 90vw); }
.toast {
  display: flex;
  gap: 11px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--a-surface2);
  border: 1px solid var(--a-stroke2);
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px -24px #000;
  animation: tin 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  font-size: 0.9rem;
}
.toast.ok { border-color: rgba(0, 255, 204, 0.45); }
.toast.err { border-color: rgba(255, 0, 60, 0.5); }
@keyframes tin { from { opacity: 0; transform: translateY(12px) scale(0.97); } }

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(2, 3, 6, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 400;
  animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(440px, 100%);
  padding: 26px;
  border-radius: 18px;
  background: var(--a-surface2);
  border: 1px solid var(--a-stroke2);
  box-shadow: 0 40px 90px -40px #000;
}
.modal h3 { font-family: var(--a-code); margin-bottom: 10px; font-size: 1.1rem; }
.modal p { color: var(--a-dim); font-size: 0.92rem; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--a-green);
  border-radius: 50%;
  animation: sp 0.7s linear infinite;
  display: inline-block;
}
@keyframes sp { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

@media (max-width: 1080px) {
  .editor-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    height: 100vh;
  }
  .sidebar.open { transform: none; box-shadow: 30px 0 80px -30px #000; }
  .mobile-toggle { display: grid; place-items: center; }
  .main { padding: 18px 14px 90px; }
  .form-row, .form-row.three { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}
