/* =========================================================================
   MT Hub – Shell-Stylesheet (Topbar / Sidebar / Tabs / Frames)
   Look: ruhig, industriell, hochkontrastig — Millionthoughts Design System.
   Farben, Fonts, Radien kommen aus css/mt-design.css (Single Source of Truth).
   Hier nur noch SHELL-SPEZIFISCHE Layout-Tokens.
   ========================================================================= */

@import url('mt-design.css');

:root {
  /* Shell-Layout (nicht Teil des globalen Design-Systems) */
  --radius-sm:  4px;
  --sidebar-w:  240px;
  --tabbar-h:   38px;
  --topbar-h:   48px;

  --shadow-sm:  0 1px 2px rgba(0,0,0,0.04);
  --shadow:     0 2px 8px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input {
  font-family: inherit;
  font-size: inherit;
}

/* ========================== Layout ========================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) var(--tabbar-h) 1fr;
  grid-template-areas:
    "topbar  topbar"
    "sidebar tabbar"
    "sidebar main";
  height: 100vh;
}

body.sidebar-collapsed .app {
  grid-template-columns: 0 1fr;
}
body.sidebar-collapsed #sidebar {
  display: none;
}

/* ========================== Topbar ========================== */
#topbar {
  grid-area: topbar;
  background: var(--text);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  border-bottom: 1px solid #000;
}

.brand {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 22px;
  height: 22px;
  background: var(--primary);
  border-radius: 3px;
  display: inline-block;
  position: relative;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 5px;
  background: var(--text);
  border-radius: 1px;
}

.brand-sub {
  font-weight: 400;
  font-size: 11px;
  color: var(--muted-2);
  letter-spacing: 0;
  text-transform: none;
  padding-left: 12px;
  border-left: 1px solid #2a2a2a;
}

.topbar-spacer { flex: 1; }

#sidebar-toggle {
  color: var(--muted-2);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  line-height: 1;
}
#sidebar-toggle:hover { background: #1a1a1a; color: #fff; }

.search-wrap {
  position: relative;
  width: 280px;
}
#search {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #fff;
  padding: 6px 10px 6px 28px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}
#search::placeholder { color: var(--muted); }
#search:focus { outline: none; border-color: var(--primary); }
.search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-size: 12px;
}
.search-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  background: #0a0a0a;
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid #2a2a2a;
}

.hub-cost-widget {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid #3b3b3b;
  border-radius: var(--radius-sm);
  background: #151515;
  color: #fff;
  text-align: left;
  line-height: 1.1;
}
.hub-cost-widget[hidden] { display: none; }
.hub-cost-widget:hover { border-color: var(--primary); background: #1d1d1d; }
.hub-cost-widget__label { grid-column: 1 / -1; color: var(--muted-2); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.hub-cost-widget strong { font-family: var(--font-mono); font-size: 12px; font-weight: 500; }
.hub-cost-widget small { color: var(--muted-2); font-size: 9px; white-space: nowrap; }
.hub-crm-widget.is-due { border-color: var(--primary); }
.hub-crm-widget.is-due strong { color: var(--primary); }
.hub-crm-widget.is-partial { border-color: var(--accent); }

/* ========================== Sidebar ========================== */
#sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 0;
}

.tool-group + .tool-group { margin-top: 18px; }

.tool-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 0 16px 6px;
}

.tool-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 7px 16px;
  gap: 10px;
  text-align: left;
  color: var(--text);
  font-size: 13px;
  border-left: 2px solid transparent;
  transition: background 0.08s;
}
.tool-item:hover {
  background: var(--surface-2);
}
.tool-item.active {
  background: var(--primary-bg);
  border-left-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 500;
}

.tool-icon { font-size: 14px; width: 18px; text-align: center; }
.tool-name { flex: 1; }
.tool-badge {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
}

/* ========================== Tabbar ========================== */
#tab-bar {
  grid-area: tabbar;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  padding: 0;
}
#tab-bar::-webkit-scrollbar { height: 4px; }

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--muted);
  min-width: 140px;
  max-width: 220px;
  cursor: pointer;
  position: relative;
  user-select: none;
}
.tab:hover { background: #ebebe6; color: var(--text); }
.tab.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 500;
}
.tab.active::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--primary);
}

.tab-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab-icon { font-size: 12px; }
.tab-close {
  font-size: 16px;
  line-height: 1;
  color: var(--muted-2);
  padding: 2px 4px;
  border-radius: 3px;
}
.tab-close:hover { background: var(--border); color: var(--text); }

/* ========================== Main / Frames ========================== */
#main {
  grid-area: main;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

#tool-frames {
  width: 100%;
  height: 100%;
  position: relative;
}
#tool-frames iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: none;
  background: var(--surface);
}

/* Platzhalter für nicht installierte Tools */
.tool-placeholder {
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 40px;
}
.placeholder-inner {
  max-width: 420px;
  text-align: center;
}
.placeholder-icon {
  font-size: 48px;
  opacity: 0.4;
  margin-bottom: 16px;
}
.placeholder-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}
.placeholder-subtitle {
  font-size: 12px;
  color: var(--accent);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 20px;
}
.placeholder-text {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.placeholder-text code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--text);
}

/* Empty State */
#empty-state {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  color: var(--muted);
}
.empty-mark {
  width: 64px;
  height: 64px;
  background: var(--primary);
  border-radius: var(--radius);
  margin-bottom: 24px;
  position: relative;
  opacity: 0.15;
}
.empty-mark::after {
  content: '';
  position: absolute;
  inset: 14px;
  background: var(--bg);
  border-radius: 3px;
}
.empty-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.empty-text {
  max-width: 360px;
  font-size: 13px;
  line-height: 1.6;
}
.empty-shortcuts {
  margin-top: 28px;
  display: grid;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.empty-shortcuts span {
  display: inline-block;
  padding: 2px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  margin-right: 6px;
}

/* ========================== Scrollbars ========================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ========================== User-Menu (Topbar, Platzhalter bis Login) ========================== */
.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 14px;
  margin-left: 8px;
  border-left: 1px solid #2a2a2a;
  opacity: 0.6;
}
.user-role {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted-2);
  background: #1a1a1a;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
