/* --- MULTITERM BLOKK (Multipanel terminál) --- */
.block.multiterm-block {
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 8px;
  }
  .block.multiterm-block .block-handle { color: #94a3b8; }
  .block.multiterm-block .block-handle:hover { background: #1e293b; color: #cbd5e1; }
  .block.multiterm-block .block-toolbar .icon-btn {
    background: rgba(255,255,255,0.05);
    border-color: #334155;
    color: #cbd5e1;
  }
  .block.multiterm-block .block-toolbar .icon-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #f1f5f9;
  }
  .block.multiterm-block .block-toolbar .icon-btn.danger { color: #f87171; }
  .block.multiterm-block .block-toolbar .icon-btn.danger:hover { background: rgba(127,29,29,0.4); }

  /* Fülsáv */
  .mt-tabs-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px 6px 0 0;
    padding: 4px 6px;
    overflow-x: auto;
    min-height: 36px;
  }
  .mt-tabs {
    display: flex;
    gap: 2px;
    flex: 1;
    min-width: 0;
  }
  .mt-tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: #94a3b8;
    padding: 5px 10px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: background 0.12s, color 0.12s;
  }
  .mt-tab:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; }
  .mt-tab.active {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
  }
  .mt-tab .mt-tab-icon { font-size: 0.85rem; }
  .mt-tab .mt-tab-label { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }

  /* Bezáró X gomb a füleken */
  .mt-tab .mt-tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 2px;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.10);
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
    transition: background 0.12s, color 0.12s, opacity 0.12s;
    opacity: 1;
  }
  .mt-tab:hover .mt-tab-close { opacity: 1; }
  .mt-tab.active .mt-tab-close { opacity: 1; }
  .mt-tab.active:hover .mt-tab-close { opacity: 1; }
  .mt-tab .mt-tab-close:hover {
    background: #dc2626;
    color: white;
    opacity: 1;
  }
  /* Tanári (nem bezárható) panel jelölése a fülsávban. */
  .mt-tab .mt-tab-locked {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 2px;
    font-size: 0.65rem;
    line-height: 1;
    color: #94a3b8;
    flex-shrink: 0;
    opacity: 0.9;
    cursor: default;
  }

  /* Fül-címke szerkesztés közben */
  .mt-tab-label.mt-tab-label-editing {
    background: rgba(59, 130, 246, 0.3);
    outline: 1px solid #3b82f6;
    border-radius: 3px;
    color: #ffffff;
    padding: 0 4px;
    margin: 0 -4px;
    cursor: text;
  }

  /* Drag & drop a füleken */
  .mt-tab[draggable="true"] { cursor: grab; }
  .mt-tab[draggable="true"]:active { cursor: grabbing; }
  .mt-tab.dragging { opacity: 0.4; }
  .mt-tab.drag-over-left {
    box-shadow: inset 3px 0 0 0 #3b82f6;
  }
  .mt-tab.drag-over-right {
    box-shadow: inset -3px 0 0 0 #3b82f6;
  }

  .mt-add-btn, .mt-settings-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid #334155;
    border-radius: 4px;
    color: #cbd5e1;
    padding: 4px 9px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
    font-family: inherit;
  }
  .mt-add-btn:hover, .mt-settings-btn:hover { background: rgba(255,255,255,0.14); color: #f1f5f9; }
  .mt-add-btn:disabled { opacity: 0.35; cursor: not-allowed; }

  /* Kitöltő (4) mód: a diák nem adhat hozzá más termináltípust,
     ezért a fülsáv jobb szélén a "+" gomb nem jelenik meg.
     A fülek és a beépített terminál változatlanul látszanak. */
  body.mode-fill-only .multiterm-block .mt-add-btn {
    display: none !important;
  }

  /* Panel konténer */
  .mt-panels-container {
    position: relative;
    width: 100%;
    height: 480px;
    background: #000;
    border: 1px solid #334155;
    border-top: none;
    border-radius: 0 0 6px 6px;
    overflow: hidden;
  }
  .mt-panel {
    position: absolute;
    inset: 0;
    visibility: hidden;
    overflow: hidden;
  }
  .mt-panel.active { visibility: visible; }
  .mt-panel iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
    background: #000;
  }

  /* VNC panel belseje */
  .mt-panel .vnc-target {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
  }
  .mt-panel .vnc-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    background: rgba(15, 23, 42, 0.9);
    color: #cbd5e1;
    text-align: center;
    padding: 20px;
    font-size: 0.9rem;
  }
  .mt-panel .vnc-overlay-icon { font-size: 2.5rem; line-height: 1; }

  /* Üres állapot */
  .mt-empty {
    padding: 40px 20px;
    text-align: center;
    color: #64748b;
    font-style: italic;
    font-size: 0.9rem;
  }
  /* Üres terminálblokk: ne maradjon ott a tartalom nélküli fekete
     ablak. A 480px-es panel-konténer ilyenkor rejtve van, csak a
     rövid szöveg (és a diáknál az eltávolító gomb) látszik.
     A fülsávot a JS rejti el, ha nincs "+" gomb (Kitöltő mód), mert
     abban a módban a diák már nem tud panelt hozzáadni. */
  .block.multiterm-block.mt-is-empty .mt-panels-container,
  .block.multiterm-block.mt-is-empty .mt-groups-bar {
    display: none !important;
  }
  .block.multiterm-block.mt-is-empty .mt-empty {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    color: #64748b;
  }
  /* Az üres terminálablak eltávolító gombja. Csak a diák saját
     (üres) blokkjánál jelenik meg, a tanár által kiadott blokknál nem. */
  .mt-empty .mt-empty-actions {
    margin-top: 16px;
    display: flex;
    justify-content: center;
  }
  .mt-empty .mt-empty-remove {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid #f87171;
    border-radius: 6px;
    background: rgba(127, 29, 29, 0.92);
    color: #fff;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    font-style: normal;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    transition: background 0.12s, transform 0.12s;
  }
  .mt-empty .mt-empty-remove:hover {
    background: #dc2626;
    border-color: #fca5a5;
  }
  .mt-empty .mt-empty-remove:active { transform: scale(0.97); }

  /* Panel-szerkesztő modál */
  .mt-panel-editor {
    max-width: 640px;
    width: 90%;
  }
  .mt-panel-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 12px 0;
    /* A viewporthoz igazodik, hogy a modal ne nyuljon tul
       a kepernyon. A 260px a fejlec + url mezok + gombok
       becsult magassaga. */
    max-height: calc(80vh - 260px);
    min-height: 100px;
    overflow-y: auto;
  }
  .mt-panel-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.88rem;
    flex-shrink: 0;
  }
  .mt-panel-item-icon { font-size: 1.1rem; flex-shrink: 0; }
  .mt-panel-item-label { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mt-panel-item-meta { color: #64748b; font-family: Consolas, monospace; font-size: 0.78rem; flex-shrink: 0; }
  .mt-panel-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
  .mt-panel-item-actions .icon-btn { padding: 4px 8px; font-size: 0.78rem; }

  /* Panel-szerkesztő űrlap */
  .mt-panel-form { display: flex; flex-direction: column; gap: 6px; }
  .mt-panel-form label { font-size: 0.8rem; font-weight: 600; color: #475569;
    text-transform: uppercase; letter-spacing: 0.04em; margin-top: 8px; }
  .mt-panel-form input, .mt-panel-form select {
    padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px;
    font-size: 0.9rem; font-family: inherit; background: white;
  }
  .mt-panel-form input:focus, .mt-panel-form select:focus {
    outline: 2px solid #93c5fd; border-color: transparent;
  }
  .mt-panel-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  @media (max-width: 600px) {
    .mt-panel-form-row { grid-template-columns: 1fr; }
  }

/* --- MULTITERM CSOPORT-SAV --- */
.mt-groups-bar {
    display: none;
    align-items: center;
    gap: 4px;
    background: #0b1220;
    border: 1px solid #334155;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 6px 8px;
    overflow-x: auto;
    min-height: 38px;
  }
  .mt-has-groups .mt-groups-bar { display: flex; }
  .mt-has-groups .mt-tabs-bar { border-radius: 0; }
  .mt-group-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.04);
    border: 1px solid #334155;
    border-radius: 16px;
    color: #cbd5e1;
    padding: 4px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    flex-shrink: 0;
  }
  .mt-group-btn:hover {
    background: rgba(255,255,255,0.10);
    color: #f1f5f9;
  }
  .mt-group-btn.active {
    background: #78350f;
    border-color: #d97706;
    color: #fef3c7;
    box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.4);
  }
  .mt-group-btn .mt-group-count {
    background: rgba(255,255,255,0.15);
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.4;
  }
  .mt-group-btn.active .mt-group-count {
    background: rgba(254, 243, 199, 0.25);
    color: #fef3c7;
  }
  .mt-group-btn.drag-over {
    background: rgba(37, 99, 235, 0.5);
    border-color: #60a5fa;
  }

