/* ==========================================================================
   SolarRoofFit — Solar PV Flat Roof CAD Design System Stylesheet
   Theme: Nordic Architectural Daylight (Crisp Studio & Sapphire PV Panels)
   ========================================================================== */

:root {
  /* Typography: Privacy-first font stack (zero external trackers / 100% GDPR compliant) */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Core Color Palette: Nordic Architectural Studio */
  --bg-darkest: #F1F5F9;
  --bg-darker: #E2E8F0;
  --bg-surface: #FFFFFF;
  --bg-surface-elevated: #F8FAFC;
  --bg-surface-hover: #F1F5F9;

  /* Solar Accent Colors */
  --solar-amber: #D97706;
  --solar-amber-light: #F59E0B;
  --solar-amber-glow: rgba(217, 119, 6, 0.2);

  --electric-cyan: #0284C7;
  --electric-cyan-glow: rgba(2, 132, 199, 0.2);

  --brand-blue: #2563EB;
  --brand-blue-hover: #1D4ED8;
  --brand-blue-glow: rgba(37, 99, 235, 0.25);

  /* Status Accents */
  --status-success: #059669;
  --status-warning: #D97706;
  --status-error: #DC2626;
  --status-error-glow: rgba(220, 38, 38, 0.25);

  /* Text & Border Shades */
  --text-main: #0F172A;
  --text-muted: #475569;
  --text-subtle: #64748B;
  --border-color: rgba(15, 23, 42, 0.08);
  --border-color-focus: rgba(37, 99, 235, 0.5);

  /* Solar Module Visuals */
  --pv-frame: #64748B;
  --pv-cell-bg: #0A1C38;
  --pv-cell-border: #1E3A5F;
  --pv-busbar: rgba(255, 255, 255, 0.22);

  /* Shadows & Glassmorphism */
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --glass-blur: blur(12px);

  /* Layout Measurements */
  --header-height: 64px;
  --sidebar-width: 275px;
}

[x-cloak] {
  display: none !important;
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-darkest);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

/* App Shell Layout */
#app-root {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
  background: radial-gradient(circle at 50% 0%, #FFFFFF 0%, var(--bg-darkest) 85%);
}

/* ==========================================================================
   Header Component
   ========================================================================== */
.app-header {
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  gap: 1rem;
  z-index: 30;
  flex-shrink: 0;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 0 0 auto;
}

.brand-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--solar-amber-light), var(--solar-amber));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px var(--solar-amber-glow);
  color: #FFF;
}

.brand-title-wrap h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0F172A;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Toolbar Controls */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
}

/* Language Switcher in Header */
.lang-switch-wrap {
  display: inline-flex;
  background: #F1F5F9;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.3rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.lang-btn:hover {
  color: #0F172A;
  background: rgba(15, 23, 42, 0.05);
}

.lang-btn.active {
  background: var(--brand-blue);
  color: #FFF;
  box-shadow: 0 1px 4px var(--brand-blue-glow);
}

.btn-group {
  display: inline-flex;
  background: #F1F5F9;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  white-space: nowrap;
  user-select: none;
}

.btn:hover:not(:disabled) {
  background: #E2E8F0;
  color: #0F172A;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-blue), #1D4ED8);
  color: #FFF;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 1px 4px var(--brand-blue-glow);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #3B82F6, var(--brand-blue));
  box-shadow: 0 2px 8px var(--brand-blue-glow);
}

.btn-solar {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 1px 4px var(--solar-amber-glow);
}

.btn-solar:hover:not(:disabled) {
  background: linear-gradient(135deg, #FBBF24, #F59E0B);
  box-shadow: 0 2px 8px var(--solar-amber-glow);
}

.btn-outline {
  border-color: var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
}

.btn-outline:hover:not(:disabled) {
  background: #E2E8F0;
  border-color: rgba(15, 23, 42, 0.15);
}

.btn-icon-only {
  padding: 0.45rem;
  border-radius: 6px;
}

.divider-v {
  width: 1px;
  height: 24px;
  background: var(--border-color);
  margin: 0 0.25rem;
}

/* ==========================================================================
   Main Workspace Layout
   ========================================================================== */
.workspace-container {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--header-height));
  position: relative;
  overflow: hidden;
}

