/* ═══════════════════════════════════════════════════════════════
   VALTUUTUS PLAYGROUND — Precision Instrument Design System
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  /* ── Backgrounds ── */
  --bg-app:      #101525;
  --bg-panel:    #18203a;
  --bg-surface:  #1b2340;
  --bg-elevated: #1e2848;
  --bg-input:    #1e2848;
  --bg-hover:    #242f55;

  /* ── Borders ── */
  --border-strong: #364875;
  --border-base:   #28365a;
  --border-dim:    #1e2848;

  /* ── Text ── */
  --text-hi:  #eaf2ff;
  --text-mid: #8aa0c0;
  --text-lo:  #445870;

  /* ── Accent — warm amber ── */
  --accent:      #f5ae38;
  --accent-hi:   #ffc055;
  --accent-soft: #b07820;
  --accent-glow: rgba(245, 174, 56, 0.14);
  --accent-dim:  rgba(245, 174, 56, 0.06);

  /* ── Semantic colors ── */
  --ok:        #58d888;
  --ok-dim:    rgba(88, 216, 136, 0.08);
  --err:       #ef6878;
  --err-dim:   rgba(239, 104, 120, 0.08);
  --rel:       #b49aee;
  --teal:      #40d0d8;
  --teal-dim:  rgba(64, 208, 216, 0.08);

  /* ── Typography ── */
  --font-ui:   'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* ── Dimensions ── */
  --app-header-h:  44px;
  --panel-hdr-h:   32px;
  --tab-h:         30px;
  --radius:        3px;
}

/* ══ Base ══════════════════════════════════════════════════════ */

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  background: var(--bg-app);
  color: var(--text-hi);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Custom scrollbars ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-soft); }

/* ══ App Shell ═════════════════════════════════════════════════ */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ══ App Header ════════════════════════════════════════════════ */

.app-header {
  height: var(--app-header-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-base);
  position: relative;
  z-index: 10;
}

/* Subtle amber accent line across the very top */
.app-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--accent-soft) 20%, var(--accent) 50%, var(--accent-soft) 80%, transparent 100%);
  opacity: 0.6;
}

.app-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-name {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.brand-sep {
  color: var(--text-lo);
  font-size: 11px;
}

.brand-sub {
  font-size: 10px;
  color: var(--text-mid);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.app-header-fill { flex: 1; }

/* ══ Layout — B2 Grid ══════════════════════════════════════════ */

.app-layout-b2 {
  flex: 1;
  display: grid;
  grid-template-columns: 480px 4px 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  min-height: 0;
  overflow: hidden;
}

.b2-schema {
  grid-column: 1;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.b2-resize-handle {
  grid-column: 2;
  grid-row: 1 / 3;
  background: var(--border-base);
  cursor: col-resize;
  transition: background 0.12s;
  position: relative;
}

.b2-resize-handle:hover,
.b2-resize-handle.dragging { background: var(--accent-soft); }

.b2-graph {
  grid-column: 3 / 5;
  grid-row: 1;
  border-bottom: 1px solid var(--border-base);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.b2-data {
  grid-column: 3;
  grid-row: 2;
  border-right: 1px solid var(--border-base);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.b2-query {
  grid-column: 4;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--border-base);
}

.panel:last-child { border-bottom: none; }

/* ══ Panel Header ══════════════════════════════════════════════ */

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: var(--panel-hdr-h);
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-base);
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-mid);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel-header > span:first-child {
  color: var(--text-hi);
  font-size: 11px;
}

/* ══ Panel Body ════════════════════════════════════════════════ */

.panel-body {
  flex: 1;
  overflow: auto;
  padding: 10px 12px;
  min-height: 0;
  background: var(--bg-panel);
}

/* ══ Tabs ══════════════════════════════════════════════════════ */

.tabs {
  display: flex;
  align-items: flex-end;
  padding: 0 10px;
  height: var(--tab-h);
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-base);
  flex-shrink: 0;
  gap: 2px;
}

.tab {
  padding: 0 12px;
  height: var(--tab-h);
  line-height: var(--tab-h);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-lo);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  transition: color 0.12s ease, border-color 0.12s ease;
  letter-spacing: 0.03em;
  font-family: var(--font-ui);
  white-space: nowrap;
}

.tab:hover { color: var(--text-mid); }

.tab.active {
  color: var(--text-hi);
  border-bottom-color: var(--accent);
}

/* ══ Monaco Editor fill ════════════════════════════════════════ */

.vtt-editor-fill {
  width: 100%;
  height: 100%;
  min-height: 200px;
}

/* ══ Section Titles ════════════════════════════════════════════ */

.section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-soft);
  margin-bottom: 7px;
}

/* ══ Form ══════════════════════════════════════════════════════ */

