/* ============================================================
   Admin Panel — exclusive styles
   Links after style.css so these rules win on the admin page
   ============================================================ */

/* ============================================================
   1. PER-TEMPLATE EDITOR CARDS
   ============================================================ */
.tpl-card{
  background:var(--card2);
  border:1px solid var(--line);
  border-radius:10px;
  padding:14px;
  margin-bottom:12px;
}

.tpl-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:10px;
  padding-bottom:8px;
  border-bottom:1px solid var(--line);
}
.tpl-head strong{
  color:var(--acc);
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.08em;
}

.tpl-card label{
  display:block;
  font-size:11px;
  color:var(--mut);
  text-transform:uppercase;
  letter-spacing:.05em;
  margin-bottom:10px;
}
.tpl-card label > input,
.tpl-card label > textarea,
.tpl-card label > select{
  display:block;
  width:100%;
  margin-top:4px;
  text-transform:none;
  letter-spacing:normal;
  font-size:13px;
  font-family:ui-monospace,Menlo,Consolas,monospace;
  color:var(--txt);
  background:var(--card);
  border:1px solid var(--line);
  border-radius:8px;
  padding:8px 10px;
  outline:none;
  box-sizing:border-box;
}
.tpl-card label > input:focus,
.tpl-card label > textarea:focus{border-color:var(--acc)}
.tpl-card textarea{resize:vertical;min-height:60px;line-height:1.5}
.tpl-card .solution-input{min-height:120px}
.tpl-card .vars-input{min-height:90px}

/* ---- Layout grids inside a template card ---- */
.tpl-grid{
  display:grid;
  grid-template-columns:1fr 1fr 1fr;
  gap:8px;
}
.tpl-grid label{margin-bottom:10px}

.tpl-grid-small{
  display:grid;
  grid-template-columns:1fr 100px;
  gap:8px;
  align-items:start;
}

@media (max-width:640px){
  .tpl-grid,
  .tpl-grid-small{grid-template-columns:1fr}
}

/* ---- Helper text inside cards ---- */
.tpl-help{
  font-size:11px;
  color:var(--mut);
  margin:-4px 0 10px 0;
  text-transform:none;
  letter-spacing:normal;
  font-family:inherit;
  line-height:1.6;
}
.tpl-help code{
  background:rgba(255,255,255,.06);
  padding:1px 4px;
  border-radius:3px;
  font-size:11px;
  font-family:ui-monospace,monospace;
}

/* ============================================================
   2. SECTION LABELS INSIDE CARDS
   ============================================================ */
.tpl-section-label{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:11px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.08em;
  color:var(--acc);
  margin:18px 0 8px 0;
}
.tpl-section-label::after{
  content:'';
  flex:1;
  height:1px;
  background:var(--line);
}

/* ============================================================
   3. VARIABLE EDITOR — unified list
   ============================================================ */
.vars-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin:18px 0 8px 0;
}
.vars-header .title{
  font-size:11px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.08em;
  color:var(--acc);
}
.vars-header .insert-hint{
  font-size:11px;
  color:var(--mut);
  font-style:italic;
}

.vars-list{
  display:flex;
  flex-direction:column;
  gap:10px;
}

/* ---- Variable row ---- */
.var-row{
  background:var(--card);
  border:1px solid var(--line);
  border-left:3px solid var(--line);
  border-radius:8px;
  padding:12px 14px;
  transition:border-left-color .15s;
}

/* Type-specific accent colour on the left border */
.var-row.type-int,
.var-row.type-pick,
.var-row.type-bool,
.var-row.type-const{ border-left-color:var(--acc); }

.var-row.type-expr{ border-left-color:var(--purple); }

/* ---- Row header: name + type + delete ---- */
.var-row-head{
  display:flex;
  align-items:center;
  gap:8px;
  margin-bottom:10px;
}

.var-row-head .var-name{
  flex:1;
  min-width:100px;
  font-family:ui-monospace,monospace;
  font-size:13px;
  font-weight:600;
  background:var(--card2);
  color:var(--txt);
  border:1px solid var(--line);
  border-radius:7px;
  padding:7px 10px;
  outline:none;
}
.var-row-head .var-name:focus{border-color:var(--acc)}
.var-row.type-expr .var-row-head .var-name:focus{border-color:var(--purple)}

