/* ==========================================================================
   POLISH BOARD STUDIO — Workspace, Viewport & Docks
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--surface-alabaster);
  font-family: var(--font-body);
  color: var(--text-ink);
  user-select: none;
}

/* ========================================================== */
/* PANNABLE CANVAS VIEWPORT                                   */
/* ========================================================== */
#viewport {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
  cursor: grab;
  touch-action: none;
  background-color: var(--surface-alabaster);
  background-image: radial-gradient(var(--border-strong) 1.5px, transparent 1.5px);
  background-size: 34px 34px;
}

#viewport.is-dragging {
  cursor: grabbing;
}

#viewport.is-connecting {
  cursor: crosshair;
}

#board-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 14000px;
  height: 6000px;
  background: transparent;
  transform-origin: 0 0;
  will-change: transform;
}

/* Dynamic SVG Connectors Layer */
#svg-connections {
  position: absolute;
  top: 0;
  left: 0;
  width: 14000px;
  height: 6000px;
  pointer-events: none;
  z-index: 5;
}

.flow-line {
  fill: none;
  stroke: #736D67;
  stroke-width: 3.5px;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 8 6;
  pointer-events: stroke;
  cursor: pointer;
  transition: stroke 0.2s, stroke-width 0.2s;
}

.flow-line:hover,
.flow-line.is-selected {
  stroke: var(--brand-noir) !important;
  stroke-width: 4.5px !important;
  stroke-dasharray: none !important;
}

.flow-line.color-gold { stroke: var(--brand-gold); }
.flow-line.color-noir { stroke: var(--brand-noir); }
.flow-line.color-rose { stroke: var(--accent-rose); }
.flow-line.color-green { stroke: var(--accent-green); }

/* Temporary line being drawn */
.temp-flow-line {
  fill: none;
  stroke: var(--brand-gold);
  stroke-width: 3px;
  stroke-linecap: round;
  stroke-dasharray: 6 6;
  pointer-events: none;
}

/* Floating Centered Pill Labels on Arrows */
.connector-label-pill {
  position: absolute;
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 4px 12px;
  font-family: var(--font-body);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-slate);
  box-shadow: 0 4px 12px rgba(26, 23, 21, 0.08);
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  white-space: nowrap;
  z-index: 40;
  transition: all 0.15s ease;
}

.connector-label-pill:hover,
.connector-label-pill.is-selected {
  border-color: var(--brand-noir);
  color: var(--brand-noir);
  box-shadow: 0 6px 16px rgba(26, 23, 21, 0.14);
}

/* ========================================================== */
/* TOP DOCK: BRAND, TITLE, ACTIONS & NAVIGATION               */
/* ========================================================== */
header.studio-dock {
  position: fixed;
  top: 12px;
  left: 18px;
  right: 18px;
  height: 56px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.6rem;
  box-shadow: 0 10px 30px rgba(26, 23, 21, 0.07);
  z-index: 1000;
  gap: 0.75rem;
}

.dock-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-mark-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.15s;
}

.brand-mark-btn:hover {
  opacity: 0.9;
  transform: translateY(-0.5px);
}

.brand-logo-mark {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 0 10px rgba(226, 199, 153, 0.45));
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), filter 0.25s ease;
}

.brand-mark-btn:hover .brand-logo-mark {
  transform: scale(1.06);
  filter: drop-shadow(0 0 16px rgba(226, 199, 153, 0.75));
}

.brand-text-lockup {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  line-height: 1;
  gap: 2px;
}

.brand-name {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--brand-noir);
  line-height: 1.1;
}

.brand-subtitle {
  font-family: var(--font-heading);
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #7A5E32;
  line-height: 1;
  white-space: nowrap;
}

body.theme-dark .brand-subtitle {
  color: #E2C799;
}

.dock-divider {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin: 0 4px;
}

/* Board Title Input */
.board-title-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--brand-noir);
  padding: 4px 8px;
  outline: none;
  min-width: 140px;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.15s, background 0.15s;
}

.board-title-input:hover {
  background: var(--surface-subtle);
}

.board-title-input:focus {
  background: #FFFFFF;
  border-color: var(--brand-gold);
}

.save-indicator {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-green);
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
}

.save-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
}

