/* GP Coastal Craft Design System */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&family=Archivo:wght@400;500;600&display=swap');

:root {
  --gp-primary: #4AC7E3;
  --gp-primary-dark: #29a9c8;
  --gp-background: #FFFFFF;
  --gp-background-alt: #FAFAFA;
  --gp-foreground: #000000;
  --gp-muted: #64748B;
  --gp-border: #E0E0E0;
  --gp-font-heading: 'Montserrat', sans-serif;
  --gp-font-body: 'Archivo', sans-serif;
  --gp-cta-radius: 30px;
  --gp-card-radius: 8px;
  --gp-success: #22C55E;
  --gp-warning: #F59E0B;
  --gp-error: #EF4444;
  --gp-orange: #F97316;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--gp-font-body);
  background: var(--gp-background);
  color: var(--gp-foreground);
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ──────────────────────────────────────────────────────────── */

h1, h2, h3, h4 { font-family: var(--gp-font-heading); font-weight: 700; }

/* ── Header ──────────────────────────────────────────────────────────────── */

.gp-header {
  height: 60px;
  border-bottom: 1px solid var(--gp-border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--gp-background);
  z-index: 100;
}

.gp-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.gp-logo-mark {
  width: 32px;
  height: 32px;
  background: var(--gp-primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gp-logo-mark svg { width: 20px; height: 20px; color: #fff; }

.gp-logo-text {
  font-family: var(--gp-font-heading);
  font-weight: 700;
  font-size: 16px;
  color: var(--gp-foreground);
}

.gp-header-subtitle {
  font-size: 13px;
  color: var(--gp-muted);
  border-left: 1px solid var(--gp-border);
  padding-left: 12px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn-primary {
  background: var(--gp-primary);
  color: #fff;
  border: none;
  border-radius: var(--gp-cta-radius);
  padding: 14px 32px;
  font-family: var(--gp-font-heading);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover { background: var(--gp-primary-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: transparent;
  color: var(--gp-foreground);
  border: 1.5px solid var(--gp-border);
  border-radius: var(--gp-card-radius);
  padding: 8px 16px;
  font-family: var(--gp-font-body);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.btn-secondary:hover { border-color: var(--gp-primary); background: #F0FBFD; }
.btn-secondary.active { border-color: var(--gp-primary); background: #E0F6FB; color: var(--gp-primary-dark); }

.btn-icon {
  background: transparent;
  border: 1.5px solid var(--gp-border);
  border-radius: var(--gp-card-radius);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--gp-muted);
  font-size: 14px;
}

.btn-icon:hover { border-color: var(--gp-primary); color: var(--gp-primary); background: #F0FBFD; }
.btn-icon.active { border-color: var(--gp-primary); background: var(--gp-primary); color: #fff; }
.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Upload Screen ───────────────────────────────────────────────────────── */

.upload-screen {
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background: var(--gp-background-alt);
}

.upload-hero {
  text-align: center;
  max-width: 560px;
  margin-bottom: 40px;
}

.upload-hero h1 {
  font-size: 36px;
  line-height: 1.15;
  margin-bottom: 16px;
}

.upload-hero h1 span { color: var(--gp-primary); }

.upload-hero p {
  font-size: 16px;
  color: var(--gp-muted);
  line-height: 1.6;
}

.upload-card {
  background: var(--gp-background);
  border-radius: 16px;
  border: 1px solid var(--gp-border);
  padding: 40px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

.drop-zone {
  border: 2px dashed var(--gp-border);
  border-radius: var(--gp-card-radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--gp-primary);
  background: #F0FBFD;
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-zone-icon {
  width: 52px;
  height: 52px;
  background: #EEF9FC;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--gp-primary);
}

.drop-zone-icon svg { width: 26px; height: 26px; }

.drop-zone h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.drop-zone p {
  font-size: 13px;
  color: var(--gp-muted);
}

.drop-zone .file-types {
  margin-top: 10px;
  font-size: 11px;
  color: #94A3B8;
  letter-spacing: 0.03em;
}

.file-selected-name {
  margin-top: 12px;
  font-size: 13px;
  color: var(--gp-primary-dark);
  font-weight: 500;
  display: none;
}

/* Threshold slider */
.threshold-row {
  margin-top: 24px;
}

.threshold-row label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
}

.threshold-row label span { color: var(--gp-muted); font-weight: 400; }

input[type="range"] {
  width: 100%;
  accent-color: var(--gp-primary);
  height: 4px;
  cursor: pointer;
}

.upload-action {
  margin-top: 28px;
  display: flex;
  justify-content: center;
}

.upload-action .btn-primary {
  width: 100%;
  justify-content: center;
  font-size: 16px;
  padding: 16px 32px;
}

/* Progress states */
.progress-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.95);
  z-index: 200;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
}

.progress-overlay.visible { display: flex; }

.progress-spinner {
  width: 56px;
  height: 56px;
  border: 4px solid var(--gp-border);
  border-top-color: var(--gp-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 260px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #94A3B8;
  transition: color 0.3s;
}

.progress-step.active { color: var(--gp-foreground); font-weight: 500; }
.progress-step.done { color: var(--gp-success); }

.progress-step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.progress-step.active .progress-step-dot { animation: pulse 1s ease-in-out infinite; }

@keyframes pulse { 0%,100% { transform: scale(1); opacity:1; } 50% { transform: scale(1.4); opacity:0.7; } }

/* Error banner */
.error-banner {
  display: none;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--gp-card-radius);
  padding: 14px 16px;
  font-size: 13px;
  color: #DC2626;
  margin-top: 16px;
}

.error-banner.visible { display: block; }

/* ── Editor Screen ───────────────────────────────────────────────────────── */

.editor-layout {
  display: grid;
  grid-template-columns: 48px 1fr 280px;
  grid-template-rows: 48px 1fr;
  height: calc(100vh - 60px);
  overflow: hidden;
}

.editor-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-bottom: 1px solid var(--gp-border);
  background: var(--gp-background);
}

.topbar-divider {
  width: 1px;
  height: 24px;
  background: var(--gp-border);
  margin: 0 4px;
}

.zoom-label {
  font-size: 12px;
  color: var(--gp-muted);
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.editor-toolbar {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border-right: 1px solid var(--gp-border);
  background: var(--gp-background);
}

.tool-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--gp-card-radius);
  border: 1.5px solid transparent;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gp-muted);
  font-size: 13px;
  font-family: var(--gp-font-heading);
  font-weight: 700;
  transition: all 0.1s;
  position: relative;
}

.tool-btn:hover { background: var(--gp-background-alt); color: var(--gp-foreground); border-color: var(--gp-border); }
.tool-btn.active { background: var(--gp-primary); color: #fff; border-color: var(--gp-primary); }

.tool-btn::after {
  content: attr(data-tip);
  position: absolute;
  left: 46px;
  top: 50%;
  transform: translateY(-50%);
  background: #1E293B;
  color: #fff;
  font-family: var(--gp-font-body);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 50;
}

.tool-btn:hover::after { opacity: 1; }

.toolbar-sep {
  width: 24px;
  height: 1px;
  background: var(--gp-border);
  margin: 4px 0;
}

/* Canvas area */
.editor-canvas-wrap {
  grid-column: 2;
  grid-row: 2;
  overflow: hidden;
  position: relative;
  background: #F1F5F9;
}

.canvas-bg-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #94A3B8;
  pointer-events: none;
}

#editor-canvas {
  display: block;
  cursor: crosshair;
}

.editor-canvas-wrap[data-tool="select"] #editor-canvas { cursor: default; }
.editor-canvas-wrap[data-tool="connect"] #editor-canvas { cursor: crosshair; }
.editor-canvas-wrap[data-tool="node"] #editor-canvas { cursor: move; }
.editor-canvas-wrap[data-tool="delete"] #editor-canvas { cursor: not-allowed; }
.editor-canvas-wrap[data-tool="draw"] #editor-canvas { cursor: crosshair; }
.editor-canvas-wrap[data-tool="smooth"] #editor-canvas { cursor: default; }
.editor-canvas-wrap[data-tool="pan"] #editor-canvas { cursor: grab; }

/* Right rail */
.editor-rail {
  grid-column: 3;
  grid-row: 2;
  border-left: 1px solid var(--gp-border);
  background: var(--gp-background);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.rail-section {
  padding: 16px;
  border-bottom: 1px solid var(--gp-border);
}

.rail-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gp-muted);
  margin-bottom: 12px;
}

.spec-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid #F1F5F9;
}

.spec-item:last-child { border-bottom: none; }

.spec-icon { font-size: 15px; flex-shrink: 0; line-height: 1.4; }
.spec-label { flex: 1; line-height: 1.4; }
.spec-count { font-size: 12px; color: var(--gp-muted); }

.spec-item.pass .spec-icon::before { content: '✅'; }
.spec-item.fail .spec-icon::before { content: '❌'; }
.spec-item.warn .spec-icon::before { content: '⚠️'; }
.spec-item.pending .spec-icon::before { content: '⬜'; }

/* Tiling preview */
.tiling-panel {
  border-left: 1px solid var(--gp-border);
  background: #F8FAFC;
  overflow: hidden;
  display: none;
  flex-direction: column;
}

.tiling-panel.open { display: flex; }

.tiling-panel-header {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--gp-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tiling-canvas-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
}

#tiling-canvas {
  display: block;
}

.seam-indicator {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.seam-indicator.ok { background: #DCFCE7; color: #16A34A; }
.seam-indicator.bad { background: #FEE2E2; color: #DC2626; }

/* Proceed button */
.proceed-wrap {
  padding: 16px;
  margin-top: auto;
}

.proceed-btn {
  width: 100%;
  justify-content: center;
  background: var(--gp-success);
}

.proceed-btn:hover { background: #16A34A; }
.proceed-btn:disabled { background: var(--gp-border); color: var(--gp-muted); cursor: not-allowed; }

/* Violation tooltip */
.violation-tooltip {
  position: fixed;
  background: #1E293B;
  color: #fff;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 999;
  display: none;
  gap: 8px;
  flex-direction: column;
}

.violation-tooltip.visible { display: flex; }
.nudge-btn {
  background: var(--gp-primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  pointer-events: all;
}

/* Session info bar */
.session-bar {
  font-size: 12px;
  color: var(--gp-muted);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.confidence-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.confidence-badge.high { background: #DCFCE7; color: #16A34A; }
.confidence-badge.med { background: #FEF9C3; color: #CA8A04; }
.confidence-badge.low { background: #FEE2E2; color: #DC2626; }

/* Loading overlay for editor */
.editor-loading {
  position: absolute;
  inset: 0;
  background: rgba(241,245,249,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
}

.editor-loading h3 { font-size: 15px; }
.editor-loading p { font-size: 13px; color: var(--gp-muted); }