/* --- CSOPORT ÁTNEVEZÉS - inline editing --- */
.mt-group-label.mt-group-label-editing {
    background: rgba(217, 119, 6, 0.3);
    outline: 1px solid #d97706;
    border-radius: 3px;
    color: #ffffff;
    padding: 0 4px;
    margin: 0 -4px;
    cursor: text;
    min-width: 40px;
    display: inline-block;
  }

  .student-lab-locked {
    opacity: 0.5;
    cursor: not-allowed !important;
  }

  /* A teljes diáklabor blokk piros háttere, ha zárolva van */
  .block.container-lab-block.container-lab-block-locked {
    background: #fef2f2;
    border-color: #fca5a5;
    border-left: 4px solid #dc2626;
    box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.1);
  }
  .block.container-lab-block.container-lab-block-locked
    .container-lab-placeholder-icon {
    opacity: 0.5;
  }

/* --- Lebegő ablak mód (multiterm blokk) --- */
.block.multiterm-block.floating-mode {
    position: fixed !important;
    z-index: 9999;
    margin: 0 !important;
    background: #0f172a;
    border: 2px solid #334155;
    border-radius: 10px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    resize: both;
    overflow: hidden;
    min-width: 360px;
    min-height: 240px;
    max-width: 98vw;
    max-height: 98vh;
  }
  .block.multiterm-block.floating-mode .block-toolbar {
    flex-shrink: 0;
    cursor: move;
    cursor: grab;
    background: #1e293b;
    border-radius: 8px 8px 0 0;
    padding: 6px 8px;
    border-bottom: 1px solid #334155;
    user-select: none;
    -webkit-user-select: none;
  }
  .block.multiterm-block.floating-mode .block-toolbar:active {
    cursor: grabbing;
  }
  .block.multiterm-block.floating-mode .block-toolbar .block-handle {
    cursor: move;
  }
  /* A fül-sáv fix magasságú, soha nem zsugorodik össze. */
  .block.multiterm-block.floating-mode .mt-tabs-bar {
    flex-shrink: 0;
    flex-grow: 0;
    min-height: 40px;
    height: 40px;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    align-items: stretch;
    box-sizing: border-box;
  }
  .block.multiterm-block.floating-mode .mt-tabs-bar .mt-tabs {
    display: flex;
    align-items: stretch;
    min-height: 0;
  }
  /* A csoport-sáv is fix magasságú. */
  .block.multiterm-block.floating-mode .mt-groups-bar {
    flex-shrink: 0;
    flex-grow: 0;
    min-height: 38px;
    height: auto;
    max-height: 60px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  /* A panelek konténere kapja a maradék helyet. */
  .block.multiterm-block.floating-mode .mt-panels-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }
  /* A block-toolbar is fix magasságú. */
  .block.multiterm-block.floating-mode .block-toolbar {
    flex-shrink: 0;
    flex-grow: 0;
    min-height: 36px;
  }
  .block.multiterm-block.floating-mode::after {
    content: '';
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 14px;
    height: 14px;
    cursor: nwse-resize;
    background:
      linear-gradient(135deg, transparent 0 45%, #64748b 45% 55%, transparent 55%),
      linear-gradient(135deg, transparent 0 65%, #64748b 65% 75%, transparent 75%),
      linear-gradient(135deg, transparent 0 85%, #64748b 85% 95%, transparent 95%);
    pointer-events: none;
  }
  .block.multiterm-block .icon-btn.float-btn {
    color: #7c3aed;
    border-color: #ddd6fe;
    background: #faf5ff;
  }
  .block.multiterm-block .icon-btn.float-btn:hover {
    background: #f3e8ff;
    border-color: #c4b5fd;
  }
  .block.multiterm-block.floating-mode .icon-btn.float-btn {
    background: #7c3aed;
    border-color: #6d28d9;
    color: white;
  }
  .block.multiterm-block.floating-mode .icon-btn.float-btn:hover {
    background: #6d28d9;
  }
  .floating-placeholder-box {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 24px;
    text-align: center;
    color: #94a3b8;
    background: #f8fafc;
    font-size: 0.9rem;
    font-style: italic;
  }

  /* Külön ablak gomb a lebegő panelen */
  .block.multiterm-block .icon-btn.popout-btn {
    color: #0891b2;
    border-color: #a5f3fc;
    background: #ecfeff;
  }
  .block.multiterm-block .icon-btn.popout-btn:hover {
    background: #cffafe;
    border-color: #67e8f9;
  }

  /* ============================================================
     Kitöltő (4) mód — csak az ablak-vezérlők
     ============================================================
     A step.css a Kitöltő módban a teljes block-toolbart elrejti.
     A diáknak viszont a terminálon is el kell tudnia indítani a
     lebegő módot és a külön böngészőablakot, ezért a multiterm
     toolbarján meghagyjuk KIZÁRÓLAG ezt a két gombot, közvetlenül
     láthatóan (nem menübe rejtve), minden más gombot elrejtünk.
     Üres terminálblokkon (nincs panel) és beadott (zárt) munkánál
     a toolbar marad rejtve. */
  body.mode-fill-only:not(.locked) .multiterm-block[data-lab-block-id]:has(.mt-panel) > .block-toolbar:has(.tb-group[data-tb-group="window"]) {
    display: flex !important;
    justify-content: flex-end !important;
  }
  body.mode-fill-only .multiterm-block[data-lab-block-id] > .block-toolbar > *:not(.tb-group) {
    display: none !important;
  }
  body.mode-fill-only .multiterm-block[data-lab-block-id] > .block-toolbar > .tb-group:not([data-tb-group="window"]) {
    display: none !important;
  }
  body.mode-fill-only .multiterm-block[data-lab-block-id] > .block-toolbar > .tb-group[data-tb-group="window"] {
    display: inline-flex !important;
  }
  /* A csoportgomb (🖥️ menü) helyett a két eredeti gomb látszik. */
  body.mode-fill-only .multiterm-block[data-lab-block-id] > .block-toolbar > .tb-group[data-tb-group="window"] > .tb-group-btn {
    display: none !important;
  }
  body.mode-fill-only .multiterm-block[data-lab-block-id] > .block-toolbar > .tb-group[data-tb-group="window"] > .tb-pool {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
  }
  /* A csoportgomb rejtése miatt a kurzor a gombokon legyen pointer. */
  body.mode-fill-only .multiterm-block[data-lab-block-id] > .block-toolbar > .tb-group[data-tb-group="window"] > .tb-pool > .icon-btn {
    cursor: pointer !important;
  }
  .floating-popup-placeholder {
    border: 2px dashed #0891b2;
    border-radius: 10px;
    padding: 20px 24px;
    text-align: center;
    color: #0e7490;
    background: #ecfeff;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
  }
  .floating-popup-placeholder:hover {
    background: #cffafe;
    border-color: #06b6d4;
  }
  .floating-popup-placeholder .popup-icon {
    font-size: 1.6rem;
    display: block;
    margin-bottom: 6px;
  }
  .floating-popup-placeholder .popup-text {
    font-weight: 600;
  }
  .floating-popup-placeholder .popup-hint {
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 4px;
  }