.var-row-head .var-type{
  width:100px;
  flex-shrink:0;
  font-family:ui-monospace,monospace;
  font-size:12px;
  background:var(--card2);
  color:var(--acc);
  border:1px solid var(--line);
  border-radius:7px;
  padding:7px 8px;
  outline:none;
  cursor:pointer;
}
.var-row.type-expr .var-row-head .var-type{color:var(--purple)}

.var-row-head .var-del{
  width:32px;
  height:32px;
  flex-shrink:0;
  border-radius:7px;
  padding:0 !important;
  font-size:18px;
  line-height:1;
  color:var(--mut);
  border:1px solid var(--line);
  background:transparent;
  cursor:pointer;
}
.var-row-head .var-del:hover{
  color:#fff;
  background:rgba(248,81,73,.2);
  border-color:var(--bad);
}

/* ---- Row body: fields ---- */
.var-fields{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:flex-start;
}

.mini-label{
  display:flex;
  flex-direction:column;
  gap:3px;
  font-size:10px;
  color:var(--mut);
  text-transform:uppercase;
  letter-spacing:.06em;
  flex:1 1 110px;
  min-width:0;
}
.mini-label > input,
.mini-label > select{
  width:100%;
  box-sizing:border-box;
  font-family:ui-monospace,monospace;
  font-size:12px;
  background:var(--card2);
  color:var(--txt);
  border:1px solid var(--line);
  border-radius:6px;
  padding:6px 8px;
  outline:none;
  text-transform:none;
  letter-spacing:normal;
}
.mini-label > input:focus,
.mini-label > select:focus{border-color:var(--acc)}

/* ============================================================
   4. EXPRESSION ROW (type: expr)
   ============================================================ */
