/* ============================================================
   layout.css — 1:1 from original LiveScatter3D/wwwroot/index.html
   ============================================================ */

/* Fill full viewport — same as original */
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  min-height: 600px;
  overflow: hidden;
}

/* ── Connection gate ── */
#connection-gate {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: var(--bg-main);
}
#connection-gate.gate-open { display: flex; }

.gate-shell {
  width: min(1180px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gate-panel {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  min-height: 0;
}

.gate-hero {
  padding: 16px 18px;
  position: relative;
}

.gate-theme-corner {
  position: absolute;
  top: 10px;
  right: 12px;
}

.gate-hero-head {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
}

.gate-terms {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gate-hero-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}


.gate-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  color: var(--txt-main);
}
.gate-sub {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--txt-soft);
}

.gate-terms-box {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-card);
  padding: 8px;
  font-size: 11px;
  color: var(--txt-main);
  line-height: 1.45;
}

.gate-terms-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gate-terms-warn {
  font-family: 'Segoe MDL2 Assets', sans-serif;
  font-size: 16px;
  line-height: 1;
  color: var(--error);
}

.gate-terms-content {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 8px;
}

.gate-terms-warn-large {
  font-family: 'Segoe MDL2 Assets', sans-serif;
  font-size: 30px;
  line-height: 1;
  color: var(--error);
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  margin-top: 0;
}

.gate-terms-copy p {
  margin: 0;
  padding-left: 18px;
}

.gate-terms-box ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.gate-terms-box li {
  margin: 3px 0;
}

.gate-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr);
  gap: 10px;
  min-height: 0;
}

.gate-status-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr);
  gap: 10px;
}

.gate-status-wrap {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-alt);
}
.gate-status-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--txt-muted);
  font-weight: 700;
  display: inline-block;
}

