/* public/css/main.css — layout и компоненты. Токены темы — в theme.css */

body { font-size: 15px; line-height: 1.55; }

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 64px 1fr;
  grid-template-areas: "header header" "sidebar main";
  min-height: 100vh;
}
@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; grid-template-areas: "header" "main"; }
  .sidebar { position: fixed; inset: 64px 0 0 0; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.is-open { transform: translateX(0); }
}

/* ── Header ── */
.header {
  grid-area: header;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 19px; text-decoration: none; white-space: nowrap; }
.brand-mark { width: 26px; height: 26px; flex-shrink: 0; }
.header-search { flex: 1; max-width: 520px; }
.header-spacer { flex: 1; }
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; color: var(--text-muted);
  cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-elevated-2); color: var(--text); }
.menu-toggle { display: none; }
@media (max-width: 880px) { .menu-toggle { display: flex; } }

/* ── Sidebar / catalog tree ── */
.sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  overflow-y: auto;
  padding: 16px 10px 40px;
}
.tree-node { user-select: none; }
.tree-row {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-muted); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tree-row:hover { background: var(--bg-elevated-2); color: var(--text); }
.tree-row.is-active { background: var(--bg-elevated-2); color: var(--text); font-weight: 600; }
.tree-caret { width: 14px; height: 14px; flex-shrink: 0; transition: transform .15s; opacity: .6; }
.tree-node.is-collapsed > .tree-children { display: none; }
.tree-node.is-collapsed > .tree-row .tree-caret { transform: rotate(-90deg); }
.tree-children { margin-left: 16px; border-left: 1px solid var(--border); padding-left: 4px; }
.tree-lock { width: 12px; height: 12px; flex-shrink: 0; color: var(--signal); opacity: .8; }

/* ── Main ── */
.main { grid-area: main; padding: 28px 32px 60px; max-width: 1100px; }
@media (max-width: 640px) { .main { padding: 18px 16px 40px; } }

.page-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin: 0 0 6px; }
.page-subtitle { color: var(--text-muted); margin: 0 0 24px; }
.eyebrow { font-family: var(--font-mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--aurora-1); margin: 0 0 10px; }

.breadcrumbs { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); margin-bottom: 18px; flex-wrap: wrap; }
.breadcrumbs a { text-decoration: none; }
.breadcrumbs a:hover { color: var(--text); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow-card); text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--aurora-1); transform: translateY(-2px); }
.card-title { font-weight: 600; font-size: 15.5px; }
.card-meta { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 13px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Buttons ── */
.btn {
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  padding: 9px 16px; border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--bg-elevated-2); color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; transition: filter .15s, transform .1s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--aurora-gradient); color: #08111a; border: none; }
.btn-danger { background: var(--danger); color: #fff; border: none; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--bg-elevated-2); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.input, select.input, textarea.input {
  font-family: var(--font-body); font-size: 14px; color: var(--text);
  background: var(--bg-elevated-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 12px; outline: none; transition: border-color .15s;
  width: 100%;
}
.input:focus { border-color: var(--aurora-1); }
textarea.input { resize: vertical; min-height: 90px; font-family: var(--font-body); }
.input.mono { font-family: var(--font-mono); }
.hint { font-size: 12.5px; color: var(--text-faint); }

.search-box { position: relative; }
.search-box .input { padding-left: 36px; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); width: 16px; height: 16px; }

/* ── Badges (роли, статус, замок) ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; font-family: var(--font-mono); }
.badge-user { background: var(--bg-elevated-2); color: var(--text-muted); }
.badge-moderator { background: rgba(79,209,197,0.15); color: var(--aurora-1); }
.badge-admin { background: rgba(159,122,234,0.18); color: #b79bf0; }
.badge-super_admin { background: linear-gradient(90deg, rgba(79,209,197,.25), rgba(159,122,234,.25)); color: var(--text); border: 1px solid var(--aurora-2); }
.badge-draft { background: rgba(245,166,35,0.15); color: var(--signal); }
.badge-locked { background: rgba(245,166,35,0.12); color: var(--signal); }

.tag-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; background: var(--bg-elevated-2); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted); font-family: var(--font-mono); text-decoration: none; }
.tag-pill:hover { border-color: var(--aurora-1); color: var(--text); }
.tag-pill .x { cursor: pointer; opacity: .6; }
.tag-pill .x:hover { opacity: 1; }

/* ── Rating ── */
.stars { display: inline-flex; gap: 2px; }
.stars svg { width: 17px; height: 17px; }
.stars.is-interactive svg { cursor: pointer; }
.star-filled { color: var(--signal); fill: var(--signal); }
.star-empty { color: var(--text-faint); fill: none; stroke: currentColor; }
.rating-summary { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; }

