/* Union Site Plan – Frontend v1.1 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body.usp-fullscreen {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	background: #f1f3f5;
	overflow: hidden;
	height: 100vh;
}

/* ── App shell ──────────────────────────────────────────────── */
.usp-app {
	display: grid;
	grid-template-columns: 240px 1fr 280px;
	height: 100vh;
	overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.usp-sidebar {
	background: #111827;
	color: #f9fafb;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border-right: 1px solid #1f2937;
}
.usp-sidebar-top { padding: 16px 16px 12px; border-bottom: 1px solid #1f2937; }
.usp-logo { display: flex; align-items: center; gap: 8px; }
.usp-logo-img { width: 24px; height: 24px; border-radius: 4px; }
.usp-logo-name { font-size: 13px; font-weight: 600; color: #e5e7eb; letter-spacing: 0.02em; }

.usp-project-meta { padding: 16px 16px 12px; border-bottom: 1px solid #1f2937; }
.usp-project-title { font-size: 15px; font-weight: 700; color: #fff; line-height: 1.3; margin-bottom: 4px; }
.usp-project-version { font-size: 11px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.06em; }

.usp-sidebar-nav { padding: 8px 8px 0; }
.usp-nav-item {
	display: flex; align-items: center; gap: 8px; width: 100%;
	padding: 8px 10px; background: none; border: none; color: #9ca3af;
	font-size: 12px; font-weight: 600; text-transform: uppercase;
	letter-spacing: 0.06em; cursor: pointer; border-radius: 5px;
	transition: background 0.15s, color 0.15s;
}
.usp-nav-item:hover    { background: #1f2937; color: #e5e7eb; }
.usp-nav-item--active  { background: #1f2937; color: #60a5fa; }

.usp-panel { flex: 1; overflow-y: auto; padding: 8px; }
.usp-panel-header { font-size: 10px; font-weight: 700; color: #6b7280; letter-spacing: 0.1em; text-transform: uppercase; padding: 8px 8px 6px; }

.usp-modules-list { display: flex; flex-direction: column; gap: 4px; }
.usp-loading { color: #6b7280; font-size: 13px; padding: 12px; }

.usp-module-item {
	display: flex; align-items: center; gap: 10px;
	padding: 8px 10px; background: #1f2937;
	border: 1px solid #374151; border-radius: 6px;
	cursor: grab; transition: background 0.15s, border-color 0.15s;
	user-select: none;
}
.usp-module-item:hover  { background: #2d3748; border-color: #4b5563; }
.usp-module-item:active { cursor: grabbing; }
.usp-module-item img    { width: 36px; height: 36px; object-fit: contain; flex-shrink: 0; }
.usp-module-item-name   { flex: 1; font-size: 13px; color: #e5e7eb; font-weight: 500; }
.usp-module-drag-icon   { color: #4b5563; font-size: 16px; flex-shrink: 0; }

/* Disable sidebar drag cursors in road mode */
.usp-app[data-mode="road"] .usp-module-item { cursor: not-allowed; opacity: 0.4; }

.usp-sidebar-footer { padding: 12px 8px; border-top: 1px solid #1f2937; }
.usp-clear-btn {
	display: flex; align-items: center; gap: 6px; width: 100%;
	padding: 7px 10px; background: none; border: 1px solid #374151;
	border-radius: 5px; color: #9ca3af; font-size: 12px; cursor: pointer;
	transition: all 0.15s;
}
.usp-clear-btn:hover { border-color: #ef4444; color: #ef4444; }

/* ── Canvas area ────────────────────────────────────────────── */
.usp-canvas-area { display: flex; flex-direction: column; background: #e5e7eb; overflow: hidden; }

.usp-canvas-toolbar {
	display: flex; align-items: center; justify-content: space-between;
	padding: 8px 16px; background: #fff; border-bottom: 1px solid #e5e7eb;
	flex-shrink: 0; gap: 12px;
}
.usp-toolbar-left { display: flex; align-items: center; gap: 12px; }

/* Mode buttons */
.usp-mode-controls { display: flex; gap: 4px; }
.usp-mode-btn {
	display: flex; align-items: center; gap: 5px;
	padding: 5px 12px; font-size: 12px; font-weight: 600;
	border: 1px solid #d1d5db; border-radius: 5px;
	background: #fff; color: #6b7280; cursor: pointer;
	transition: all 0.15s;
}
.usp-mode-btn:hover  { background: #f3f4f6; border-color: #9ca3af; color: #374151; }
.usp-mode-btn.active { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.usp-mode-btn svg    { flex-shrink: 0; }

.usp-mode-hint { font-size: 11px; color: #9ca3af; }

.usp-zoom-controls { display: flex; align-items: center; gap: 6px; }
.usp-zoom-btn {
	width: 28px; height: 28px; border: 1px solid #d1d5db;
	background: #fff; border-radius: 4px; font-size: 16px;
	cursor: pointer; display: flex; align-items: center; justify-content: center;
	transition: all 0.15s;
}
.usp-zoom-btn:hover { background: #f3f4f6; border-color: #9ca3af; }
.usp-zoom-level { font-size: 13px; color: #374151; font-weight: 500; min-width: 42px; text-align: center; }

.usp-canvas-scroll {
	flex: 1; overflow: auto;
	display: flex; align-items: flex-start; justify-content: flex-start;
	padding: 24px;
}
/* Road mode cursor on scroll area */
.usp-app[data-mode="road"] .usp-canvas-scroll { cursor: crosshair; }

.usp-canvas-inner {
	position: relative; transform-origin: 0 0;
	display: inline-block; line-height: 0;
	box-shadow: 0 4px 24px rgba(0,0,0,0.15);
	border-radius: 2px; background: #fff;
	min-width: 200px; min-height: 200px;
}
.usp-canvas-bg { display: block; }

.usp-canvas-empty {
	display: flex; flex-direction: column; align-items: center;
	justify-content: center; gap: 12px; padding: 60px 40px;
	color: #9ca3af; text-align: center; font-size: 14px; line-height: 1.5;
}

/* ── Placed modules ─────────────────────────────────────────── */
.usp-placed-module { position: absolute; cursor: move; user-select: none; line-height: 0; }
.usp-placed-module img { display: block; pointer-events: none; }

/* Disable module interaction in road mode */
.usp-app[data-mode="road"] .usp-placed-module { pointer-events: none; }

.usp-rotate-handle {
	position: absolute; top: -26px; left: 50%;
	transform: translateX(-50%);
	width: 16px; height: 16px;
	background: #2563eb; border: 2px solid #fff;
	border-radius: 50%; cursor: grab; display: none;
	box-shadow: 0 1px 4px rgba(0,0,0,0.3); line-height: 0;
}
.usp-rotate-handle::after {
	content: ''; position: absolute; bottom: -10px; left: 50%;
	transform: translateX(-50%); width: 1px; height: 10px; background: #2563eb;
}

.usp-delete-btn {
	position: absolute; top: -10px; right: -10px;
	width: 20px; height: 20px; background: #ef4444; color: #fff;
	border-radius: 50%; display: none; align-items: center;
	justify-content: center; font-size: 13px; line-height: 1;
	cursor: pointer; font-style: normal;
	box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.usp-placed-module.selected                  { outline: 2px solid #2563eb; outline-offset: 2px; }
.usp-placed-module.selected .usp-rotate-handle { display: block; }
.usp-placed-module.selected .usp-delete-btn    { display: flex; }

/* Ghost drag */
.usp-ghost { position: fixed; pointer-events: none; z-index: 9999; opacity: 0.7; transform: translate(-50%,-50%); }
.usp-ghost img { display: block; }

/* Drop zone */
.usp-canvas-inner.usp-drop-active { outline: 3px dashed #2563eb; outline-offset: 4px; }

/* ── Roads SVG ──────────────────────────────────────────────── */
#usp-roads-svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: visible; }
/* In place mode, SVG passes events through (only hit areas respond) */
.usp-app[data-mode="place"] #usp-roads-svg { pointer-events: none; }
/* In road mode, SVG captures all clicks */
.usp-app[data-mode="road"]  #usp-roads-svg { pointer-events: all; }
/* Road hit areas always respond in place mode (override SVG none via inline style) */

/* ── Feasibility panel ──────────────────────────────────────── */
.usp-feasibility { background: #fff; border-left: 1px solid #e5e7eb; display: flex; flex-direction: column; overflow: hidden; }
.usp-feasibility-header { padding: 18px 20px 14px; border-bottom: 1px solid #f3f4f6; }
.usp-feasibility-header h2 { font-size: 16px; font-weight: 700; color: #111827; }
.usp-feasibility-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.usp-feasibility-status { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; }
.usp-f-status-label { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; color: #6b7280; text-transform: uppercase; }
.usp-f-status-value { font-size: 22px; font-weight: 800; color: #374151; }
.usp-feasibility-status.pass   { background: #f0fdf4; border-color: #bbf7d0; }
.usp-feasibility-status.pass   .usp-f-status-value { color: #16a34a; }
.usp-feasibility-status.review { background: #fffbeb; border-color: #fde68a; }
.usp-feasibility-status.review .usp-f-status-value { color: #d97706; }

.usp-f-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.usp-f-stat { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px 14px; }
.usp-f-stat--full { grid-column: 1 / -1; }
.usp-f-label { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; color: #6b7280; text-transform: uppercase; margin-bottom: 4px; }
.usp-f-value { font-size: 20px; font-weight: 700; color: #111827; }
.usp-f-roi   { color: #2563eb; }

.usp-f-breakdown table    { width: 100%; border-collapse: collapse; font-size: 13px; }
.usp-f-breakdown th       { text-align: left; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: #6b7280; text-transform: uppercase; padding: 6px 8px; border-bottom: 1px solid #e5e7eb; }
.usp-f-breakdown td       { padding: 7px 8px; border-bottom: 1px solid #f3f4f6; color: #374151; }
.usp-f-breakdown td:last-child { text-align: right; font-weight: 600; color: #111827; }
.usp-f-breakdown tr:last-child td { border-bottom: none; }

.usp-f-disclaimer { background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 10px 12px; font-size: 11px; color: #78350f; line-height: 1.5; }