/* Sidebar Styles */
.sidebar {
  width: var(--sidebar-width);
  background: #F8FAFC;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 20;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 3px;
}

.sidebar-panel {
  padding: 0.7rem 0.85rem;
  background: #FFFFFF;
  margin: 0.35rem 0.5rem;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.panel-title {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand-blue);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.panel-title svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 0.4rem;
}

.form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.69rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.18rem;
  white-space: nowrap;
}

.form-label .unit-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.67rem;
  color: var(--solar-amber);
  background: rgba(217, 119, 6, 0.08);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-weight: 600;
}

.input-control, .select-control {
  width: 100%;
  background: #F8FAFC;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 5px;
  color: var(--text-main);
  padding: 0.28rem 0.45rem;
  font-size: 0.76rem;
  height: 27px;
  line-height: 1.2;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-control:focus, .select-control:focus {
  background: #FFFFFF;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 2px var(--brand-blue-glow);
}

.range-slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.range-slider {
  flex: 1;
  accent-color: var(--brand-blue);
  height: 4px;
  border-radius: 2px;
  background: #E2E8F0;
  cursor: pointer;
}

.input-number-compact {
  width: 80px;
  height: 27px;
  padding: 0.2rem 0.35rem;
  font-size: 0.75rem;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  background: #FFFFFF;
}

.input-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

/* Switch Toggle */
.toggle-switch-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.18rem 0;
}

.form-label-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.form-sublabel {
  font-size: 0.63rem;
  color: var(--text-subtle);
  font-weight: 400;
}

.form-micro-hint {
  font-size: 0.66rem;
  color: #1E40AF;
  background: rgba(37, 99, 235, 0.06);
  border: 1px dashed rgba(37, 99, 235, 0.25);
  border-radius: 5px;
  padding: 0.22rem 0.45rem;
  margin: 0.25rem 0 0.35rem 0;
  display: flex;
  align-items: center;
}

.form-micro-hint kbd {
  background: #FFFFFF;
  color: #0F172A;
  border: 1px solid rgba(15, 23, 42, 0.15);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.64rem;
  margin: 0 2px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 16px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-round {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #CBD5E1;
  transition: .2s;
  border-radius: 16px;
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 10px;
  width: 10px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: .2s;
  border-radius: 50%;
}

input:checked + .slider-round {
  background-color: var(--brand-blue);
}

input:checked + .slider-round:before {
  transform: translateX(12px);
}

/* Setback Link Toggle & Status */
.btn-link-toggle {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.66rem;
  font-family: inherit;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-link-toggle:hover {
  background: #F1F5F9;
  color: var(--text-main);
  border-color: rgba(15, 23, 42, 0.15);
}

.link-status {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.link-status.linked {
  color: var(--brand-blue);
}

.link-status.unlinked {
  color: var(--solar-amber);
}

/* 4-Way Compass Setback Grid */
.setback-4way-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  margin-top: 0.25rem;
  background: #F8FAFC;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.35rem 0.4rem;
}

.setback-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.setback-field.top-field,
.setback-field.bottom-field {
  width: 90px;
}

.setback-field .input-number-compact {
  width: 58px;
  height: 25px;
  padding: 0.18rem 0.3rem;
  font-size: 0.73rem;
}

.setback-mid-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.3rem;
}

.setback-field.left-field,
.setback-field.right-field {
  flex: 1;
}

.compass-center-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-blue);
  opacity: 0.85;
  padding: 0 0.15rem;
}

.compass-center-icon svg {
  width: 18px;
  height: 18px;
}

.compass-label {
  font-size: 0.63rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-family: 'Inter', sans-serif;
}

.compass-dir {
  font-weight: 500;
}

/* Segmented Control */
.segmented-control {
  display: flex;
  background: #F1F5F9;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: 2px;
  gap: 2px;
  margin-top: 0.15rem;
}

.segment-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.24rem 0.2rem;
  font-size: 0.68rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  white-space: nowrap;
}

.segment-btn:hover {
  color: var(--text-main);
  background: rgba(15, 23, 42, 0.04);
}

