/* ============================================================
   Psychotest Admin — Stylesheet
   ============================================================ */

:root {
  --primary:    #6c63ff;
  --primary-d:  #5048e5;
  --secondary:  #ff6b6b;
  --success:    #51cf66;
  --warning:    #ffd93d;
  --danger:     #ff4444;
  --bg:         #0f0f1a;
  --bg2:        #1a1a2e;
  --bg3:        #252540;
  --card:       #1e1e35;
  --border:     rgba(255,255,255,.1);
  --text:       #e8e8f0;
  --text-muted: rgba(255,255,255,.5);
  --radius:     12px;
  --radius-sm:  8px;
  --transition: .2s ease;
  --sidebar-w:  240px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ---- Sidebar ---- */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
  overflow-y: auto;
  transition: transform var(--transition);
}
.admin-sidebar__logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.admin-sidebar__logo a {
  font-size: 1.2rem; font-weight: 900; color: var(--primary);
  text-decoration: none; letter-spacing: -.03em;
}
.admin-sidebar__logo a span { color: var(--secondary); }
.admin-sidebar__label {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted); padding: 16px 20px 6px;
}
.admin-nav { list-style: none; padding: 8px 12px; }
.admin-nav li + li { margin-top: 2px; }
.admin-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none;
  font-size: .9rem; font-weight: 500;
  transition: all var(--transition);
}
.admin-nav a:hover { background: rgba(255,255,255,.06); color: var(--text); }
.admin-nav a.active { background: var(--primary); color: #fff; }
.admin-nav a .icon { font-size: 1.1rem; width: 20px; text-align: center; }
.admin-sidebar__footer {
  margin-top: auto; padding: 16px 12px;
  border-top: 1px solid var(--border);
}
.admin-sidebar__footer a {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-size: .875rem;
}
.admin-sidebar__footer a:hover { color: var(--danger); }

/* ---- Main content ---- */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column;
  min-width: 0;
}
.admin-topbar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 58px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 40;
}
.admin-topbar__title {
  font-size: 1rem; font-weight: 700; color: var(--text);
}
.admin-topbar__actions { display: flex; gap: 10px; align-items: center; }
.admin-content {
  padding: 28px;
  flex: 1;
}