.form-row {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.form-row > span,
.form-row-word {
  color: var(--text-lo);
  font-size: 11px;
  font-style: italic;
  white-space: nowrap;
}

.vtt-select, .vtt-input {
  background: var(--bg-input);
  color: var(--text-hi);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 4px 7px;
  font-size: 11px;
  font-family: var(--font-mono);
  transition: border-color 0.12s ease, background 0.12s ease;
}

.vtt-select:focus, .vtt-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.vtt-select option {
  background: var(--bg-elevated);
  color: var(--text-hi);
}

/* ── Primary button ── */
.vtt-btn {
  background: var(--accent);
  color: var(--bg-app);
  border: none;
  border-radius: var(--radius);
  padding: 4px 11px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-ui);
  letter-spacing: 0.02em;
  transition: background 0.12s ease, transform 0.08s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.vtt-btn:hover { background: var(--accent-hi); }
.vtt-btn:active { transform: scale(0.96); }

/* ── Outline button ── */
.vtt-btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius);
  padding: 4px 11px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: background 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}

.vtt-btn-outline:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

/* ── Ghost button (header actions) ── */
.vtt-btn-ghost {
  background: transparent;
  color: var(--text-mid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 4px 11px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-ui);
  letter-spacing: 0.02em;
  transition: color 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}

.vtt-btn-ghost:hover {
  color: var(--accent);
  border-color: var(--accent-soft);
}

/* ══ Textarea ══════════════════════════════════════════════════ */

.vtt-textarea {
  width: 100%;
  background: var(--bg-input);
  color: var(--ok);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 7px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  resize: vertical;
  line-height: 1.7;
  transition: border-color 0.12s ease;
}

.vtt-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.vtt-textarea::placeholder { color: var(--text-lo); }

/* ══ Data Table ════════════════════════════════════════════════ */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-family: var(--font-mono);
}

.data-table th {
  text-align: left;
  padding: 4px 8px;
  color: var(--text-lo);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-base);
  font-family: var(--font-ui);
}

.data-table td {
  padding: 4px 8px;
  color: var(--text-hi);
  border-bottom: 1px solid var(--border-dim);
}

.data-table tr:hover td { background: var(--bg-elevated); }

.data-table td.entity-col   { color: var(--err); }
.data-table td.relation-col { color: var(--rel); }
.data-table td.delete-col   {
  cursor: pointer;
  color: var(--text-lo);
  text-align: center;
  width: 22px;
  padding: 4px 4px;
}
.data-table td.delete-col:hover { color: var(--err); }

/* ══ Assertion Cards ════════════════════════════════════════════ */

.assertion-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.assertion-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--border-base);
  border-radius: 2px;
  overflow: hidden;
}

.assertion-progress-fill {
  height: 100%;
  background: var(--ok);
  border-radius: 2px;
  transition: width 0.2s ease;
}

.assertion-progress-label {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-mid);
  white-space: nowrap;
}

.assertion-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border-base);
  border-left: 3px solid var(--border-base);
  margin-bottom: 4px;
  font-size: 11px;
  background: var(--bg-panel);
  transition: border-color 0.12s;
}

.assertion-card.pass {
  background: var(--ok-dim);
  border-left-color: var(--ok);
}

.assertion-card.fail {
  background: var(--err-dim);
  border-left-color: var(--err);
}

.assertion-card-icon {
  font-size: 12px;
  font-family: var(--font-mono);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.assertion-card-icon.pass    { color: var(--ok); }
.assertion-card-icon.fail    { color: var(--err); }
.assertion-card-icon.pending { color: var(--text-lo); }

.assertion-card-sentence {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  color: var(--text-hi);
}

.assertion-card-sentence .tok-subject { color: var(--text-hi); }
.assertion-card-sentence .tok-perm    { color: var(--rel); }
.assertion-card-sentence .tok-entity  { color: var(--err); }
.assertion-card-sentence .tok-word    { color: var(--text-lo); font-style: italic; font-family: var(--font-ui); }

.assertion-expect-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 2px;
  flex-shrink: 0;
}

.assertion-expect-badge.expect-allow {
  background: var(--ok-dim);
  color: var(--ok);
  border: 1px solid rgba(88, 216, 136, 0.25);
}

.assertion-expect-badge.expect-deny {
  background: var(--err-dim);
  color: var(--err);
  border: 1px solid rgba(239, 104, 120, 0.25);
}

.assertion-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.assertion-run-btn,
.assertion-del-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 2px;
  line-height: 1;
  color: var(--text-lo);
}

.assertion-run-btn:hover { color: var(--accent); }
.assertion-del-btn:hover { color: var(--err); }

.assertion-explain-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 2px;
  line-height: 1;
  color: var(--text-lo);
}

.assertion-explain-btn:hover { color: var(--cyan, #89dceb); }

/* ══ Results ═══════════════════════════════════════════════════ */

.result-allowed {
  color: var(--ok);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 12px;
}

.result-denied {
  color: var(--err);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 12px;
}

.result-list {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--teal);
  line-height: 1.9;
}

/* ══ Result Pills ══════════════════════════════════════════════ */

.result-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.result-pill {
  display: inline-flex;
  align-items: center;
  background: var(--teal-dim);
  color: var(--teal);
  border: 1px solid rgba(64, 208, 216, 0.25);
  border-radius: var(--radius);
  padding: 3px 9px;
  font-size: 11px;
  font-family: var(--font-mono);
}

.result-pill .pill-type { color: var(--text-lo); }

/* ══ Schema Validation Badges ══════════════════════════════════ */

.badge-valid {
  font-size: 11px;
  color: var(--ok);
  font-family: var(--font-mono);
  font-weight: 500;
}

.badge-invalid {
  font-size: 11px;
  color: var(--err);
  font-family: var(--font-mono);
  font-weight: 500;
}

/* ══ Mermaid Graph ═════════════════════════════════════════════ */

.cyto-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
}

