/* =========================================================
   Data Engineer Whiteboard — Design System
   ========================================================= */

:root {
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --bg: #1a1d23;
  --bg-elevated: #22262e;
  --bg-sidebar: #16191f;
  --bg-toolbar: #1e2229;
  --bg-canvas: #1c1f26;
  --bg-hover: #2a303a;
  --bg-active: #323942;

  --border: #2e3540;
  --border-subtle: #252a33;

  --text: #e8eaed;
  --text-muted: #9aa3b2;
  --text-dim: #6b7380;

  --accent: #3d9cf0;
  --accent-hover: #5aaff5;
  --accent-soft: rgba(61, 156, 240, 0.15);

  --success: #3ecf8e;
  --warning: #f0b429;
  --danger: #f07178;

  --aws: #ff9900;
  --azure: #0078d4;
  --gcp: #4285f4;
  --databricks: #ff3621;
  --spark: #e25a1c;
  --kafka: #231f20;
  --postgres: #336791;
  --sticky: #f5d76e;

  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);

  --sidebar-w: 280px;
  --toolbar-h: 52px;
  --transition: 150ms ease;
}

[data-theme="light"] {
  --bg: #f4f6f9;
  --bg-elevated: #ffffff;
  --bg-sidebar: #eef1f6;
  --bg-toolbar: #ffffff;
  --bg-canvas: #f0f2f5;
  --bg-hover: #e4e8ef;
  --bg-active: #d8dee8;
  --border: #d0d7e2;
  --border-subtle: #e2e6ed;
  --text: #1a1d23;
  --text-muted: #5a6475;
  --text-dim: #8a93a3;
  --accent-soft: rgba(61, 156, 240, 0.12);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ---------- Toolbar ---------- */

.toolbar {
  height: var(--toolbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}

.toolbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
  flex-shrink: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  border-radius: var(--radius-sm);
  letter-spacing: -0.5px;
}

.brand-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .brand-name {
    display: none;
  }
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar-actions {
  margin-left: auto;
}

.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.tb-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.tb-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.tb-btn-accent {
  background: var(--accent);
  color: #fff;
  padding: 0 12px;
}

.tb-btn-accent:hover {
  background: var(--accent-hover);
  color: #fff;
}

.tb-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.tb-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  height: 32px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.tb-toggle input {
  accent-color: var(--accent);
  cursor: pointer;
}

.tool-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
}

/* ---------- Main Layout ---------- */

.main {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
  transition: transform 200ms ease, width 200ms ease, margin 200ms ease;
}

.sidebar-search {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-search input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
}

.sidebar-search input:focus {
  border-color: var(--accent);
}

.sidebar-categories {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.category {
  border-bottom: 1px solid var(--border-subtle);
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-align: left;
}

.category-header:hover {
  background: var(--bg-hover);
}

.category-chevron {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-dim);
  transition: transform var(--transition);
}

.category.open .category-chevron {
  transform: rotate(90deg);
}

.category-body {
  display: none;
  padding: 4px 8px 12px;
}

.category.open .category-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.category-body.list {
  grid-template-columns: 1fr;
}

.palette-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 10px;
  cursor: grab;
  user-select: none;
  transition: background var(--transition), border-color var(--transition);
}

.palette-item:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border);
}

.palette-item:active {
  cursor: grabbing;
}

.palette-item.list-item {
  flex-direction: row;
  justify-content: flex-start;
  gap: 10px;
  padding: 8px 10px;
  font-size: 12px;
}

.palette-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.palette-icon svg {
  width: 18px;
  height: 18px;
}

.template-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.template-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.template-item strong {
  font-size: 12px;
  font-weight: 600;
}

.template-item span {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---------- Canvas ---------- */

.canvas-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  background: var(--bg-canvas);
  overflow: hidden;
}

#whiteboard {
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
  outline: none;
  touch-action: none;
}

#whiteboard.panning,
#whiteboard.space-pan {
  cursor: grab;
}

#whiteboard.panning:active,
#whiteboard.space-pan:active {
  cursor: grabbing;
}

#whiteboard.drawing {
  cursor: crosshair;
}

#whiteboard.erasing {
  cursor: cell;
}

.text-editor {
  position: absolute;
  min-width: 40px;
  min-height: 24px;
  padding: 4px 8px;
  border: 2px solid var(--accent);
  border-radius: 2px;
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  outline: none;
  z-index: 30;
  white-space: pre-wrap;
  word-break: break-word;
}

.canvas-status {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 12px;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  pointer-events: none;
  z-index: 5;
}

.zoom-controls {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 5;
}

.zoom-controls button {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
}

.zoom-controls button:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ---------- Presentation Mode ---------- */

body.presentation .toolbar,
body.presentation .sidebar,
body.presentation .site-footer {
  display: none;
}

body.presentation .canvas-status,
body.presentation .zoom-controls {
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}

body.presentation .canvas-wrap:hover .canvas-status,
body.presentation .canvas-wrap:hover .zoom-controls {
  opacity: 1;
  pointer-events: auto;
}

body.presentation .main {
  height: 100vh;
}

/* ---------- Modal ---------- */

.modal {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 480px;
  width: calc(100% - 32px);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.modal-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-card h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.projects-list {
  max-height: 360px;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.project-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
}

.project-row:hover {
  border-color: var(--accent);
}

.project-row .info {
  flex: 1;
  min-width: 0;
}

.project-row .info strong {
  display: block;
  font-size: 13px;
}

.project-row .info small {
  color: var(--text-dim);
  font-size: 11px;
}

.project-row .actions {
  display: flex;
  gap: 4px;
}

.project-row .actions button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.project-row .actions button:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.modal-card footer {
  display: flex;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
}

.btn-primary,
.btn-secondary {
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

/* ---------- Site footer (CTA) ---------- */

.site-footer {
  flex-shrink: 0;
  padding: 8px 16px 10px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-toolbar);
  text-align: center;
}

.site-footer > p {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-dim);
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.site-footer a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.seo-panel {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.seo-panel p {
  margin: 0 auto;
  max-width: 920px;
  font-size: 10px;
  line-height: 1.45;
  color: var(--text-dim);
}

.seo-panel strong {
  color: var(--text-muted);
  font-weight: 600;
}

/* H1 semântico para SEO/a11y — não compete com a UI do canvas */
.seo-h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--text);
  z-index: 100;
  animation: toast-in 200ms ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ---------- Scrollbar ---------- */

.sidebar-categories::-webkit-scrollbar,
.projects-list::-webkit-scrollbar {
  width: 6px;
}

.sidebar-categories::-webkit-scrollbar-thumb,
.projects-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ---------- Empty hint ---------- */

.sidebar-empty {
  padding: 16px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}