.segment-btn.active {
  background: var(--brand-blue);
  color: white;
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Center Viewport & Interactive SVG Canvas
   ========================================================================== */
.canvas-viewport {
  flex: 1;
  position: relative;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #EEF2F6;
  background-image: 
    linear-gradient(rgba(15, 23, 42, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.04) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* ==========================================================================
   Floating Canvas Command Toolbar (CAD / Figma Style)
   ========================================================================== */
.canvas-toolbar-floating {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: 0 10px 25px -4px rgba(15, 23, 42, 0.12), 0 2px 6px -1px rgba(15, 23, 42, 0.06);
  border-radius: 10px;
  padding: 0.35rem 0.45rem;
  user-select: none;
  max-width: calc(100% - 1.5rem);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.canvas-toolbar-floating:hover {
  box-shadow: 0 14px 30px -4px rgba(15, 23, 42, 0.16), 0 2px 8px -1px rgba(15, 23, 42, 0.08);
}

.canvas-toolbar-floating .btn-group {
  background: #F1F5F9;
}

.canvas-toolbar-floating .btn {
  padding: 0.35rem 0.55rem;
  font-size: 0.76rem;
}

.canvas-toolbar-floating .btn-icon-only {
  padding: 0.38rem;
  min-width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.canvas-toolbar-floating .divider-v {
  height: 20px;
  margin: 0 0.15rem;
  background: rgba(15, 23, 42, 0.1);
}

.btn-toolbar-primary {
  padding: 0.38rem 0.8rem !important;
  font-size: 0.78rem !important;
}

/* Split Auto-Fill Dropdown in Floating Toolbar */
.split-btn-group {
  position: relative;
}

.canvas-toolbar-floating .btn-split-main {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  padding-right: 0.45rem !important;
}

.canvas-toolbar-floating .btn-split-trigger {
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
  padding-left: 0.25rem !important;
  padding-right: 0.35rem !important;
  border-left: 1px solid rgba(15, 23, 42, 0.1) !important;
}

.split-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 290px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  box-shadow: 0 16px 36px -4px rgba(15, 23, 42, 0.18), 0 0 1px 1px rgba(15, 23, 42, 0.06);
  padding: 0.35rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  animation: dropdownFadeIn 0.15s ease-out;
}

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

.dropdown-header {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.3rem 0.5rem 0.2rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  margin-bottom: 0.15rem;
}

.dropdown-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.dropdown-item:hover {
  background: #F1F5F9;
  border-color: rgba(15, 23, 42, 0.08);
}

.dropdown-item.active {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.3);
}

.dropdown-item-icon {
  flex-shrink: 0;
  margin-top: 0.15rem;
  color: var(--brand-blue);
}

.dropdown-item-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.dropdown-item-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.dropdown-item-title {
  font-size: 0.76rem;
  font-weight: 600;
  color: #0F172A;
}

.dropdown-badge-accent {
  font-size: 0.6rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: rgba(5, 150, 105, 0.12);
  color: #059669;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.dropdown-badge-neutral {
  font-size: 0.6rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: rgba(37, 99, 235, 0.1);
  color: #2563EB;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.dropdown-item-desc {
  font-size: 0.67rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.dropdown-check {
  color: var(--brand-blue);
  flex-shrink: 0;
  margin-top: 0.15rem;
}

#roof-canvas-svg {
  width: 100%;
  height: 100%;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

#roof-canvas-svg:active {
  cursor: grabbing;
}

/* Top Bar Metrics HUD */
.metrics-hud {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 1 auto;
}

.metric-card {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 6px;
  padding: 0.18rem 0.45rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.metric-card:hover {
  border-color: rgba(37, 99, 235, 0.3);
}

.metric-card.highlight {
  border-color: rgba(217, 119, 6, 0.35);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08) 0%, #FFFFFF 100%);
}

.metric-card.status-card {
  flex-direction: row;
  align-items: center;
  padding: 0.25rem 0.45rem;
}

.metric-label {
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  line-height: 1;
  margin-bottom: 0.1rem;
  white-space: nowrap;
}

.metric-value-wrap {
  display: flex;
  align-items: baseline;
  gap: 0.2rem;
  line-height: 1.1;
  white-space: nowrap;
}

.metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  font-weight: 700;
  color: #0F172A;
}

.metric-card.highlight .metric-value {
  color: #D97706;
}

.metric-unit {
  font-size: 0.62rem;
  color: var(--text-subtle);
  font-weight: 500;
}

/* Floating Navigation Controls (Bottom-right of Canvas) */
.canvas-controls-floating {
  position: absolute;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  z-index: 10;
}

.control-btn {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.control-btn:hover {
  background: #FFFFFF;
  color: var(--brand-blue);
  box-shadow: var(--shadow-md);
  transform: scale(1.05);
}

/* Floating Bottom Status & Hints Bar */
.bottom-hints-bar {
  position: absolute;
  bottom: 1.25rem;
  left: 1.25rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.hint-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.kbd-badge {
  background: #F1F5F9;
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: #0F172A;
  font-weight: 600;
}

/* Alert Banner for Collisions / Out of Bounds */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
}

.status-pill.ok {
  background: rgba(5, 150, 105, 0.1);
  color: #059669;
  border: 1px solid rgba(5, 150, 105, 0.25);
}

.status-pill.warning {
  background: rgba(217, 119, 6, 0.1);
  color: #D97706;
  border: 1px solid rgba(217, 119, 6, 0.25);
}

.status-pill.error {
  background: rgba(220, 38, 38, 0.1);
  color: #DC2626;
  border: 1px solid rgba(220, 38, 38, 0.25);
}

/* ==========================================================================
   SVG Graphical Elements & Visual Styling (Nordic Architectural Daylight)
   ========================================================================== */

/* Roof Blueprint Base */
.roof-membrane {
  fill: #D8DFE8;
  stroke: #64748B;
  stroke-width: 0.04;
  filter: drop-shadow(0 0.15 0.35 rgba(15, 23, 42, 0.16));
}

.roof-setback-line {
  fill: rgba(37, 99, 235, 0.025);
  stroke: #2563EB;
  stroke-width: 0.025;
  stroke-dasharray: 0.15 0.1;
}

/* Walkway Maintenance Corridors on SVG */
.walkway-group {
  pointer-events: none;
}

.walkway-group.custom-walkway {
  pointer-events: all;
  cursor: grab;
}

.auto-walkway {
  pointer-events: none;
}

.walkway-group.custom-walkway:active,
.walkway-group.custom-walkway.dragging {
  cursor: grabbing !important;
}

.walkway-corridor {
  fill: rgba(248, 250, 252, 0.9);
  stroke: #94A3B8;
  stroke-width: 0.016;
  stroke-dasharray: 0.1 0.05;
}

.walkway-corridor.custom-corridor {
  fill: rgba(254, 243, 199, 0.85);
  stroke: #D97706;
  stroke-width: 0.025;
  stroke-dasharray: none;
  transition: fill 0.15s ease, stroke 0.15s ease;
}

.walkway-group.custom-walkway:hover .custom-corridor {
  fill: rgba(254, 243, 199, 0.95);
  stroke: #B45309;
}

.walkway-group.custom-walkway.selected .custom-corridor {
  fill: rgba(253, 230, 138, 0.95);
  stroke: #D97706;
  stroke-width: 0.035;
  filter: drop-shadow(0 0 0.05 rgba(217, 119, 6, 0.5));
}

.walkway-group.custom-walkway.dragging .custom-corridor {
  fill: rgba(253, 230, 138, 0.98);
  stroke: #D97706;
  stroke-width: 0.04;
  filter: drop-shadow(0 2px 8px rgba(217, 119, 6, 0.6));
}

.walkway-border-line {
  pointer-events: none;
}

.walkway-centerline {
  stroke: #64748B;
  stroke-width: 0.01;
  stroke-dasharray: 0.12 0.06;
  pointer-events: none;
}

.walkway-centerline.selected {
  stroke: #B45309;
  stroke-width: 0.018;
}

.walkway-annotation {
  fill: #334155;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.13px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  letter-spacing: 0.01em;
  pointer-events: none;
  user-select: none;
}

.walkway-annotation.selected {
  fill: #78350F;
  font-weight: 800;
}

/* Roof Obstacles (Skylights & Chimneys) on SVG Canvas */
.obstacle-group {
  cursor: grab;
}

.obstacle-group:active,
.obstacle-group.dragging {
  cursor: grabbing !important;
}

.obstacle-clearance-zone {
  fill: rgba(14, 165, 233, 0.08);
  stroke: rgba(14, 165, 233, 0.45);
  stroke-width: 0.018;
  stroke-dasharray: 0.08 0.05;
  transition: fill 0.15s ease, stroke 0.15s ease;
}

.obstacle-group.obstacle-chimney .obstacle-clearance-zone {
  fill: rgba(217, 119, 6, 0.08);
  stroke: rgba(217, 119, 6, 0.45);
}

.obstacle-group:hover .obstacle-clearance-zone {
  fill: rgba(14, 165, 233, 0.14);
  stroke: rgba(14, 165, 233, 0.7);
}

.obstacle-group.selected .obstacle-clearance-zone {
  fill: rgba(14, 165, 233, 0.18);
  stroke: #0284C7;
  stroke-width: 0.024;
}

.obstacle-clearance-label {
  fill: #0284C7;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.10px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  user-select: none;
}

.skylight-curb {
  fill: #FFFFFF;
  stroke: #0284C7;
  stroke-width: 0.022;
  filter: drop-shadow(0 0.02 0.04 rgba(2, 132, 199, 0.25));
  transition: stroke 0.15s ease;
}

.skylight-glass {
  fill: url(#skylight-glass-gradient);
  stroke: #0284C7;
  stroke-width: 0.015;
}

.skylight-glazing-line {
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 0.012;
  stroke-dasharray: 0.08 0.04;
  pointer-events: none;
}

.chimney-masonry {
  fill: #7C2D12;
  stroke: #431407;
  stroke-width: 0.022;
  filter: drop-shadow(0 0.02 0.04 rgba(67, 20, 7, 0.35));
  transition: stroke 0.15s ease;
}

.chimney-rim {
  fill: #475569;
  stroke: #334155;
  stroke-width: 0.015;
}

.chimney-flue-circle {
  fill: #0F172A;
  stroke: #1E293B;
  stroke-width: 0.015;
}

.obstacle-selection-outline {
  stroke: #06B6D4;
  stroke-width: 0.035;
  stroke-dasharray: 0.08 0.05;
  filter: drop-shadow(0 0 0.06 rgba(6, 182, 212, 0.6));
}

.obstacle-annotation {
  fill: #0F172A;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.11px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: central;
  letter-spacing: 0.01em;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 0.01 0.02 rgba(255, 255, 255, 0.8));
}

.obstacle-group.obstacle-chimney .obstacle-annotation {
  fill: #FEF3C7;
  filter: drop-shadow(0 0.01 0.02 rgba(0, 0, 0, 0.8));
}

/* Walkway Draw Tool Cursor & Preview */
.tool-draw-walkway {
  cursor: crosshair !important;
}

.walkway-preview-group {
  pointer-events: none;
}

/* Floating Draw Mode Active Banner */
.draw-mode-banner {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  background: rgba(254, 243, 199, 0.96);
  border: 1px solid #D97706;
  color: #92400E;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  backdrop-filter: blur(8px);
  animation: bannerSlideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes bannerSlideDown {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.draw-mode-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.draw-mode-info svg {
  color: #D97706;
  flex-shrink: 0;
}

.btn-banner-exit {
  background: #D97706;
  color: #FFFFFF;
  border: none;
  border-radius: 9999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-banner-exit:hover {
  background: #B45309;
}

.custom-walkway-item.selected {
  border-color: #D97706 !important;
  background: rgba(217, 119, 6, 0.08) !important;
  box-shadow: 0 0 0 1px #D97706;
}

.custom-obstacle-item:hover {
  border-color: #0284C7 !important;
  background: #F0F9FF !important;
}

.custom-obstacle-item.selected {
  border-color: #0284C7 !important;
  background: rgba(14, 165, 233, 0.1) !important;
  box-shadow: 0 0 0 1px #0284C7;
}

/* CAD Smart Magnetic Snap Alignment Guides */
.snap-guide-group {
  pointer-events: none;
}

.snap-guide-line {
  stroke: #2563EB;
  stroke-width: 0.018;
  stroke-dasharray: 0.08 0.04;
  filter: drop-shadow(0 0 0.04 rgba(37, 99, 235, 0.4));
}

.snap-guide-line.snap-gap-line {
  stroke: #D97706;
  filter: drop-shadow(0 0 0.04 rgba(217, 119, 6, 0.4));
}

.snap-guide-line.snap-flush-line {
  stroke: #2563EB;
  filter: drop-shadow(0 0 0.04 rgba(37, 99, 235, 0.4));
}

.snap-guide-text {
  fill: #0F172A;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.135px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  paint-order: stroke;
  stroke: #FFFFFF;
  stroke-width: 0.035;
  stroke-linejoin: round;
  letter-spacing: 0.02em;
}

/* Dimension Annotation Guides */
.dim-line {
  stroke: #475569;
  stroke-width: 0.02;
}

.dim-text {
  fill: #0F172A;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.35px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
}

/* PV Module Group */
.pv-module-group {
  cursor: move;
  transition: filter 0.15s ease;
}

.pv-module-group:hover .pv-module-frame {
  stroke-width: 0.035;
  stroke: #2563EB;
}

/* Frame */
.pv-module-frame {
  fill: #0A1931;
  stroke: #64748B;
  stroke-width: 0.02;
  rx: 0.01;
}

/* Cells Matrix Texture */
.pv-cell-rect {
  fill: url(#pv-cell-gradient);
}

.pv-busbar-line {
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 0.004;
}

.pv-junction-indicator {
  fill: #1E293B;
  stroke: #475569;
  stroke-width: 0.005;
}

/* States: Selected, Warning, Collision */
.pv-module-group.selected .pv-module-frame {
  stroke: #2563EB !important;
  stroke-width: 0.045 !important;
  filter: drop-shadow(0 0 0.08 rgba(37, 99, 235, 0.5));
}

.pv-module-group.warning .pv-module-frame {
  stroke: var(--solar-amber) !important;
  stroke-width: 0.045 !important;
  filter: drop-shadow(0 0 0.08 var(--solar-amber-glow));
}

.pv-module-group.collision .pv-module-frame,
.pv-module-group.error_roof .pv-module-frame {
  stroke: var(--status-error) !important;
  stroke-width: 0.05 !important;
  filter: drop-shadow(0 0 0.1 var(--status-error-glow));
}

/* ==========================================================================
   Toast Notification Banner
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 4.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(15, 23, 42, 0.1);
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #0F172A;
  box-shadow: 0 10px 25px -4px rgba(15, 23, 42, 0.12), 0 2px 6px -1px rgba(15, 23, 42, 0.06);
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.success {
  border-color: rgba(5, 150, 105, 0.4);
  color: #059669;
}

.toast.info {
  border-color: rgba(37, 99, 235, 0.4);
  color: #2563EB;
}

.toast.error {
  border-color: rgba(220, 38, 38, 0.4);
  color: #DC2626;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 1500px) {
  .brand-subtitle {
    display: none;
  }
}

@media (max-width: 1380px) {
  .canvas-toolbar-floating .btn-text-responsive {
    display: none;
  }
  .canvas-toolbar-floating {
    padding: 0.3rem 0.4rem;
    gap: 0.25rem;
  }
  .canvas-toolbar-floating .btn {
    padding: 0.35rem 0.5rem;
  }
  .metric-card {
    padding: 0.15rem 0.35rem;
  }
  .metric-label {
    font-size: 0.52rem;
  }
}

@media (max-width: 1100px) {
  .metric-card .metric-label {
    display: none;
  }
  .status-text-responsive {
    display: none;
  }
  .brand-title-wrap h1 {
    font-size: 1rem;
  }
  .metric-hide-tablet {
    display: none !important;
  }
}

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 250px;
  }
}

@media (max-width: 950px) {
  .metric-hide-mobile {
    display: none !important;
  }
  .app-header {
    padding: 0 0.75rem;
    gap: 0.5rem;
  }
}

@media (max-width: 768px) {
  .workspace-container {
    flex-direction: column-reverse;
  }
  .sidebar {
    width: 100%;
    height: 42vh;
    border-right: none;
    border-top: 1px solid var(--border-color);
  }
  .canvas-viewport {
    height: 58vh;
  }
  .canvas-toolbar-floating {
    top: 0.5rem;
    padding: 0.25rem 0.35rem;
  }
}

/* ====================================================================
   Modal Dialog (Walkway Width & General)
   ==================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-card {
  background: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 380px;
  overflow: hidden;
  animation: modalPop 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border-color);
  background: #F8FAFC;
}

.modal-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.modal-header .btn-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.2rem;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.modal-header .btn-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.1rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem;
  border-top: 1px solid var(--border-color);
  background: #F8FAFC;
}

/* Blueprint Export Modal Customization */
.modal-card-export {
  max-width: 530px !important;
}

.blueprint-mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.blueprint-mode-card {
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 0.8rem;
  cursor: pointer;
  background: #FFFFFF;
  transition: all 0.15s ease;
  user-select: none;
}

.blueprint-mode-card:hover {
  border-color: var(--brand-blue);
  background: #F8FAFC;
}

.blueprint-mode-card.active {
  border-color: var(--brand-blue);
  background: rgba(37, 99, 235, 0.05);
  box-shadow: 0 0 0 1.5px var(--brand-blue);
}

.mode-card-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.blueprint-mode-card.active .mode-card-title {
  color: var(--brand-blue);
}

.mode-card-desc {
  font-size: 0.68rem;
  color: var(--text-subtle);
  line-height: 1.35;
}

/* ====================================================================
   Drag & Drop Project JSON File Overlay
   ==================================================================== */
.drop-zone-overlay {
  position: absolute;
  inset: 0;
  z-index: 1200;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-zone-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2.25rem 3.5rem;
  background: #FFFFFF;
  border: 2px dashed var(--brand-blue);
  border-radius: 16px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
  color: var(--brand-blue);
  text-align: center;
  pointer-events: none;
  animation: dropCardPulse 1.4s ease-in-out infinite alternate;
}

@keyframes dropCardPulse {
  0% { transform: scale(0.98); }
  100% { transform: scale(1.02); }
}

.drop-zone-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.drop-zone-card p {
  font-size: 0.8rem;
  color: var(--text-subtle);
  margin: 0;
}

/* Print Header hidden by default on screen */
.print-only-header {
  display: none;
}

/* ====================================================================
   Print Stylesheet (@media print) for Paper and PDF Blueprint Generation
   ==================================================================== */
@media print {
  @page {
    size: landscape;
    margin: 8mm;
  }

  *, *::before, *::after {
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
  }

  html, body {
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    background: #FFFFFF !important;
    color: #0F172A !important;
  }

  #app-root {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    background: #FFFFFF !important;
  }

  /* Hide interactive UI elements */
  .app-header,
  .sidebar,
  .canvas-toolbar-floating,
  .canvas-controls-floating,
  .drop-zone-overlay,
  .toast-notification,
  .modal-backdrop,
  .quick-shortcuts-bar,
  .bottom-info-strip {
    display: none !important;
  }

  .workspace-container {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Show Print Architectural Header */
  .print-only-header {
    display: block !important;
    border-bottom: 2px solid #0F172A;
    padding-bottom: 0.45rem;
    margin-bottom: 0.6rem;
  }

  .print-brand-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
  }

  .print-brand-row h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #0F172A;
    margin: 0;
  }

  .print-date {
    font-size: 0.8rem;
    color: #475569;
    font-family: var(--font-mono);
  }

  .print-metrics-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    font-size: 0.78rem;
    color: #334155;
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
  }

  .print-metric-item strong {
    color: #0F172A;
  }

  /* Center and scale canvas */
  .canvas-viewport {
    height: auto !important;
    max-height: 82vh !important;
    overflow: visible !important;
    background: #FFFFFF !important;
    background-image: none !important;
    border: 1px solid #CBD5E1;
    border-radius: 8px;
    padding: 0.5rem;
  }

  #roof-canvas-svg {
    width: 100% !important;
    height: 70vh !important;
    max-height: 70vh !important;
    display: block !important;
    margin: 0 auto;
  }
}

/* ====================================================================
   Global Error Boundary & Crash Recovery Banner
   ==================================================================== */
.app-crash-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99999;
  background: #FEF2F2;
  border-bottom: 2px solid #EF4444;
  color: #991B1B;
  padding: 0.65rem 1.25rem;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.84rem;
  animation: slideDownCrash 0.2s ease-out;
}

@keyframes slideDownCrash {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

.crash-banner-content {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.crash-banner-content svg {
  flex-shrink: 0;
  stroke: #DC2626;
}

.crash-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-crash-reset {
  background: #DC2626;
  color: #FFFFFF;
  border: none;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-crash-reset:hover {
  background: #B91C1C;
}

.btn-crash-dismiss {
  background: transparent;
  color: #991B1B;
  border: none;
  font-size: 1rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  border-radius: 4px;
}

.btn-crash-dismiss:hover {
  background: rgba(239, 68, 68, 0.1);
}




