* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  user-select: none;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Ensure .hidden ALWAYS wins over role or flex classes */
.hidden {
  display: none !important;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* 1. Fixed Floating Flowchart Input Window */
.floating-table-window {
  position: fixed;
  top: 52px;
  left: 12px;
  width: 800px;
  height: calc(100vh - 96px);
  min-width: 380px;
  min-height: 220px;
  max-width: calc(100vw - 12px);
  max-height: calc(100vh - 8px);
  resize: both;
  overflow: hidden;
  backdrop-filter: blur(8px);
  z-index: 60;
}

.floating-table-window.maximized {
  top: 6px !important;
  left: 6px !important;
  width: calc(100vw - 12px) !important;
  height: calc(100vh - 48px) !important;
  resize: none !important;
}

.floating-table-window.collapsed {
  height: auto !important;
  min-height: 0 !important;
  resize: none !important;
}

/* 2. Separate Draggable & Resizable Sticky Notes Window */
.floating-notes-window {
  position: fixed;
  top: 64px;
  right: 16px;
  width: 380px;
  height: 490px;
  min-width: 300px;
  min-height: 220px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  resize: both;
  overflow: hidden;
  backdrop-filter: blur(8px);
  z-index: 65;
}

.floating-notes-window.collapsed {
  height: auto !important;
  min-height: 0 !important;
  resize: none !important;
}

@media (max-width: 768px) {
  .floating-table-window {
    width: calc(100vw - 16px);
    height: 65vh;
  }
  .floating-notes-window {
    width: calc(100vw - 24px);
    height: 55vh;
    right: 12px;
  }
}

/* Spreadsheet Table Styling */
.sheet-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

.sheet-table th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #e8b49a;
  color: #1e293b;
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid #94a3b8;
  border-right: 1px solid #cbd5e1;
  padding: 6px 8px;
  text-align: left;
}

.sheet-table td {
  border-bottom: 1px solid #cbd5e1;
  border-right: 1px solid #cbd5e1;
  padding: 0;
  height: 34px;
  vertical-align: middle;
  transition: background-color 0.15s ease;
}

/* Base Structural Row Styling */
.row-phase td {
  background-color: #fae5d8;
  border-top: 2px solid #d97706;
  border-bottom: 2px solid #d97706;
  font-weight: 700;
  color: #7c2d12;
}

.row-group td {
  background-color: #c5d9e2;
  border-top: 1.5px solid #38bdf8;
  border-bottom: 1.5px solid #0284c7;
  font-weight: 600;
  color: #0f172a;
}

.row-ungrouped td {
  background-color: #f8fafc;
}

/* 8 Custom Color Themes for Shapes, Groups & Phase Headers in Table */
.row-highlight-default td,
.row-highlight-slate td {
  background-color: #f8fafc !important;
}
.row-highlight-slate input.activity-name-input {
  color: #0f172a !important;
}

.row-highlight-blue td {
  background-color: #dbeafe !important;
}
.row-highlight-blue input.activity-name-input {
  color: #1e40af !important;
  font-weight: 600;
}

.row-highlight-amber td {
  background-color: #ffedd5 !important;
}
.row-highlight-amber input.activity-name-input {
  color: #9a3412 !important;
  font-weight: 600;
}

.row-highlight-yellow td {
  background-color: #fef9c3 !important;
}
.row-highlight-yellow input.activity-name-input {
  color: #dc2626 !important;
  font-weight: 600;
}

.row-highlight-green td {
  background-color: #dcfce7 !important;
}
.row-highlight-green input.activity-name-input {
  color: #15803d !important;
  font-weight: 600;
}

.row-highlight-purple td {
  background-color: #f3e8ff !important;
}
.row-highlight-purple input.activity-name-input {
  color: #7e22ce !important;
  font-weight: 600;
}

.row-highlight-rose td {
  background-color: #ffe4e6 !important;
}
.row-highlight-rose input.activity-name-input {
  color: #be123c !important;
  font-weight: 600;
}

.row-highlight-teal td {
  background-color: #ccfbf1 !important;
}
.row-highlight-teal input.activity-name-input {
  color: #0f766e !important;
  font-weight: 600;
}

/* Active & Multi-Selected Row Styles */
.row-selected td {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

.row-checked td {
  box-shadow: inset 0 0 0 9999px rgba(14, 165, 233, 0.14);
}

.cell-input {
  width: 100%;
  height: 32px;
  padding: 0 8px;
  background: transparent;
  border: none;
  font-size: 13px;
  outline: none;
}
.cell-input:focus {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: inset 0 0 0 2px #2563eb;
}

/* SVG Flowchart Interactive Styles */
.canvas-bg {
  background-color: #f8fafc;
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 20px 20px;
}

.flow-node {
  cursor: move;
  transition: filter 0.12s ease, opacity 0.2s ease;
}
.flow-node:hover {
  filter: drop-shadow(0 6px 12px rgba(37, 99, 235, 0.22));
}

/* Canvas Sticky Note Styling */
.flow-sticky-note {
  cursor: move;
  transition: filter 0.15s ease, transform 0.12s ease;
}
.flow-sticky-note:hover {
  filter: drop-shadow(0 8px 14px rgba(15, 23, 42, 0.22));
}
.sticky-delete-btn {
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s ease;
}
.sticky-delete-btn:hover {
  opacity: 1;
}

.flow-connector-badge {
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.flow-connector-badge:hover {
  filter: drop-shadow(0 4px 10px rgba(14, 165, 233, 0.45));
}

.flow-group-container {
  cursor: move;
}

.flow-edge {
  transition: stroke-width 0.12s ease, opacity 0.2s ease, stroke 0.12s ease;
  cursor: pointer;
}
.flow-edge:hover {
  stroke-width: 3.5px !important;
  stroke: #0284c7 !important;
}

/* Draw.io-style Draggable Waypoint & Port Handles */
.edge-segment-handle {
  transition: transform 0.1s ease, fill 0.1s ease;
}
.edge-segment-handle:hover {
  fill: #0284c7;
  stroke: #ffffff;
  stroke-width: 2.5px;
}

.port-target-dot {
  transition: r 0.12s ease, fill 0.12s ease;
}
.port-target-dot:hover {
  r: 7px;
  fill: #22c55e;
}

.dimmed {
  opacity: 0.22 !important;
}

@keyframes dashFlow {
  to {
    stroke-dashoffset: -24;
  }
}
.edge-animated {
  stroke-dasharray: 7 5;
  animation: dashFlow 0.8s linear infinite;
}

/* Workbook Sheet Tabs Bar */
.sheet-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  border: 1px solid transparent;
}
.sheet-tab-active {
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 1px 4px rgba(2, 132, 199, 0.3);
}
.sheet-tab-inactive {
  background: #1e293b;
  color: #cbd5e1;
  border-color: #334155;
}
.sheet-tab-inactive:hover {
  background: #334155;
  color: #ffffff;
}

/* Role-Based Visibility Rules (Viewer vs Editor) */
body.role-viewer .editor-only-control,
body.role-viewer .editor-only-panel {
  display: none !important;
}

body.role-editor .viewer-only-banner {
  display: none !important;
}

body.role-viewer #projectTitleInput {
  pointer-events: none;
}

body.role-viewer .flow-node,
body.role-viewer .flow-group-container {
  cursor: pointer !important;
}

body.role-viewer .edge-segment-handle,
body.role-viewer .port-target-dot {
  display: none !important;
}

/* Sticky notes remain draggable by BOTH Viewers and Editors */
body.role-viewer .flow-sticky-note {
  cursor: move !important;
}