/* ════════════════════════════════════════════
   Code Editor – imifactory.ch
   style.css  |  Version 1.1
   GEÄNDERT: aus index.html ausgelagert
════════════════════════════════════════════ */

/* ─── CSS-Variablen ───────────────────── */
:root {
  --brand-mid:    #0b3c5d;
  --brand-accent: #00bfae;
  --brand-hover:  #00897b;
  --bg:    #f8fafc;
  --border:#d1dce6;
  --muted: #5a7080;
  --sans:  'Sora','Segoe UI',sans-serif;
  --mono:  'JetBrains Mono',monospace;
  --tab-html:#e84a3f;
  --tab-css: #3b82f6;
  --tab-js:  #f59e0b;
  --e-bg:   #1a2433;
  --e-gut:  #1e2a38;
  --e-bdr:  #2a3a4a;
  --e-fg:   #e2ebf5;
  --e-dim:  #4a6070;
  --e-bar:  #12202e;
  --err-ln: #ef4444;
  --wrn-ln: #f59e0b;
  --ok-ln:  #00bfae;
  --fz: 14px; /* Editor-Schriftgrösse – per JS angepasst */
}

/* ─── Reset ───────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; font-family: var(--sans); background: var(--bg); color: #1e293b; }
body { display: flex; flex-direction: column; }

/* ─── Header (imifactory Standard) ───── */
header {
  flex-shrink: 0;
  background: linear-gradient(90deg, #05263d 0%, #0b3c5d 100%);
  padding: 10px 20px;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.site {
  font-size: 19px;
  font-weight: 700;
  text-decoration: none;
  color: #fff;
}
.bc { margin-top: 3px; font-size: 11px; color: #94a3b8; }
.bc a { color: #cbd5e1; text-decoration: none; }
.bc a:hover { color: var(--brand-accent); }

/* ─── Toolbar ─────────────────────────── */
.toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 5px 12px;
  background: #fff;
  border-bottom: 2px solid var(--border);
}
.tg { display: flex; gap: 3px; align-items: center; }
.sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; flex-shrink: 0; }

/* Sprach-Tabs */
.ltab {
  padding: 5px 14px;
  border: 2px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--sans);
  transition: background .12s, border-color .12s;
  background: #f0f4f8;
  color: var(--muted);
  user-select: none;
}
.ltab[data-l="html"].on { background: var(--tab-html); color: #fff; border-color: var(--tab-html); }
.ltab[data-l="css"].on  { background: var(--tab-css);  color: #fff; border-color: var(--tab-css); }
.ltab[data-l="js"].on   { background: var(--tab-js);   color: #fff; border-color: var(--tab-js); }
.ltab:not(.on):hover { border-color: var(--brand-accent); color: var(--brand-mid); }

/* Buttons */
.btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--sans);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
  background: #f0f4f8;
  color: var(--brand-mid);
  user-select: none;
}
.btn:hover { background: #e2ecf4; border-color: var(--brand-mid); }
.btn:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; } /* GEÄNDERT: Fokus-Indikator WCAG 2.4.7 */
.btn.primary { background: var(--brand-accent); color: #fff; border-color: var(--brand-accent); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.danger { background: #fef2f2; color: #ef4444; border-color: #fecaca; }
.btn.danger:hover { background: #ef4444; color: #fff; border-color: #ef4444; }
.btn.icon { padding: 5px 8px; }

/* Layout-Buttons */
.lbtn {
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--sans);
  background: #f0f4f8;
  color: var(--muted);
  transition: all .12s;
  user-select: none;
}
.lbtn.on { background: var(--brand-mid); color: #fff; border-color: var(--brand-mid); }
.lbtn:not(.on):hover { border-color: var(--brand-accent); color: var(--brand-mid); }
.lbtn:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }

/* Auto-Run */
.ar {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.ar input { accent-color: var(--brand-mid); cursor: pointer; }

/* Schriftgrössen-Steuerung */
.fz-ctrl { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.fz-ctrl button {
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--mono);
  background: #f0f4f8;
  color: var(--brand-mid);
  line-height: 1;
  transition: background .1s;
}
.fz-ctrl button:hover { background: #e2ecf4; border-color: var(--brand-mid); }
.fz-ctrl button:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
.fz-val { min-width: 26px; text-align: center; font-family: var(--mono); font-size: 11px; }

/* ─── Split-Layout ────────────────────── */
.main { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.pane-ed  { display: flex; flex-direction: column; flex: 0 0 50%; min-width: 120px; min-height: 0; }
.pane-pre { display: flex; flex-direction: column; flex: 1; min-width: 120px; min-height: 0; }

/* Splitter-Griff */
.splitter {
  flex-shrink: 0;
  width: 5px;
  background: var(--border);
  cursor: col-resize;
  transition: background .15s;
  position: relative;
  z-index: 10;
}
.splitter:hover, .splitter.dragging { background: var(--brand-accent); }
.splitter::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 1px; height: 24px;
  background: var(--muted);
  border-radius: 1px;
}

/* Layout-Varianten */
.main.lv { flex-direction: column; }
.main.lv .pane-ed  { flex: 0 0 50%; min-width: 0; min-height: 60px; }
.main.lv .pane-pre { flex: 1; min-width: 0; }
.main.lv .splitter { width: auto; height: 5px; cursor: row-resize; }
.main.lv .splitter::after { width: 24px; height: 1px; }

.main.le .pane-pre { display: none; }
.main.le .splitter  { display: none; }
.main.le .pane-ed   { flex: 1; }
.main.lp .pane-ed   { display: none; }
.main.lp .splitter  { display: none; }
.main.lp .pane-pre  { flex: 1; }

/* ─── Editor ──────────────────────────── */
.ed-wrap { flex: 1; display: flex; overflow: hidden; min-height: 0; }

.gutter {
  flex-shrink: 0;
  width: 44px;
  padding: 14px 6px 14px 0;
  background: var(--e-gut);
  font-family: var(--mono);
  font-size: var(--fz);
  line-height: 1.6;
  text-align: right;
  overflow: hidden;
  user-select: none;
  pointer-events: none;
  border-right: 1px solid var(--e-bdr);
  white-space: pre;
  color: var(--e-dim);
}
.ge { color: var(--err-ln) !important; font-weight: 700; }
.gw { color: var(--wrn-ln) !important; }

#ta {
  flex: 1;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: var(--fz);
  line-height: 1.6;
  color: var(--e-fg);
  background: var(--e-bg);
  border: none;
  resize: none;
  outline: none;
  white-space: pre;
  tab-size: 2;
  -moz-tab-size: 2;
  overflow: auto;
  caret-color: var(--brand-accent);
  scrollbar-width: thin;
  scrollbar-color: #2d3f52 var(--e-bg);
}
#ta::-webkit-scrollbar { width: 10px; height: 10px; }
#ta::-webkit-scrollbar-track { background: var(--e-bg); }
#ta::-webkit-scrollbar-thumb { background: #2d3f52; border-radius: 5px; border: 2px solid var(--e-bg); }
#ta::selection { background: rgba(0,191,174,.3); color: var(--e-fg); }

/* ─── Statusleiste ────────────────────── */
.sbar {
  flex-shrink: 0;
  background: var(--e-bar);
  color: var(--e-dim);
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 14px;
  display: flex;
  gap: 14px;
  align-items: center;
  border-top: 1px solid var(--e-bdr);
  min-height: 22px;
  flex-wrap: wrap;
}
.sbar-item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.ldot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sind { margin-left: auto; font-size: 10px; }
.sind.ok    { color: var(--ok-ln); }
.sind.dirty { color: var(--e-dim); }

/* ─── Fehler-Panel ────────────────────── */
.ep {
  flex-shrink: 0;
  background: #0f1a25;
  border-top: 1px solid var(--e-bdr);
  max-height: 0;
  overflow: hidden;
  transition: max-height .2s ease;
  font-family: var(--mono);
  font-size: 12px;
}
.ep.open { max-height: 150px; overflow-y: auto; }
.ep::-webkit-scrollbar { width: 6px; }
.ep::-webkit-scrollbar-thumb { background: #2d3f52; border-radius: 3px; }
.ep-hd {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 14px;
  background: #0a1520;
  cursor: pointer; user-select: none;
  font-size: 11px; font-weight: 700;
  color: var(--e-dim);
  border-bottom: 1px solid var(--e-bdr);
}
.ep-ct.has-err { color: var(--err-ln); }
.ep-ct.has-wrn { color: var(--wrn-ln); }
.ep-ct.clean   { color: var(--ok-ln); }
.ep-arr { font-size: 9px; transition: transform .2s; }
.ep.open .ep-arr { transform: rotate(180deg); }
.ep-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 5px 14px;
  border-bottom: 1px solid #131f2d;
  cursor: pointer;
  transition: background .1s;
}
.ep-row:last-child { border-bottom: none; }
.ep-row:hover { background: #162030; }
.ep-lno  { color: var(--e-dim); min-width: 58px; flex-shrink: 0; font-size: 11px; }
.ep-badge { font-size: 10px; padding: 1px 6px; border-radius: 3px; font-weight: 700; flex-shrink: 0; margin-top: 1px; }
.ep-badge.e { background: rgba(239,68,68,.2);   color: var(--err-ln); }
.ep-badge.w { background: rgba(245,158,11,.18); color: var(--wrn-ln); }
.ep-txt  { color: #c8d8e8; flex: 1; word-break: break-word; line-height: 1.5; }
.ep-none { padding: 6px 14px; color: var(--ok-ln); font-size: 11px; }

/* ─── Vorschau-Leiste ─────────────────── */
.pbar {
  flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 5px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pdots { display: flex; gap: 5px; align-items: center; }
.pdots span { width: 11px; height: 11px; border-radius: 50%; display: block; }
.pbar-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.pbar-ts    { font-size: 11px; color: #94a3b8; flex: 1; text-align: right; }
.pbar-reload {
  padding: 3px 8px;
  font-size: 11px; font-weight: 700;
  font-family: var(--sans);
  border: 1px solid var(--border); border-radius: 4px;
  background: #f0f4f8; color: var(--muted);
  cursor: pointer; transition: all .12s; flex-shrink: 0;
}
.pbar-reload:hover { background: var(--brand-accent); color: #fff; border-color: var(--brand-accent); }

#fr { flex: 1; min-height: 0; border: none; width: 100%; display: block; background: #fff; }

/* ─── JS-Konsole ──────────────────────── */
.con {
  flex-shrink: 0;
  background: #0f1a25;
  border-top: 2px solid var(--e-bdr);
  font-family: var(--mono);
  font-size: 12px;
  max-height: 0;
  overflow: hidden;
  transition: max-height .2s ease;
}
.con.open { max-height: 140px; overflow-y: auto; }
.con::-webkit-scrollbar { width: 6px; }
.con::-webkit-scrollbar-thumb { background: #2d3f52; border-radius: 3px; }
.con-hd {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 12px;
  background: #0a1520;
  cursor: pointer; user-select: none;
  font-size: 11px; font-weight: 700;
  border-bottom: 1px solid var(--e-bdr);
}
.con-hd-lbl { color: var(--e-dim); display: flex; align-items: center; gap: 6px; }
.con-badge  { font-size: 10px; padding: 1px 5px; border-radius: 3px; font-weight: 700; }
.con-badge.err { background: rgba(239,68,68,.2);   color: var(--err-ln); }
.con-badge.ok  { background: rgba(0,191,174,.15); color: var(--ok-ln); }
.con-arr  { font-size: 9px; transition: transform .2s; color: var(--e-dim); }
.con.open .con-arr { transform: rotate(180deg); }
.con-clr {
  font-size: 10px; padding: 1px 7px; border-radius: 3px;
  border: 1px solid var(--e-bdr); background: transparent;
  color: var(--e-dim); cursor: pointer;
  font-family: var(--sans); font-weight: 600;
}
.con-clr:hover { color: #fff; border-color: var(--e-dim); }
.con-line {
  padding: 3px 12px;
  border-bottom: 1px solid #131f2d;
  font-size: 11px; line-height: 1.5;
  display: flex; gap: 8px; align-items: baseline;
}
.con-line:last-child { border-bottom: none; }
.con-line.log   { color: #c8d8e8; }
.con-line.warn  { color: var(--wrn-ln); }
.con-line.error { color: var(--err-ln); }
.con-line.info  { color: #7ec8e3; }
.con-ts   { color: var(--e-dim); font-size: 10px; flex-shrink: 0; min-width: 52px; }
.con-kind { font-size: 10px; padding: 1px 4px; border-radius: 2px; font-weight: 700; flex-shrink: 0; }
.con-kind.error { background: rgba(239,68,68,.18);  color: var(--err-ln); }
.con-kind.warn  { background: rgba(245,158,11,.18); color: var(--wrn-ln); }
.con-kind.log   { background: rgba(255,255,255,.05); color: var(--e-dim); }
.con-kind.info  { background: rgba(126,200,227,.1);  color: #7ec8e3; }
.con-msg   { flex: 1; word-break: break-all; }
.con-empty { padding: 6px 12px; color: var(--e-dim); font-size: 11px; }

/* ─── Tastaturkürzel-Overlay ──────────── */
.overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(5,20,35,.75);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.overlay.show { opacity: 1; pointer-events: all; }
.overlay-box {
  background: #1a2433;
  border: 1px solid var(--e-bdr);
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 480px; width: 90%;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
  font-family: var(--mono);
  color: var(--e-fg);
}
.overlay-title {
  font-family: var(--sans); font-size: 15px; font-weight: 700;
  color: #fff; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.overlay-close {
  background: none; border: none; cursor: pointer;
  color: var(--e-dim); font-size: 18px; line-height: 1; padding: 2px 6px;
}
.overlay-close:hover { color: #fff; }
.overlay-close:focus-visible { outline: 2px solid var(--brand-accent); border-radius: 3px; }
.kb-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.kb-table tr { border-bottom: 1px solid var(--e-bdr); }
.kb-table tr:last-child { border-bottom: none; }
.kb-table td { padding: 6px 4px; vertical-align: middle; }
.kb-table td:first-child { width: 48%; }
.kb-table td:last-child  { color: #94a3b8; font-family: var(--sans); font-size: 12px; }
kbd {
  display: inline-block; padding: 1px 6px;
  background: #0a1520;
  border: 1px solid var(--e-bdr); border-radius: 4px;
  font-family: var(--mono); font-size: 11px; color: #c8d8e8;
  margin: 0 2px; white-space: nowrap;
}

/* ─── Toast ───────────────────────────── */
#toast {
  position: fixed; bottom: 18px; right: 18px; z-index: 9999;
  background: var(--brand-mid); color: #fff;
  padding: 9px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600; font-family: var(--sans);
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  opacity: 0; transform: translateY(10px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }

/* ─── Responsive ──────────────────────── */
@media (max-width: 640px) {
  .main:not(.le):not(.lp) { flex-direction: column; }
  .main:not(.le):not(.lp) .pane-ed { flex: 0 0 50%; min-width: 0; min-height: 60px; }
  .main:not(.le):not(.lp) .splitter { width: auto; height: 5px; cursor: row-resize; }
  .sep { display: none; }
}
