/* Organisationens egna verktyg — topbaren, menyn under "+", verktygsvyn och dialogen. */

/* ── Topbaren: verktygen efter lägesväxlaren ── */
.org-tools { display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; flex-shrink: 1; min-width: 0; }
.org-tools[hidden] { display: none; }
.org-tool-btn {
  display: inline-flex; align-items: center; gap: 4px; max-width: 160px;
  height: 24px; padding: 0 10px; border: 1px solid transparent; border-radius: 999px;
  background: transparent; color: var(--text-secondary); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.org-tool-ic { flex: none; opacity: .7; }
.org-tool-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-tool-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.org-tool-btn.is-on { border-color: var(--accent); color: var(--accent); background: var(--accent-subtle, transparent); }
.org-tool-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.org-tool-compact { display: none; }
@media (max-width: 900px) {
  .org-tool-btn:not(.org-tool-compact) { display: none; }
  .org-tool-compact { display: inline-flex; }
}

/* ── Menyn (under "+", "Fler", "Hantera") ── */
.org-tools-menu {
  position: fixed; z-index: 10050; min-width: 220px; max-width: min(340px, calc(100vw - 16px)); padding: 4px;
  border: 1px solid var(--border-default); border-radius: 10px; background: var(--bg-elevated, var(--bg-surface));
  box-shadow: var(--shadow-lg, 0 10px 30px rgba(0,0,0,.18));
}
.otm-item {
  display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; width: 100%;
  padding: 7px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text-primary);
  font: inherit; font-size: 13px; text-align: start; cursor: pointer;
}
.otm-item > span { grid-column: 2; }
.otm-item > svg { grid-column: 1; color: var(--text-secondary); }
.otm-item > small { grid-column: 2; font-size: 11.5px; color: var(--text-muted); }
.otm-item:not(:has(svg)) { grid-template-columns: 1fr; }
.otm-item:not(:has(svg)) > span, .otm-item:not(:has(svg)) > small { grid-column: 1; }
.otm-item:hover, .otm-item:focus-visible { background: var(--bg-hover); outline: none; }
.otm-item.is-danger { color: var(--error); }
.otm-sep { height: 1px; margin: 4px 6px; background: var(--border-subtle, var(--border-default)); }

/* ── Verktygsvyn: appen inne i myceon ── */
.org-tool-view { position: fixed; inset: 0; z-index: 10040; display: flex; flex-direction: column; background: var(--bg-base, var(--bg-surface)); }
.org-tool-view[hidden] { display: none; }
.otv-bar {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 12px;
  border-bottom: 1px solid var(--border-default); background: var(--bg-surface);
}
.otv-bar .logo-wordmark { flex: none; }
.otv-tabs { display: flex; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; }
.otv-tab {
  flex: none; height: 28px; padding: 0 12px; border: 1px solid transparent; border-radius: 999px;
  background: transparent; color: var(--text-secondary); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.otv-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.otv-tab.is-on { border-color: var(--accent); color: var(--accent); }
.otv-note { flex: none; font-size: 12px; color: var(--text-muted); cursor: help; }
.otv-act {
  flex: none; display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border: 1px solid var(--border-default); border-radius: 8px;
  background: transparent; color: var(--text-secondary); font: inherit; font-size: 12.5px; text-decoration: none; cursor: pointer;
}
.otv-act:hover { background: var(--bg-hover); color: var(--text-primary); }
.otv-close { flex: none; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); font-size: 22px; line-height: 1; cursor: pointer; }
.otv-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.otv-tab:focus-visible, .otv-act:focus-visible, .otv-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.otv-body { position: relative; flex: 1 1 auto; min-height: 0; }
.otv-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.otv-loading { padding: 32px; color: var(--text-muted); }
html.org-tool-open body { overflow: hidden; }
@media (max-width: 640px) {
  .otv-note { display: none; }
  .otv-bar .logo-wordmark { display: none; }
}

/* ── Dialogen: Lägg till verktyg ── */
.ot-modal { position: fixed; inset: 0; z-index: 10060; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.4); }
.ot-card {
  width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 20px 22px;
  border-radius: 14px; background: var(--bg-elevated, var(--bg-surface)); color: var(--text-primary); box-shadow: var(--shadow-lg, 0 20px 50px rgba(0,0,0,.25));
}
.ot-card h2 { margin: 0 0 12px; font-size: 18px; }
.ot-card h3 { margin: 4px 0 6px; font-size: 13px; color: var(--text-secondary); }
.ot-form { display: flex; flex-direction: column; gap: 14px; }
.ot-field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; font-size: 13px; }
.ot-field > span, .ot-field > legend { font-weight: 600; font-size: 13px; padding: 0; }
.ot-field select, .ot-field input[type=text], .ot-field input:not([type]) {
  font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border-default); background: var(--bg-base, var(--bg-surface)); color: var(--text-primary);
}
.ot-radio { display: flex; align-items: center; gap: 8px; }
.ot-roles { display: flex; flex-wrap: wrap; gap: 12px; padding-inline-start: 24px; }
.ot-roles[hidden] { display: none; }
.ot-scope-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ot-scope-list li { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border-subtle, var(--border-default)); font-size: 13px; }
.ot-scope-list li:empty { display: none; }
.ot-scope-list li.is-on { border-color: var(--success, var(--border-default)); }
.ot-scope-list li.is-locked { opacity: .75; }
.ot-scope-list small { color: var(--text-muted); font-size: 12px; }
.ot-dim { color: var(--text-muted); font-size: 12px; margin: 0; }
.ot-err { color: var(--error); font-size: 13px; margin: 0; }
.ot-err[hidden] { display: none; }
.ot-acts { display: flex; justify-content: flex-end; gap: 8px; }
.ot-toast {
  position: fixed; z-index: 10070; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100vw - 32px);
  padding: 10px 14px; border-radius: 10px; background: var(--text-primary); color: var(--bg-surface); font-size: 13px; box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.2));
}
.ot-toast.is-error { background: var(--error); color: #fff; }

.otv-mode { flex: none; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border-default); color: var(--text-secondary); }
.otv-mode:empty { display: none; }
.otv-mode.is-draft { color: var(--warning); border-color: var(--warning); }
.otv-mode.is-version { color: var(--success, var(--text-secondary)); border-color: var(--success, var(--border-default)); }
.otv-act[hidden] { display: none; }
.ot-note { margin: 0; font-size: 12.5px; color: var(--text-secondary); padding: 8px 10px; border-radius: 8px; background: var(--bg-inset, var(--bg-hover)); }
.ot-note:empty { display: none; }