/* ── Instruction viewer / stepper ── */
.step-progress-track { height: 4px; background: var(--bg-elevated-2); border-radius: 4px; overflow: hidden; margin-bottom: 22px; }
.step-progress-fill { height: 100%; background: var(--aurora-gradient); transition: width .25s ease; }
.step-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 28px; gap: 12px; }
.step-counter { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }
.step-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 26px; }
.step-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; margin: 0 0 18px; }
.block { margin-bottom: 16px; }
.block:last-child { margin-bottom: 0; }
.block-caption { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.block img, .block video { max-width: 100%; border-radius: var(--radius-md); display: block; }
.block audio { width: 100%; }
.block-file { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--bg-elevated-2); border-radius: var(--radius-md); border: 1px solid var(--border); text-decoration: none; color: var(--text); }
.block-file svg { flex-shrink: 0; color: var(--aurora-1); }
.block-link { display: inline-flex; align-items: center; gap: 6px; color: var(--aurora-1); text-decoration: none; font-weight: 600; }
.block-link:hover { text-decoration: underline; }
.md-code-block { background: var(--bg-elevated-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; overflow-x: auto; font-family: var(--font-mono); font-size: 13px; }
.md-inline-code { background: var(--bg-elevated-2); border-radius: 4px; padding: 2px 6px; font-family: var(--font-mono); font-size: 13px; }
.md-heading { font-family: var(--font-display); }
.md-quote { border-left: 3px solid var(--aurora-2); padding-left: 14px; color: var(--text-muted); margin: 0; }
.toc-list { display: flex; flex-direction: column; gap: 6px; }
.toc-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--bg-elevated); cursor: pointer; }
.toc-item:hover { border-color: var(--aurora-1); }
.toc-num { font-family: var(--font-mono); color: var(--text-faint); font-size: 13px; width: 20px; }

/* ── Editor (шаги/блоки) ── */
.editor-step { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-elevated); margin-bottom: 14px; overflow: hidden; }
.editor-step-header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--bg-elevated-2); }
.editor-step-body { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.editor-block { border: 1px dashed var(--border); border-radius: var(--radius-md); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.editor-block-head { display: flex; justify-content: space-between; align-items: center; }
.block-type-label { font-family: var(--font-mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--aurora-1); }
.add-block-menu { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Comments ── */
.comment { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; background: var(--bg-elevated-2); object-fit: cover; }
.comment-body { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.comment-name { font-weight: 600; font-size: 14px; }
.comment-date { font-size: 12px; color: var(--text-faint); }
.comment-text { font-size: 14.5px; }
.comment-text.is-deleted { color: var(--text-faint); font-style: italic; }
.comment-img { max-width: 320px; border-radius: var(--radius-md); margin-top: 8px; display: block; }
.comment-actions { display: flex; gap: 12px; margin-top: 6px; font-size: 12.5px; }
.comment-actions button { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0; }
.comment-actions button:hover { color: var(--aurora-1); }
.replies-toggle { color: var(--aurora-1); font-size: 13px; font-weight: 600; background: none; border: none; cursor: pointer; padding: 6px 0; }
.replies-block { margin-left: 48px; margin-top: 4px; }

/* ── Tables (admin) ── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { color: var(--text-muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
.table tr:hover td { background: var(--bg-elevated-2); }

.perm-matrix { border-collapse: collapse; font-size: 13.5px; }
.perm-matrix th, .perm-matrix td { border: 1px solid var(--border); padding: 8px 10px; text-align: center; }
.perm-matrix th:first-child, .perm-matrix td:first-child { text-align: left; }
.perm-check { width: 18px; height: 18px; cursor: pointer; }

.checkbox-row { display: flex; align-items: center; gap: 8px; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab { padding: 10px 14px; font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--aurora-1); }

/* ── Modal / toast ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; max-width: 560px; width: 100%; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-card); }
.modal h3 { margin-top: 0; font-family: var(--font-display); }
.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 16px; box-shadow: var(--shadow-card); font-size: 14px; max-width: 320px; }
.toast.is-error { border-color: var(--danger); }
.toast.is-success { border-color: var(--success); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.spinner { width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--aurora-1); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-loading { display: flex; justify-content: center; padding: 60px 0; }
