/* ─── Design tokens (from nextscope) ─────────────────────────────────────── */
:root {
  /* Backgrounds */
  --color-bg:           #1C1C1E;
  --color-surface:      #2A2A2D;
  --color-border:       #333336;

  /* Brand Accents */
  --color-primary:      #D4523A;
  --color-secondary:    #7B4E8A;

  /* Signature Gradient */
  --gradient-brand: linear-gradient(180deg, #D4523A 0%, #C4566B 50%, #7B4E8A 100%);

  /* Typography */
  --color-text-primary:   #F0EDE8;
  --color-text-secondary: #9A9490;

  /* Semantic */
  --color-success:  #3DB87A;
  --color-warning:  #C47A10;
  --color-error:    #D94F3D;
  --color-info:     #3A8FC4;

  /* Alpha variants */
  --color-primary-alpha: rgba(212, 82, 58, 0.15);
  --color-on-primary:    #F0EDE8;

  /* Shadows */
  --color-shadow:    rgba(0, 0, 0, 0.4);
  --color-backdrop:  rgba(0, 0, 0, 0.6);
  --shadow-subtle:   0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-medium:   0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-elevated: 0 4px 16px rgba(0, 0, 0, 0.5);

  /* Layout */
  --topnav-height: 65px;
}

[data-theme="light"] {
  --color-bg:             #F5F2EE;
  --color-surface:        #EDEAE5;
  --color-border:         #D6D0C8;

  --color-primary:        #C94530;
  --color-secondary:      #6B3F7A;

  --color-text-primary:   #1C1A18;
  --color-text-secondary: #6B635A;

  --color-success:        #2D9A63;
  --color-warning:        #B56E0A;
  --color-error:          #C43828;
  --color-info:           #2E7DB0;

  --color-on-primary:     #F5F2EE;
  --color-primary-alpha:  rgba(201, 69, 48, 0.12);

  --color-shadow:    rgba(28, 20, 14, 0.12);
  --color-backdrop:  rgba(28, 20, 14, 0.5);
  --shadow-subtle:   0 1px 3px var(--color-shadow);
  --shadow-medium:   0 2px 8px var(--color-shadow);
  --shadow-elevated: 0 4px 16px var(--color-shadow);
}

/* ─── Reset & base ───────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: "Lato", sans-serif;
  margin: 0;
  padding-top: var(--topnav-height);
  font-size: 16px;
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ─── Top navigation bar (nextscope style) ───────────────────────────────── */
.topnav {
  width: 100%;
  left: 0;
  top: 0;
  position: fixed;
  height: var(--topnav-height);
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-medium);
  display: flex;
  align-items: center;
  color: var(--color-text-primary);
  z-index: 100;
  overflow: visible;
}

/* NextPower brand logo */
.topnav-brand-logo {
  width: 180px;
  padding: 8px 16px;
  flex-shrink: 0;
  cursor: default;
}

.logo-light-theme { display: none; }
.logo-dark-theme  { display: block; }

[data-theme="light"] .logo-light-theme { display: block; }
[data-theme="light"] .logo-dark-theme  { display: none; }

/* Thin vertical separator after logo */
.topnav-divider {
  width: 1px;
  height: 28px;
  background-color: var(--color-border);
  flex-shrink: 0;
  margin: 0 4px;
}

/* App name — absolutely centered in the topnav regardless of side content */
.topnav-apptitle {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text-primary);
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0.03em;
}

@media (max-width: 700px) {
  .topnav-apptitle {
    display: none;
  }
}

/* Push everything after this to the right */
.topnav-spacer {
  flex: 1;
}

/* Generic icon-link action buttons */
.topnav a,
.topnav-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-primary);
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 20px;
  cursor: pointer;
  border-radius: 12px;
  background: none;
  border: none;
  transition: background-color 0.15s ease;
}

.topnav a:hover,
.topnav-action:hover {
  background-color: var(--color-border);
}

.topnav-action.disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