/* ---- Stats cards ---- */
.stat-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.stat-card__label { font-size: .8rem; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .06em; }
.stat-card__value { font-size: 2rem; font-weight: 900; color: var(--text); }
.stat-card__sub   { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.stat-card__icon  { font-size: 1.6rem; float: right; margin-top: -4px; }

/* ---- Table ---- */
.admin-table-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.admin-table-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap;
}
.admin-table-header h3 { font-size: .95rem; font-weight: 700; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 12px 16px;
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.03); }
td { padding: 12px 16px; font-size: .875rem; vertical-align: middle; }
td.td--title { font-weight: 600; color: var(--text); max-width: 280px; }
td.td--title small { display: block; color: var(--text-muted); font-weight: 400; font-size: .78rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .72rem; font-weight: 700; padding: 3px 8px;
  border-radius: 50px; white-space: nowrap;
}
.badge--active  { background: rgba(81,207,102,.15); color: #4ade80; }
.badge--inactive{ background: rgba(255,68,68,.15);  color: #f87171; }
.badge--cat     { background: rgba(108,99,255,.2);  color: #a5b4fc; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; border-radius: var(--radius-sm); padding: 8px 18px; font-size: .875rem; cursor: pointer; transition: all var(--transition); border: none; text-decoration: none; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-d); color: #fff; }
.btn--sm { padding: 5px 12px; font-size: .8rem; }
.btn--danger  { background: rgba(255,68,68,.15); color: #f87171; }
.btn--danger:hover  { background: #ff4444; color: #fff; }
.btn--ghost   { background: rgba(255,255,255,.06); color: var(--text); }
.btn--ghost:hover { background: rgba(255,255,255,.1); }
.btn--success { background: rgba(81,207,102,.15); color: #4ade80; }
.btn--success:hover { background: var(--success); color: #fff; }

/* ---- Form ---- */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: .85rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-label small { color: var(--text-muted); font-weight: 400; font-size: .78rem; }
.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg3); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: .9rem; font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

/* ---- 2-col layout ---- */
.admin-form-layout {
  display: grid; grid-template-columns: 1fr 320px;
  gap: 24px; align-items: start;
}
.admin-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.admin-card + .admin-card { margin-top: 16px; }
.admin-card h3 { font-size: .95rem; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

/* ---- Questions editor ---- */
.questions-list { display: flex; flex-direction: column; gap: 16px; }
.q-item {
  background: var(--bg3); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  position: relative;
}
.q-item__header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.q-item__num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 800; flex-shrink: 0;
}
.q-item__del {
  margin-left: auto; background: none; border: none;
  color: var(--text-muted); cursor: pointer; padding: 4px;
  border-radius: var(--radius-sm); transition: color var(--transition);
}
.q-item__del:hover { color: var(--danger); }

.answers-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.ans-row {
  display: grid; grid-template-columns: 1fr 90px auto;
  gap: 8px; align-items: center;
}
.ans-row input { padding: 8px 12px; }
.ans-del {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 6px; border-radius: var(--radius-sm);
}
.ans-del:hover { color: var(--danger); }

/* Image upload box */
.img-upload-box {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 24px; text-align: center; cursor: pointer;
  transition: all var(--transition); background: var(--bg3);
}
.img-upload-box:hover { border-color: var(--primary); background: rgba(108,99,255,.05); }
.img-upload-box.has-image { border-style: solid; border-color: var(--primary); padding: 0; }
.img-upload-box img { width: 100%; border-radius: calc(var(--radius) - 2px); display: block; }
.img-upload-box__text { font-size: .85rem; color: var(--text-muted); margin-top: 8px; }
.img-upload-box__icon { font-size: 2rem; margin-bottom: 8px; }

/* ---- Stats page ---- */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.chart-wrap h3 { font-size: .9rem; margin-bottom: 16px; color: var(--text-muted); font-weight: 600; }
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; font-size: .82rem; }
.bar-track { height: 8px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #a855f7); border-radius: 99px; }

/* ---- Filters ---- */
.filters-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter-select {
  padding: 7px 12px; background: var(--bg3); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: .875rem;
  cursor: pointer; outline: none; transition: border-color var(--transition);
}
.filter-select:focus { border-color: var(--primary); }
.search-input {
  padding: 7px 14px; background: var(--bg3); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: .875rem;
  outline: none; transition: border-color var(--transition); width: 220px;
}
.search-input:focus { border-color: var(--primary); }

/* ---- Pagination ---- */
.admin-pagination {
  display: flex; gap: 6px; justify-content: center; padding: 20px 0;
}
.admin-pagination a {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  color: var(--text-muted); font-size: .875rem; text-decoration: none;
  transition: all var(--transition);
}
.admin-pagination a:hover, .admin-pagination a.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ---- Flash ---- */
.flash { padding: 12px 18px; border-radius: var(--radius-sm); font-size: .875rem; font-weight: 600; margin-bottom: 20px; }
.flash--success { background: rgba(81,207,102,.15); color: #4ade80; border: 1px solid rgba(81,207,102,.3); }
.flash--error   { background: rgba(255,68,68,.15);  color: #f87171; border: 1px solid rgba(255,68,68,.3); }

/* ---- Login ---- */
.admin-login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px;
}
.admin-login__box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px; width: 100%; max-width: 380px;
}
.admin-login__logo { font-size: 1.5rem; font-weight: 900; color: var(--primary); margin-bottom: 8px; }
.admin-login__logo span { color: var(--secondary); }
.admin-login h2 { font-size: 1.3rem; margin-bottom: 24px; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .admin-form-layout { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* ---- Sortable drag handle ---- */
.drag-handle {
  cursor: grab; color: var(--text-muted); padding: 4px; flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; }

/* ---- Image preview in question ---- */
.q-img-preview {
  margin-top: 10px; position: relative; display: inline-block;
}
.q-img-preview img {
  max-height: 140px; border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.q-img-preview__del {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,.7); color: #fff;
  border: none; border-radius: 50%; width: 22px; height: 22px;
  cursor: pointer; font-size: .75rem; display: flex; align-items: center; justify-content: center;
}