/* ══ Toast ═════════════════════════════════════════════════════ */

.vtt-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--ok);
  color: var(--bg-app);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-ui);
  animation: toast-in 0.18s ease;
  z-index: 100;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* ══ Blazor Error UI ═══════════════════════════════════════════ */

#blazor-error-ui {
  display: none;
  background: #140a0c;
  border-top: 1px solid var(--err);
  bottom: 0;
  left: 0;
  padding: 8px 16px;
  position: fixed;
  width: 100%;
  z-index: 1000;
  color: var(--err);
  font-size: 12px;
  font-family: var(--font-ui);
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 12px;
  top: 8px;
}

/* ══ Loading Screen ════════════════════════════════════════════ */

.vtt-loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #101525;
}

.vtt-loading-icon {
  width: 52px;
  height: 52px;
  animation: vtt-loading-pulse 1.6s ease-in-out infinite;
}

@keyframes vtt-loading-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.vtt-loading-label {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #445870;
}

.vtt-loading-bar {
  width: 100px;
  height: 2px;
  background: #1e2848;
  border-radius: 1px;
  overflow: hidden;
}

.vtt-loading-bar-inner {
  height: 100%;
  width: 40%;
  background: #f5ae38;
  border-radius: 1px;
  animation: vtt-loading-sweep 1.6s ease-in-out infinite;
}

@keyframes vtt-loading-sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ══ Light Theme ════════════════════════════════════════════════ */

html.light {
  --bg-app:    #f0f4ff;
  --bg-panel:  #e4eaf8;
  --bg-surface: #d8e0f0;
  --bg-elevated: #ccd4e8;
  --bg-input:  #d0d8ec;
  --bg-hover:  #c4ceea;

  --border-strong: #8fa4c8;
  --border-base:   #b0bedd;
  --border-dim:    #c8d4e8;

  --text-hi:  #0c1830;
  --text-mid: #3a5070;
  --text-lo:  #7090b0;
}

/* ══ Driver.js Tour Theme ════════════════════════════════════════ */
.driver-popover.vtt-tour-popover {
    background: var(--bg-elevated) !important;
    border: 1px solid var(--border-base) !important;
    border-radius: calc(var(--radius) + 1px) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;
    font-family: var(--font-ui) !important;
    min-width: 420px !important;
    max-width: 480px !important;
    padding: 20px 22px !important;
    color: var(--text-hi) !important;
}

.driver-popover.vtt-tour-popover .driver-popover-title {
    font-size: 12px !important;
    font-weight: 700 !important;
    letter-spacing: 0.06em !important;
    color: var(--accent) !important;
    font-family: var(--font-mono) !important;
    text-transform: uppercase !important;
}

.driver-popover.vtt-tour-popover .driver-popover-description {
    font-size: 14px !important;
    line-height: 1.65 !important;
    color: var(--text-hi) !important;
}

.driver-popover.vtt-tour-popover .driver-popover-progress-text {
    font-size: 12px !important;
    color: var(--text-lo) !important;
    font-family: var(--font-mono) !important;
}

.driver-popover.vtt-tour-popover .driver-popover-footer {
    margin-top: 4px;
}

.driver-popover.vtt-tour-popover .driver-popover-prev-btn {
    background: transparent !important;
    border: 1px solid var(--border-base) !important;
    color: var(--text-mid) !important;
    font-size: 13px !important;
    font-family: var(--font-ui) !important;
    border-radius: var(--radius) !important;
    text-shadow: none !important;
}

.driver-popover.vtt-tour-popover .driver-popover-prev-btn:hover {
    border-color: var(--border-strong) !important;
    color: var(--text-hi) !important;
    background: transparent !important;
}

.driver-popover.vtt-tour-popover .driver-popover-next-btn,
.driver-popover.vtt-tour-popover .driver-popover-done-btn {
    background: var(--accent) !important;
    border: none !important;
    color: var(--bg-app) !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    font-family: var(--font-ui) !important;
    border-radius: var(--radius) !important;
    text-shadow: none !important;
}

.driver-popover.vtt-tour-popover .driver-popover-next-btn:hover,
.driver-popover.vtt-tour-popover .driver-popover-done-btn:hover {
    background: var(--accent-hi) !important;
}

.driver-popover.vtt-tour-popover .driver-popover-close-btn {
    color: var(--text-lo) !important;
}

.driver-popover.vtt-tour-popover .driver-popover-close-btn:hover {
    color: var(--text-mid) !important;
}