/* File-open button: icon + hidden file input stacked */
.topnav-fileopen {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-primary);
  font-size: 20px;
  padding: 14px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.topnav-fileopen:hover {
  background-color: var(--color-border);
}

.topnav-fileopen input[type="file"] {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Theme toggle button */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--color-text-primary);
  cursor: pointer;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.theme-toggle:hover {
  background-color: var(--color-border);
}

/* Nextscope title logo (right-aligned end of navbar) */
.headImg {
  padding: 8px 16px;
  width: 180px;
  flex-shrink: 0;
  cursor: default;
}

/* ─── Stats bar ──────────────────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 12px;
  padding: 10px 16px;
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 8px 20px;
  min-width: 130px;
  box-shadow: var(--shadow-subtle);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Bias pitch: same column order as other stat-cards — value on top, label below */
.stat-value--bias {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 1.2em;
}

.stat-card--bias input[type="number"] {
  width: 5.5rem;
  padding: 0 4px 2px;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: var(--color-primary);
  background-color: transparent;
  border: none;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  text-align: center;
}

.stat-card--bias input[type="number"]:focus {
  outline: none;
  border-bottom-color: var(--color-primary);
}

/* ─── Drop zone (shown before file loaded) ───────────────────────────────── */
.drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--topnav-height));
  padding: 40px;
  cursor: pointer;
}

.drop-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 360px;
  height: 220px;
  border: 3px dashed var(--color-primary);
  border-radius: 20px;
  background: var(--gradient-brand);
  box-shadow: var(--shadow-elevated);
  cursor: pointer;
  transition: opacity 0.2s ease;
  text-align: center;
  padding: 24px;
}

.drop-indicator:hover {
  opacity: 0.9;
}

.drop-icon {
  font-size: 48px;
  color: var(--color-on-primary);
  line-height: 1;
  margin-bottom: 12px;
}

.drop-text {
  font-size: 15px;
  color: var(--color-on-primary);
  line-height: 1.5;
}

.drop-zone.drag-active .drop-indicator {
  opacity: 0.85;
  border-style: solid;
}

/* ─── Plot area — left column (toggled) + right side-view ───────────────── */
.plot-area {
  padding: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

.plot-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

#plot-panel-tilt-lines,
#plot-panel-roll-lines,
#plot-panel-pitch,
#plot-panel-roll {
  flex: 0 0 320px;
  width: 100%;
  height: 320px;
}

#plot-pitch {
  display: none;
}

.side-view-wrapper {
  flex: 0 0 33.333%;
  width: 33.333%;
  display: flex;
  flex-direction: column;
}

.side-view-toggle {
  justify-content: center;
  margin: 6px 0 2px;
  flex-shrink: 0;
}

#plot-side-view {
  width: 100%;
  height: 640px;
}

.resize-handle {
  flex: 0 0 5px;
  width: 5px;
  cursor: col-resize;
  background: var(--color-border);
  transition: background-color 0.15s ease;
  flex-shrink: 0;
}

.resize-handle:hover,
.resize-handle.dragging {
  background: var(--color-primary);
}

/* Hide the inactive axis pair and the side view for pitch */
.plot-area[data-axis="pitch"] #plot-panel-roll-lines,
.plot-area[data-axis="pitch"] #plot-panel-roll,
.plot-area[data-axis="pitch"] .side-view-wrapper {
  display: none;
}

.plot-area[data-axis="roll"] #plot-panel-tilt-lines,
.plot-area[data-axis="roll"] #plot-panel-pitch {
  display: none;
}

/* ─── Axis toggle (Pitch / Roll pill in topnav) ──────────────────────────── */
.axis-toggle {
  display: flex;
  align-items: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  margin: 0 6px;
  flex-shrink: 0;
}

.axis-btn {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  line-height: 1.4;
}

.axis-btn.active {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

.axis-btn:hover:not(.active) {
  background: var(--color-border);
  color: var(--color-text-primary);
}

/* ─── Focus rings ────────────────────────────────────────────────────────── */
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ─── Utility ────────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}
