/* admin.css */

body { min-height: 100vh; overflow: hidden; }

/* ── Header ── */
.admin-header {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 0 20px; height: 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 8px rgba(74,108,247,.06);
}
.admin-logo { font-weight: 700; font-size: 1rem; color: var(--accent); display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.nav-right  { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.nav-right a { font-size: .83rem; color: var(--muted); text-decoration: none; transition: color .15s; }
.nav-right a:hover { color: var(--accent); }
.user-badge { font-size: .8rem; background: #f0f4ff; color: var(--accent); padding: 4px 10px; border-radius: 999px; font-weight: 500; white-space: nowrap; }

/* ── Layout (desktop: sidebar + editor) ── */
.admin-body {
  display: grid; grid-template-columns: 280px 1fr;
  height: calc(100vh - 56px); overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--card); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  transition: transform .25s ease;
}
.sidebar-top { padding: 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sidebar-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.survey-item {
  padding: 11px 15px; border-bottom: 1px solid #f0f2f8;
  cursor: pointer; transition: background .12s; border-left: 3px solid transparent;
  -webkit-tap-highlight-color: transparent;
}
.survey-item:hover  { background: #f4f6fb; }
.survey-item.active { background: #f4f6fb; border-left-color: var(--accent); }
.si-title { font-weight: 500; font-size: .87rem; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-meta  { font-size: .74rem; color: var(--muted); display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.empty-list { padding: 32px 16px; text-align: center; color: var(--muted); font-size: .84rem; }

/* ── Editor pane ── */
.editor-pane {
  overflow-y: auto; padding: 24px; -webkit-overflow-scrolling: touch;
}
.editor-ph {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; color: var(--muted); gap: 12px; text-align: center;
}
.editor-ph .ico { font-size: 2.5rem; }
.editor-ph p    { font-size: .88rem; }

/* ── Inner card ── */
.inner-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card-top   { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-top-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Form groups ── */
.fg       { margin-bottom: 13px; }
.fg label { display: block; font-size: .79rem; font-weight: 600; color: #5a607a; margin-bottom: 5px; }

/* ── Question cards ── */
.q-card      { border: 1.5px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 11px; background: #fafbff; }
.q-card:hover { border-color: #c8d0f0; }
.q-hd        { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; flex-wrap: wrap; }
.q-hd-left   { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.q-num       { background: var(--accent); color: #fff; width: 22px; height: 22px; border-radius: 5px; font-size: .7rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.q-type-tag  { font-size: .69rem; background: #eef0ff; color: var(--accent); padding: 2px 7px; border-radius: 4px; font-weight: 500; }

/* ── Option rows ── */
.opt-row     { display: flex; align-items: center; gap: 5px; margin-bottom: 6px; flex-wrap: wrap; }
.opt-row input[type="text"] { flex: 1; min-width: 100px; font-size: .81rem; }
.flag        { font-size: .67rem; padding: 3px 6px; border-radius: 4px; border: 1px solid; cursor: pointer; user-select: none; transition: all .12s; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.flag-other  { border-color: #fd7e14; color: #fd7e14; }   .flag-other.on  { background: #fd7e14; color: #fff; }
.flag-excl   { border-color: #8b5cf6; color: #8b5cf6; }   .flag-excl.on   { background: #8b5cf6; color: #fff; }
.flag-jump   { border-color: #20c997; color: #20c997; }   .flag-jump.on   { background: #20c997; color: #fff; }
.jump-sel    { font-size: .73rem; padding: 4px 7px; border-radius: 5px; border: 1px solid var(--border); background: #fff; max-width: 130px; flex-shrink: 0; }
.rm-btn      { background: none; border: none; cursor: pointer; color: #c0c8e0; font-size: 1rem; padding: 2px 5px; border-radius: 4px; transition: color .12s; flex-shrink: 0; }
.rm-btn:hover { color: var(--danger); }
.add-opt     { width: 100%; padding: 6px; background: none; border: 1px dashed #c8d0f0; border-radius: 7px; cursor: pointer; color: var(--muted); font-size: .79rem; margin-top: 4px; transition: all .15s; }
.add-opt:hover { border-color: var(--accent); color: var(--accent); }

/* ── Add question buttons ── */
.add-q-section { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.add-q-section h4 { font-size: .84rem; font-weight: 600; margin-bottom: 10px; color: var(--muted); }
.add-q-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Modal overlay ── */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; align-items: center; justify-content: center; padding: 16px; }
.overlay.show { display: flex; }
.modal   { background: #fff; border-radius: 14px; padding: 26px; width: 100%; max-width: 440px; box-shadow: 0 8px 40px rgba(0,0,0,.15); max-height: 90vh; overflow-y: auto; }
.modal h3 { margin-bottom: 16px; font-size: 1rem; }
.modal-ft { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ── Mobile: sidebar becomes a drawer ── */
@media (max-width: 768px) {
  body { overflow: auto; }

  .admin-body { display: block; height: auto; }

  .sidebar {
    position: fixed; top: 56px; left: 0; bottom: 0;
    width: min(300px, 85vw); z-index: 40;
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,.12);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 39;
  }
  .sidebar-backdrop.show { display: block; }

  .editor-pane { padding: 16px; min-height: calc(100vh - 56px); }
  .inner-card  { padding: 14px; }
  .card-top    { gap: 8px; }
  .add-q-row   { gap: 5px; }
  .add-q-row .btn { font-size: .72rem; padding: 5px 9px; }
}