.gate-button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.gate-status-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  padding: 0 8px;
  height: 30px;
  border-radius: 4px;
  border: 1px solid;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-family: 'Segoe UI', 'Segoe UI Variable Text', sans-serif;
  cursor: default;
}
.gate-status-btn::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.gate-status-btn.connected { color: #107c10; background: #e6f4e6; border-color: #8bcb8b; }
.gate-status-btn.disconnected { color: #d13438; background: #fde8e8; border-color: #f1a0a0; }
.gate-status-btn.installing { color: #c47a1a; background: #fff3e0; border-color: #f3c57a; }
.gate-status-btn.testing { color: var(--brand); background: #e8f1fb; border-color: #9fc5ef; }


.gate-action-row { margin-top: 0; }
.gate-action-single { display: block; }
.gate-uniform-btn {
  height: 30px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.gate-download-btn {
  text-decoration: none;
}

.gate-devices-head { display: flex; align-items: center; justify-content: space-between; }
.gate-devices-head .gate-status-label { margin: 0; }
.gate-count {
  min-width: 20px;
  text-align: center;
  font-size: 10px;
  color: var(--txt-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  background: var(--bg-alt);
}

.gate-panel-devices {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 420px;
}

.gate-device-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-main);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gate-pager {
  display: grid;
  grid-template-columns: 88px 1fr 88px;
  gap: 6px;
  align-items: center;
}

.gate-pager-btn {
  height: 28px;
  padding: 0 8px;
}

.gate-pager-info {
  font-size: 10px;
  color: var(--txt-muted);
  text-align: center;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.gate-device-item {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px;
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
  background: var(--bg-card);
  text-align: left;
  font-family: 'Segoe UI', 'Segoe UI Variable Text', sans-serif;
  outline: none;
}
.gate-device-item:hover {
  border-color: var(--line);
  background: var(--bg-main);
}
.gate-device-item:focus,
.gate-device-item:focus-visible {
  outline: none;
  border-color: #9aa7b5;
  background: var(--bg-main);
  box-shadow: 0 0 0 1px rgba(154,167,181,.25);
}
.gate-device-item.selected {
  border-color: #9aa7b5;
  background: var(--bg-alt);
  box-shadow: inset 2px 0 0 #9aa7b5;
}

.gate-device-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa7b5;
}
.gate-device-dot.ok { background: #107c10; }
.gate-device-dot.err { background: #d13438; }

.gate-device-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.gate-device-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--txt-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gate-device-id {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

.gate-device-meta {
  font-size: 9px;
  color: var(--txt-muted);
  font-family: 'Segoe UI', 'Segoe UI Variable Text', sans-serif;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gate-device-state {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #107c10;
}
.gate-device-state.err { color: #d13438; }

.gate-empty {
  margin: auto 0;
  text-align: center;
  font-size: 12px;
  color: var(--txt-muted);
  padding: 20px 10px;
}

.gate-inline-refresh {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  font: inherit;
}
.gate-inline-refresh:hover { color: var(--brand-hover); }

.gate-connect-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: var(--bg-main);
}
.gate-panel-side {
  padding: 10px;
  display: grid;
  grid-template-rows: auto repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-height: 420px;
}

.gate-panel-side .gate-devices-head {
  margin-bottom: 0;
}

.gate-panel-side .gate-connect-stack {
  height: 100%;
}

.gate-panel-status {
  padding: 10px;
  display: block;
}

.gate-status-empty {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.gate-empty-note {
  font-size: 11px;
  color: var(--txt-muted);
  text-align: center;
  line-height: 1.4;
}

.gate-empty-note-line {
  display: block;
}

.gate-empty-note a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.gate-hint {
  font-size: 12px;
  color: var(--txt-muted);
  line-height: 1.4;
  min-height: 44px;
}

.gate-connect-note {
  font-size: 10px;
  color: var(--txt-muted);
}

body.dark-mode #connection-gate {
  background: var(--bg-main);
}
body.dark-mode .gate-status-btn.connected  { background: #1a2e1a; color: #4caf50; border-color: #2d5a2d; }
body.dark-mode .gate-status-btn.disconnected { background: #2d1414; color: #e05252; border-color: #5a2a2a; }
body.dark-mode .gate-status-btn.installing { background: #2d1f00; color: #f5a623; border-color: #5a3d00; }
body.dark-mode .gate-status-btn.testing    { background: #0d2240; color: #4da3e8; border-color: #1e4a80; }
body.dark-mode .gate-terms-box { border-color: var(--line); }
body.dark-mode .gate-terms-box { background: var(--bg-card); }
body.dark-mode .gate-device-list { border-color: var(--line); background: var(--bg-main); }
body.dark-mode .gate-device-item { background: var(--bg-card); border-color: var(--line); }
body.dark-mode .gate-device-item:hover { background: #202020; border-color: #3f3f3f; }
body.dark-mode .gate-device-item.selected { background: #252525; border-color: #666; box-shadow: inset 2px 0 0 #666; }

@media (max-width: 900px) {
  .gate-theme-corner { top: 8px; right: 10px; }
  .gate-main-grid { grid-template-columns: 1fr; }
  .gate-status-row { grid-template-columns: 1fr; }
  .gate-panel-devices,
  .gate-panel-side { min-height: 0; }
  .gate-panel-side { grid-template-rows: auto auto auto auto; }
  .gate-device-list { max-height: 300px; }
  .gate-button-grid { grid-template-columns: 1fr; }
}

/* ── Header ── */
#header {
  display: flex; align-items: center; gap: 12px;
  height: 40px;
  padding: 0 12px 0 calc(170px + 12px);
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0; z-index: 10;
}


/* ── Header icon buttons ── */
.hdr-icon-btn {
  display: flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px; color: var(--txt-soft);
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
  font-family: 'Segoe UI', sans-serif;
}
.hdr-icon-btn:hover {
  background: var(--bg-main);
  border-color: #b8c8da;
  color: var(--txt-main);
}
body.dark-mode .hdr-icon-btn:hover { border-color: #555; }
.hdr-btn-icon {
  font-family: 'Segoe MDL2 Assets', sans-serif;
  font-size: 14px; line-height: 1;
}
.hdr-btn-label { font-size: 12px; font-weight: 600; }

/* Connect = grün wenn verbunden */
.hdr-connect.connected {
  border-color: var(--ok);
  color: var(--ok);
}
.hdr-connect.connected:hover {
  background: var(--ok-bg);
  border-color: var(--ok);
}

/* Dark mode active state */
.hdr-icon-btn.dm-active {
  background: #23272e;
  border-color: #444c55;
  color: #e8edf3;
}
.hdr-icon-btn.dm-active:hover {
  background: #2c3139;
  border-color: #5a6370;
}
#device-select-wrap { position: relative; }
#device-select-btn {
  display: flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px; color: var(--txt-main);
  cursor: pointer; white-space: nowrap; min-width: 200px;
  transition: background .12s, border-color .12s;
}
#device-select-btn:hover { background: #f0f4f8; border-color: #b8c8da; }
body.dark-mode #device-select-btn:hover { background: #2a2a2a; border-color: #444; }
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--txt-muted); flex-shrink: 0; }
.conn-dot.ok  { background: var(--ok); }
.conn-dot.err { background: var(--error); }
#device-select-btn .device-name { flex: 1; text-align: left; }
#device-select-btn .chevron { font-size: 9px; color: var(--txt-muted); font-family: 'Segoe MDL2 Assets', sans-serif; }

#device-dropdown {
  display: none; position: absolute; top: calc(100% + 4px); right: 0;
  min-width: 240px; background: var(--bg-card);
  border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,.10); z-index: 100; overflow: hidden;
}
#device-dropdown.open { display: block; }
.device-dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; font-size: 12px; color: var(--txt-main);
  cursor: pointer; transition: background .1s;
}
.device-dropdown-item:hover { background: #f5f7fa; }
body.dark-mode .device-dropdown-item:hover { background: #2a2a2a; }
.device-dropdown-sep { height: 1px; background: var(--line); margin: 4px 0; }
.device-dropdown-add {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; font-size: 12px; color: var(--brand);
  font-weight: 600; cursor: pointer; transition: background .1s;
}
.device-dropdown-add:hover { background: #f0f0f0; }
body.dark-mode .device-dropdown-add:hover { background: #2a2a2a; }
.device-dropdown-forget {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; font-size: 11px; color: #888;
  cursor: pointer; transition: background .1s;
}
.device-dropdown-forget:hover { background: #fde8e8; color: #d13438; }
body.dark-mode .device-dropdown-forget:hover { background: #2d1414; color: var(--error); }

/* ── Body ── */
#body { display: flex; flex: 1; min-height: 0; overflow: hidden; }

/* ── Sidebar ── */
#sidebar {
  width: 170px; flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
}
.nav-group { display: flex; flex-direction: column; padding: 4px 0; }
.nav-sep { height: 1px; background: var(--line); margin: 2px 10px; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px 0 12px;
  font-size: 12px; color: var(--txt-soft);
  cursor: pointer; border-left: 3px solid transparent;
  transition: background .1s, color .1s;
  user-select: none; text-decoration: none;
}
.nav-item:hover { background: #f5f7fa; color: var(--txt-main); }
body.dark-mode .nav-item:hover { background: #252525; }
.nav-item.active {
  background: #e0e0e0; color: #1a1a1a;
  border-left-color: #555; font-weight: 600;
}
body.dark-mode .nav-item.active {
  background: #303030; color: #e8e8e8;
  border-left-color: #888;
}
.nav-item .nav-icon {
  font-family: 'Segoe MDL2 Assets', sans-serif;
  font-size: 14px; width: 18px; text-align: center; flex-shrink: 0;
}
.nav-item .nav-label { flex: 1; }
.nav-disabled { opacity: 0.35; cursor: not-allowed !important; pointer-events: none; }
.nav-sub { display: none; flex-direction: column; }
.nav-sub.open { display: flex; }
.nav-sub .nav-item { height: 28px; padding-left: 32px; font-size: 11px; }

/* ── Content ── */
#content {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden; background: var(--bg-main);
}

/* ── Page ── */
.page { display: none; flex: 1; flex-direction: column; min-height: 0; overflow: hidden; }
.page.active { display: flex; }

/* Overview page: column layout matching original tab structure */
#page-overview { flex-direction: column; }

/* ── Toolbar ── */
.toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
body.dark-mode .toolbar { background: rgba(30,30,30,.92); }
.toolbar-sep { flex: 1; }
.toolbar-title {
  font-size: 12px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--txt-soft);
}
.toolbar-label {
  font-size: 11px; color: var(--txt-muted);
}

/* ── Empty state ── */
#empty-state { display: flex; flex: 1; align-items: center; justify-content: center; }
.empty-card {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 32px 48px; background: var(--bg-card);
  border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06); text-align: center;
}
.empty-card-icon { font-family: 'Segoe MDL2 Assets', sans-serif; font-size: 36px; color: var(--txt-muted); }
.empty-card-title { font-size: 13px; font-weight: 600; color: var(--txt-main); }
.empty-card-sub { font-size: 12px; color: var(--txt-muted); max-width: 280px; line-height: 1.5; }

/* ── Status bar ── */
#statusbar {
  height: 40px; display: flex; align-items: center; gap: 6px; padding: 0 12px;
  background: var(--bg-card); border-top: 1px solid var(--line); flex-shrink: 0;
  position: relative;
}
#statusbar-text { font-size: 11px; color: var(--txt-muted); }
#statusbar-sep  { flex: 1; }
#statusbar-copy {
  font-size: 11px; font-weight: 400; color: var(--txt-muted);
  white-space: nowrap; font-family: 'Segoe UI', 'Segoe UI Variable Text', sans-serif;
  position: absolute; left: 50%; transform: translateX(-50%);
}
#statusbar-tg-link {
  font-size: 11px; font-weight: 400; color: var(--txt-muted);
  font-family: 'Segoe UI', 'Segoe UI Variable Text', sans-serif;
  text-decoration: underline; text-underline-offset: 2px;
}
#statusbar-tg-link:hover { color: var(--txt-main); }

/* Icon buttons in statusbar — kleiner als Header-Variante */
.sb-icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: transparent; border: 1px solid var(--line); border-radius: 4px;
  color: var(--txt-soft); cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.sb-icon-btn:hover { background: var(--bg-main); border-color: #b8c8da; color: var(--txt-main); }
body.dark-mode .sb-icon-btn:hover { border-color: #555; }
.sb-icon-btn .hdr-btn-icon { font-size: 13px; line-height: 1; }
.sb-icon-btn.dm-active { background: #23272e; border-color: #444c55; color: #e8edf3; }