/* Center History & Tool Actions */
.dock-center {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.dock-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-slate);
  height: 32px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.dock-svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.dock-btn:focus-visible {
  outline: 2px solid var(--brand-gold, #C5A880);
  outline-offset: 2px;
}

.dock-btn:hover {
  background: var(--surface-subtle);
  color: var(--text-ink);
  border-color: var(--border-subtle);
}

.dock-btn.btn-present {
  background: var(--brand-noir);
  color: #FFFFFF;
  border-color: var(--brand-noir);
  padding: 0 13px;
  border-radius: 20px;
  font-weight: 800;
}

.dock-btn.btn-present:hover {
  background: #262321;
}

/* Right Actions */
.dock-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ========================================================== */
/* LEFT CREATION TOOLBAR DOCK                                 */
/* ========================================================== */
aside.creation-toolbar {
  position: fixed;
  top: 50%;
  left: 20px;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 12px 36px rgba(26, 23, 21, 0.09);
  z-index: 1000;
}

.tool-item {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: transparent;
  border: none;
  color: var(--text-slate);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.tool-item:hover {
  background: var(--surface-subtle);
  color: var(--text-ink);
  transform: scale(1.06);
}

.tool-item.active {
  background: var(--brand-noir);
  color: #FFFFFF;
}

body.theme-dark .tool-item.active {
  background: var(--brand-gold);
  color: #080706;
}

.tool-icon {
  font-size: 1.15rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.tool-icon svg {
  display: block;
}

.tool-label {
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tool-item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 56px;
  background: var(--brand-noir);
  color: #FFFFFF;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  transform: translateX(-4px);
  z-index: 2000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.tool-item[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(0);
}

/* ========================================================== */
/* VIEWPORT ZOOM HUD (BOTTOM RIGHT)                           */
/* ========================================================== */
.viewport-tools {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 1000;
  box-shadow: 0 10px 26px rgba(26, 23, 21, 0.08);
}

.vp-btn {
  background: transparent;
  border: none;
  color: var(--text-ink);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.vp-btn:hover {
  background: var(--surface-subtle);
}

.zoom-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-slate);
  min-width: 44px;
  text-align: center;
  font-family: var(--font-mono);
}

/* ========================================================== */
/* PRESENTATION MODE CONTROLS                                 */
/* ========================================================== */
.presentation-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  border-radius: 40px;
  padding: 8px 18px;
  display: none;
  align-items: center;
  gap: 16px;
  z-index: 2000;
  box-shadow: 0 16px 40px rgba(26, 23, 21, 0.15);
}

.is-presenting .presentation-bar {
  display: flex;
}

.is-presenting header.studio-dock,
.is-presenting aside.creation-toolbar,
.is-presenting .viewport-tools,
.is-presenting .card-port,
.is-presenting .resize-handle {
  display: none !important;
}

.present-nav-btn {
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-ink);
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
}

.present-nav-btn:hover {
  background: var(--brand-noir);
  color: #FFFFFF;
  border-color: var(--brand-noir);
}

.present-slide-info {
  font-family: var(--font-heading);
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--brand-noir);
}

/* ========================================================== */
/* THEME: OBSIDIAN DARK NOIR WITH CHAMPAGNE ACCENTS           */
/* ========================================================== */
body.theme-dark {
  --surface-alabaster: #080706;
  --surface-card: #12100E;
  --surface-subtle: #1C1917;
  --surface-subtle-hover: #262320;
  --text-ink: #F5E6D3;
  --text-slate: #C5BAAD;
  --text-muted: #8E8478;
  --border-subtle: rgba(226, 199, 153, 0.18);
  --border-strong: rgba(226, 199, 153, 0.35);
  --brand-noir: #F5E6D3;
  --bg-dots: rgba(226, 199, 153, 0.15);
}

body.theme-dark #viewport {
  background-color: #080706;
  background-image: radial-gradient(rgba(226, 199, 153, 0.16) 1.5px, transparent 1.5px);
}

