/* browse.4diget.de – UI
 * Multi-URL-Browser mit vertikalen Tabs, Kachelraster, Vault & Automation.
 * Autor: Martin Kornmüller / 4diget
 */

:root {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --panel: #ffffff;
  --panel-2: #f1f5f9;
  --line: #cbd5e1;
  --line-strong: #94a3b8;
  --text: #0f172a;
  --text-soft: #475569;
  --text-invert: #e2e8f0;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --toolbar-h: 48px;
  --sidebar-w: 260px;
  --radius: 8px;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--sans); color: var(--text); background: var(--panel-2); }

#app {
  height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--toolbar-h) 1fr;
  grid-template-areas: "toolbar toolbar" "sidebar main";
}

/* ---------- Toolbar ---------- */
.toolbar {
  grid-area: toolbar;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: var(--bg);
  color: var(--text-invert);
  border-bottom: 1px solid #000;
}
.toolbar .brand { font-weight: 700; letter-spacing: .2px; margin-right: 6px; white-space: nowrap; }
.toolbar .brand small { color: #93c5fd; font-weight: 500; }
.toolbar .sep { width: 1px; height: 24px; background: #334155; margin: 0 4px; }
.toolbar .spacer { flex: 1; }

.btn {
  font: inherit;
  font-size: 13px;
  color: var(--text-invert);
  background: var(--bg-2);
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover { background: #334155; }
.btn.primary { background: var(--accent); border-color: var(--accent-2); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.icon { padding: 6px 8px; }

.layout-picker { display: inline-flex; align-items: center; gap: 6px; color: var(--text-invert); font-size: 13px; }
.layout-picker select { font: inherit; padding: 4px 6px; border-radius: 6px; border: 1px solid #334155; background: var(--bg-2); color: var(--text-invert); }

/* ---------- Sidebar / vertikale Tabs ---------- */
.sidebar {
  grid-area: sidebar;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head {
  padding: 8px 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-soft);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.tablist { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.tab {
  display: grid;
  grid-template-columns: 20px 1fr 22px;
  align-items: start;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 4px;
}
.tab:hover { background: var(--panel-2); }
.tab.active { background: #eff6ff; border-color: #bfdbfe; }
.tab .fav { width: 18px; height: 18px; border-radius: 4px; background: var(--panel-2); margin-top: 1px; flex: none; object-fit: contain; }
.tab .meta { min-width: 0; }
.tab .title { font-size: 13px; font-weight: 600; line-height: 1.25; word-break: break-word; } /* voller Titel, mehrzeilig */
.tab .url { font-size: 11px; color: var(--text-soft); word-break: break-all; margin-top: 2px; }
.tab .x { border: none; background: transparent; color: var(--text-soft); cursor: pointer; font-size: 15px; line-height: 1; padding: 2px; border-radius: 4px; }
.tab .x:hover { background: #fee2e2; color: var(--err); }
.tab .assign { font-size: 10px; color: var(--accent); margin-top: 3px; }

.sidebar-foot { padding: 8px; border-top: 1px solid var(--line); display: flex; gap: 6px; }
.sidebar-foot .btn { color: var(--text); background: var(--panel-2); border-color: var(--line); flex: 1; justify-content: center; }
.sidebar-foot .btn:hover { background: #e2e8f0; }

/* ---------- Main / Kachelraster ---------- */
.main { grid-area: main; min-width: 0; min-height: 0; padding: 8px; background: var(--panel-2); }
.grid {
  height: 100%;
  display: grid;
  gap: 8px;
}
.tile {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0; min-height: 0;
}
.tile.focused { border-color: var(--accent); box-shadow: 0 0 0 2px #bfdbfe; }
.tile-head {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.tile-head .t-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-soft); }
.tile-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }
.tile.focused .tile-head .dot { background: var(--accent); }
.tile-head .mini { border: none; background: transparent; cursor: pointer; color: var(--text-soft); padding: 2px 4px; border-radius: 4px; font-size: 12px; }
.tile-head .mini:hover { background: #e2e8f0; }
.tile-body { flex: 1; position: relative; min-height: 0; }
.tile iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.tile .empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--text-soft); font-size: 13px; text-align: center; padding: 12px;
}
.tile .frame-warn {
  position: absolute; left: 8px; right: 8px; bottom: 8px;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  font-size: 11px; padding: 6px 8px; border-radius: 6px; display: none;
}
.tile.blocked .frame-warn { display: block; }

/* ---------- Drawer / Panels ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.35);
  display: none; z-index: 40;
}
.drawer-backdrop.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(460px, 92vw);
  background: var(--panel); box-shadow: -8px 0 30px rgba(0,0,0,.2);
  transform: translateX(100%); transition: transform .18s ease;
  display: flex; flex-direction: column; z-index: 41;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 15px; }
.drawer-body { padding: 14px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-soft); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text);
}
.field textarea { min-height: 90px; font-family: var(--mono); font-size: 12px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.btn-light { font: inherit; font-size: 13px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; cursor: pointer; }
.btn-light:hover { background: #e2e8f0; }
.btn-light.danger { color: var(--err); border-color: #fecaca; background: #fef2f2; }
.btn-light.ok { color: #fff; background: var(--accent); border-color: var(--accent-2); }

/* Vault */
.vault-list, .scn-list { list-style: none; margin: 0; padding: 0; }
.vault-item, .scn-item { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; }
.vault-item .vi-head, .scn-item .si-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vault-item .vi-name, .scn-item .si-name { font-weight: 600; font-size: 13px; }
.vault-item .vi-url { font-size: 11px; color: var(--text-soft); word-break: break-all; }
.vault-item .vi-actions, .scn-item .si-actions { display: flex; gap: 6px; }
.chip { font-size: 11px; padding: 2px 6px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; }
.chip:hover { background: #e2e8f0; }

.locked-note { text-align: center; color: var(--text-soft); font-size: 13px; padding: 12px; }

/* Automation results */
.run-log { font-family: var(--mono); font-size: 12px; background: #0b1220; color: #cbd5e1; border-radius: 6px; padding: 10px; max-height: 260px; overflow: auto; white-space: pre-wrap; }
.run-log .ok { color: #4ade80; }
.run-log .err { color: #f87171; }
.run-log .warn { color: #fbbf24; }
.run-log .info { color: #93c5fd; }
.step-badge { display: inline-block; min-width: 18px; text-align: center; margin-right: 6px; }

.hint { font-size: 12px; color: var(--text-soft); background: var(--panel-2); border: 1px dashed var(--line-strong); border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; }
.kbd { font-family: var(--mono); font-size: 11px; background: #e2e8f0; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; }