.expr-row{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.expr-line{
  display:flex;
  align-items:center;
  gap:10px;
}
.expr-line .eq{
  font-family:ui-monospace,monospace;
  font-size:16px;
  font-weight:700;
  color:var(--purple);
  flex-shrink:0;
}
.expr-line input.vf-expr{
  flex:1;
  min-width:0;
  font-family:ui-monospace,monospace;
  font-size:13px;
  background:var(--card2);
  color:var(--txt);
  border:1px solid var(--line);
  border-radius:7px;
  padding:8px 10px;
  outline:none;
}
.expr-line input.vf-expr:focus{border-color:var(--purple)}

/* ---- Meta line: needs hint + test button ---- */
.expr-meta{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  font-size:11px;
  padding-left:26px;
  align-items:center;
}
.expr-meta .needs{ color:var(--mut); }
.expr-meta .needs code{
  background:rgba(255,255,255,.06);
  padding:1px 5px;
  border-radius:3px;
  font-family:ui-monospace,monospace;
  font-size:10.5px;
  color:#e0c8ff;
  margin:0 1px;
}

.expr-meta .test-out{
  color:var(--ok);
  font-family:ui-monospace,monospace;
  font-size:11px;
  padding:2px 8px;
  border-radius:5px;
  background:rgba(63,185,80,.12);
  border:1px solid rgba(63,185,80,.3);
}
.expr-meta .test-err{
  color:var(--bad);
  font-family:ui-monospace,monospace;
  font-size:11px;
}
.expr-meta .test-btn{
  background:transparent;
  border:1px solid var(--line);
  color:var(--mut);
  padding:3px 10px;
  font-size:10.5px;
  border-radius:5px;
  cursor:pointer;
}
.expr-meta .test-btn:hover{
  color:var(--purple);
  border-color:var(--purple);
}

/* ============================================================
   5. INSERT-VARIABLE CHIPS
   ============================================================ */
.var-inserts{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin:6px 0 0 0;
  padding:8px 10px;
  background:rgba(34,211,238,.04);
  border:1px dashed rgba(34,211,238,.2);
  border-radius:7px;
  align-items:center;
}
.var-inserts .insert-hint{
  font-size:10.5px;
  color:var(--mut);
  text-transform:uppercase;
  letter-spacing:.05em;
  margin-right:4px;
  flex-shrink:0;
}
.var-insert-chip{
  display:inline-block;
  padding:3px 9px;
  border-radius:999px;
  border:1px solid var(--line);
  background:var(--card2);
  color:var(--acc);
  font-family:ui-monospace,monospace;
  font-size:11.5px;
  cursor:pointer;
  transition:.12s;
  user-select:none;
}
.var-insert-chip:hover{
  background:rgba(34,211,238,.15);
  border-color:var(--acc);
}
.var-insert-chip.empty{
  color:var(--mut);
  cursor:default;
  font-style:italic;
}

/* ============================================================
   6. ADD VARIABLE BUTTON + EMPTY HINTS
   ============================================================ */
.add-var-btn{
  display:block;
  width:100%;
  box-sizing:border-box;
  margin-top:10px;
  padding:10px 16px;
  font-size:12px;
  border:1px dashed var(--line);
  background:transparent;
  color:var(--mut);
  border-radius:7px;
  cursor:pointer;
  font-family:inherit;
}
.add-var-btn:hover{ color:var(--acc); border-color:var(--acc); }

.vars-empty-hint{
  font-size:12px;
  color:var(--mut);
  padding:10px 0;
  font-style:italic;
  text-align:center;
}

/* ============================================================
   7. SOLUTION PREVIEW BOX
   ============================================================ */
.sol-preview-box{
  margin:8px 0 12px 0;
  padding:12px 14px;
  background:var(--card);
  border-left:3px solid var(--purple);
  border-radius:6px;
  font-size:13px;
  line-height:1.55;
  color:var(--txt);
  max-height:260px;
  overflow:auto;
}
.sol-preview-box.hidden{ display:none !important; }
.sol-preview-box p{ margin:0 0 8px 0; }
.sol-preview-box p:last-child{ margin-bottom:0; }
.sol-preview-box strong{ color:#fff; font-weight:700; }
.sol-preview-box em{ color:var(--mut); font-style:italic; }
.sol-preview-box code{
  background:rgba(255,255,255,.06);
  padding:1px 5px;
  border-radius:4px;
  font-size:12px;
  color:#e0c8ff;
}
.sol-preview-box ul,
.sol-preview-box ol{ margin:4px 0 8px 0; padding-left:22px; }
.sol-preview-box li::marker{ color:var(--purple); }

/* ============================================================
   8. LEGACY / BACKWARDS-COMPAT CLASSES
   (kept so nothing breaks if referenced from old markup)
   ============================================================ */
.vars-editor{
  margin-top:8px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.var-row.is-step{ border-left:3px solid var(--purple); padding-left:12px; }
.var-row.is-step .var-type-badge{
  display:inline-block;
  width:60px;
  text-align:center;
  padding:6px 0;
  font-size:11px;
  font-weight:700;
  color:var(--purple);
  text-transform:uppercase;
  letter-spacing:.06em;
  flex-shrink:0;
}
.var-row.is-step .step-expr-wrap{
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
}
.var-row.is-step .step-eq{
  font-size:18px;
  color:var(--purple);
  font-weight:700;
  font-family:ui-monospace,monospace;
}
.var-row.is-step input.vf-expr{
  flex:1;
  font-family:ui-monospace,monospace;
  font-size:13px;
  background:var(--card2);
  color:var(--txt);
  border:1px solid var(--line);
  border-radius:7px;
  padding:8px 10px;
  outline:none;
  text-transform:none;
  letter-spacing:normal;
}
.var-row.is-step input.vf-expr:focus{ border-color:var(--purple); }
.step-why{
  margin-top:6px;
  font-size:11px;
  color:var(--mut);
  font-style:italic;
  padding-left:32px;
}

/* ============================================================
   9. SMALL SCREEN TWEAKS
   ============================================================ */
@media (max-width:520px){
  .var-row-head{ flex-wrap:wrap; }
  .var-row-head .var-type{ width:auto; }
  .expr-meta{ padding-left:0; }
}