body.theme-dark header.studio-dock,
body.theme-dark aside.creation-toolbar,
body.theme-dark .viewport-tools,
body.theme-dark .tool-flyout,
body.theme-dark .template-modal-card,
body.theme-dark .shortcuts-card {
  background: rgba(18, 16, 14, 0.94);
  border-color: rgba(226, 199, 153, 0.22);
  color: #F5E6D3;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

body.theme-dark .board-title-input {
  color: #F5E6D3;
}

body.theme-dark .board-title-input:focus {
  background: #1C1917;
}

body.theme-dark .dock-btn {
  color: #C5BAAD;
}

body.theme-dark .dock-btn:hover {
  background: #262320;
  color: #F5E6D3;
}

body.theme-dark .board-frame,
body.theme-dark .table-card,
body.theme-dark .pricing-card,
body.theme-dark .form-field-card,
body.theme-dark .script-bubble {
  background: #141210 !important;
  border-color: rgba(226, 199, 153, 0.22) !important;
  color: #F5E6D3 !important;
}

body.theme-dark .board-frame h2,
body.theme-dark .frame-headline,
body.theme-dark .table-title,
body.theme-dark .price-figure,
body.theme-dark .form-card-title {
  color: #F5E6D3 !important;
}

body.theme-dark .content-box {
  background: #1A1715 !important;
  border-color: rgba(226, 199, 153, 0.15) !important;
}

/* ========================================================== */
/* MARQUEE SELECTION RECTANGLE                                */
/* ========================================================== */
.selection-marquee {
  position: absolute;
  border: 1.5px solid var(--brand-gold, #E2C799);
  background: rgba(226, 199, 153, 0.15);
  pointer-events: none;
  z-index: 999;
  border-radius: 4px;
}

.is-multi-selected {
  outline: 2px solid var(--brand-gold, #E2C799) !important;
  outline-offset: 4px !important;
  box-shadow: 0 0 20px rgba(226, 199, 153, 0.3) !important;
}

/* ========================================================== */
/* BOTTOM-RIGHT MINIMAP HUD                                   */
/* ========================================================== */
.minimap-hud {
  position: fixed;
  bottom: 64px;
  right: 20px;
  width: 196px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 12px 36px rgba(26, 23, 21, 0.12);
  z-index: 990;
  transition: all 0.2s ease;
}

.minimap-hud.is-collapsed .minimap-body {
  display: none;
}

.minimap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  padding: 0 4px;
}

.minimap-title {
  font-family: var(--font-mono, monospace);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-slate);
}

.minimap-toggle {
  background: transparent;
  border: none;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  color: var(--text-slate);
  padding: 0 4px;
}

.minimap-body {
  width: 180px;
  height: 110px;
  border-radius: 10px;
  overflow: hidden;
  cursor: crosshair;
}

.minimap-body canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ========================================================== */
/* TOOLBAR FLYOUT MENUS (SHAPES, STICKIES, PEN)               */
/* ========================================================== */
.tool-flyout {
  position: fixed;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 14px 40px rgba(26, 23, 21, 0.14);
  z-index: 1010;
  min-width: 190px;
  animation: flyoutFadeIn 0.15s ease-out;
}

@keyframes flyoutFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.flyout-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-slate);
  margin-bottom: 8px;
}

.flyout-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.flyout-btn {
  background: var(--surface-subtle, #F5F2EB);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-ink);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.flyout-btn:hover {
  background: var(--brand-noir, #1A1715);
  color: #FFFFFF;
}

.flyout-grid-swatches {
  display: flex;
  gap: 8px;
}

.swatch-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: transform 0.15s;
}

.swatch-btn:hover {
  transform: scale(1.2);
}

.flyout-stroke-sizes {
  display: flex;
  gap: 4px;
}

.stroke-size-btn {
  flex: 1;
  background: var(--surface-subtle, #F5F2EB);
  border: none;
  border-radius: 6px;
  padding: 5px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-ink);
}

.stroke-size-btn:hover {
  background: var(--brand-noir, #1A1715);
  color: #FFFFFF;
}

.toolbar-divider {
  width: 24px;
  height: 1px;
  background: var(--border-subtle);
  margin: 4px auto;
}

/* ========================================================== */
/* TEMPLATE PICKER MODAL                                      */
/* ========================================================== */
.template-modal,
.shortcuts-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 7, 6, 0.65);
  backdrop-filter: blur(12px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.template-modal-card {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: 28px;
  max-width: 820px;
  width: 100%;
  padding: 2.2rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.8rem;
}

.modal-title {
  font-family: var(--font-heading, sans-serif);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--brand-noir);
}

.modal-subtitle {
  font-size: 0.88rem;
  color: var(--text-slate);
  margin-top: 4px;
}

.modal-close-btn {
  background: var(--surface-subtle);
  border: none;
  color: var(--text-slate);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.9rem;
  cursor: pointer;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.2rem;
}

.template-option-card {
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 1.4rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.template-option-card:hover {
  background: #FFFFFF;
  border-color: var(--brand-gold);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(26, 23, 21, 0.08);
}

body.theme-dark .template-option-card {
  background: #181614;
}

body.theme-dark .template-option-card:hover {
  background: #221F1C;
  border-color: #E2C799;
}

.template-badge {
  font-family: var(--font-mono, monospace);
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--brand-gold);
  margin-bottom: 0.5rem;
}

.template-option-card h4 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--brand-noir);
  margin-bottom: 0.4rem;
}

.template-option-card p {
  font-size: 0.84rem;
  color: var(--text-slate);
  line-height: 1.45;
  flex-grow: 1;
  margin-bottom: 0.8rem;
}

.template-action-link {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--brand-gold);
}

/* ========================================================== */
/* SHORTCUTS MODAL                                            */
/* ========================================================== */
.shortcuts-card {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  max-width: 480px;
  width: 100%;
  padding: 1.8rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.shortcut-row:last-child {
  border-bottom: none;
}

kbd {
  background: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 3px 8px;
  font-family: var(--font-mono, monospace);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--brand-noir);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
