/* ═══════════════════════════════════════════════════════════════════════
   dolfin-suite.css — shared theme for all Dolfin suite apps
   Catppuccin Latte (light, default) + Macchiato (dark)
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Catppuccin Latte (light — CSS default) ─────────────────────────── */
:root {
  --ctp-rosewater: #dc8a78;
  --ctp-flamingo:  #dd7878;
  --ctp-pink:      #ea76cb;
  --ctp-mauve:     #8839ef;
  --ctp-red:       #d20f39;
  --ctp-maroon:    #e64553;
  --ctp-peach:     #fe640b;
  --ctp-yellow:    #df8e1d;
  --ctp-green:     #40a02b;
  --ctp-teal:      #179299;
  --ctp-sky:       #04a5e5;
  --ctp-sapphire:  #209fb5;
  --ctp-blue:      #1e66f5;
  --ctp-lavender:  #7287fd;
  --ctp-text:      #4c4f69;
  --ctp-subtext1:  #5c5f77;
  --ctp-subtext0:  #6c6f85;
  --ctp-overlay2:  #7c7f93;
  --ctp-overlay1:  #8c8fa1;
  --ctp-overlay0:  #9ca0b0;
  --ctp-surface2:  #acb0be;
  --ctp-surface1:  #bcc0cc;
  --ctp-surface0:  #ccd0da;
  --ctp-base:      #eff1f5;
  --ctp-mantle:    #e6e9ef;
  --ctp-crust:     #dce0e8;

  /* graph */
  --graph-bg:             var(--ctp-mantle);
  --graph-concept-fill:   rgba(30, 102, 245, 0.07);
  --graph-concept-stroke: var(--ctp-blue);
  --graph-concept-text:   var(--ctp-blue);
  --graph-property-fill:  rgba(114, 135, 253, 0.07);
  --graph-property-stroke:var(--ctp-lavender);
  --graph-property-text:  var(--ctp-lavender);
  --graph-edge-subclass:  var(--ctp-blue);
  --graph-edge-has:       var(--ctp-lavender);
  --graph-edge-range:     var(--ctp-green);
  --graph-field-text:     var(--ctp-subtext0);
  --graph-label-text:     var(--ctp-overlay1);
  --graph-sep-stroke:     rgba(0, 0, 0, 0.1);
  --graph-reset-bg:       var(--ctp-surface0);
  --graph-reset-border:   var(--ctp-surface2);
  --graph-reset-text:     var(--ctp-text);
  --shadow-sm:            0 1px 3px rgba(76, 79, 105, 0.1);
}

/* ── Catppuccin Macchiato (dark — explicit) ─────────────────────────── */
[data-theme="dark"] {
  --ctp-rosewater: #f4dbd6;
  --ctp-flamingo:  #f0c6c6;
  --ctp-pink:      #f5bde6;
  --ctp-mauve:     #c6a0f6;
  --ctp-red:       #ed8796;
  --ctp-maroon:    #ee99a0;
  --ctp-peach:     #f5a97f;
  --ctp-yellow:    #eed49f;
  --ctp-green:     #a6da95;
  --ctp-teal:      #8bd5ca;
  --ctp-sky:       #91d7e3;
  --ctp-sapphire:  #7dc4e4;
  --ctp-blue:      #8aadf4;
  --ctp-lavender:  #b7bdf8;
  --ctp-text:      #cad3f5;
  --ctp-subtext1:  #b8c0e0;
  --ctp-subtext0:  #a5adcb;
  --ctp-overlay2:  #939ab7;
  --ctp-overlay1:  #8087a2;
  --ctp-overlay0:  #6e738d;
  --ctp-surface2:  #5b6078;
  --ctp-surface1:  #494d64;
  --ctp-surface0:  #363a4f;
  --ctp-base:      #24273a;
  --ctp-mantle:    #1e2030;
  --ctp-crust:     #181926;

  /* graph */
  --graph-bg:             var(--ctp-mantle);
  --graph-concept-fill:   rgba(138, 173, 244, 0.12);
  --graph-concept-stroke: var(--ctp-blue);
  --graph-concept-text:   var(--ctp-blue);
  --graph-property-fill:  rgba(198, 160, 246, 0.12);
  --graph-property-stroke:var(--ctp-mauve);
  --graph-property-text:  var(--ctp-mauve);
  --graph-edge-subclass:  var(--ctp-blue);
  --graph-edge-has:       var(--ctp-mauve);
  --graph-edge-range:     var(--ctp-green);
  --graph-field-text:     var(--ctp-subtext0);
  --graph-label-text:     var(--ctp-overlay1);
  --graph-sep-stroke:     rgba(255, 255, 255, 0.08);
  --graph-reset-bg:       var(--ctp-surface0);
  --graph-reset-border:   var(--ctp-surface2);
  --graph-reset-text:     var(--ctp-text);
  --shadow-sm:            0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ── Macchiato via system preference (no override set) ──────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --ctp-rosewater: #f4dbd6;
    --ctp-flamingo:  #f0c6c6;
    --ctp-pink:      #f5bde6;
    --ctp-mauve:     #c6a0f6;
    --ctp-red:       #ed8796;
    --ctp-maroon:    #ee99a0;
    --ctp-peach:     #f5a97f;
    --ctp-yellow:    #eed49f;
    --ctp-green:     #a6da95;
    --ctp-teal:      #8bd5ca;
    --ctp-sky:       #91d7e3;
    --ctp-sapphire:  #7dc4e4;
    --ctp-blue:      #8aadf4;
    --ctp-lavender:  #b7bdf8;
    --ctp-text:      #cad3f5;
    --ctp-subtext1:  #b8c0e0;
    --ctp-subtext0:  #a5adcb;
    --ctp-overlay2:  #939ab7;
    --ctp-overlay1:  #8087a2;
    --ctp-overlay0:  #6e738d;
    --ctp-surface2:  #5b6078;
    --ctp-surface1:  #494d64;
    --ctp-surface0:  #363a4f;
    --ctp-base:      #24273a;
    --ctp-mantle:    #1e2030;
    --ctp-crust:     #181926;

    --graph-bg:             var(--ctp-mantle);
    --graph-concept-fill:   rgba(138, 173, 244, 0.12);
    --graph-concept-stroke: var(--ctp-blue);
    --graph-concept-text:   var(--ctp-blue);
    --graph-property-fill:  rgba(198, 160, 246, 0.12);
    --graph-property-stroke:var(--ctp-mauve);
    --graph-property-text:  var(--ctp-mauve);
    --graph-edge-subclass:  var(--ctp-blue);
    --graph-edge-has:       var(--ctp-mauve);
    --graph-edge-range:     var(--ctp-green);
    --graph-field-text:     var(--ctp-subtext0);
    --graph-label-text:     var(--ctp-overlay1);
    --graph-sep-stroke:     rgba(255, 255, 255, 0.08);
    --graph-reset-bg:       var(--ctp-surface0);
    --graph-reset-border:   var(--ctp-surface2);
    --graph-reset-text:     var(--ctp-text);
    --shadow-sm:            0 1px 3px rgba(0, 0, 0, 0.3);
  }
}

/* ── Base reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 16px;
  background-color: var(--ctp-base);
  color: var(--ctp-text);
}

a {
  color: var(--ctp-blue);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

input, textarea, select {
  background-color: var(--ctp-mantle);
  color: var(--ctp-text);
  border: 1px solid var(--ctp-surface0);
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  font-size: inherit;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--ctp-blue);
  outline-offset: 1px;
}

button {
  background-color: var(--ctp-surface0);
  color: var(--ctp-text);
  border: 1px solid var(--ctp-surface1);
  border-radius: 4px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
}
button:hover:not(:disabled) { background-color: var(--ctp-surface1); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

ul { list-style: none; padding: 0; margin: 0; }

/* ── Shared utility classes ─────────────────────────────────────────── */
.btn-primary {
  background-color: var(--ctp-blue);
  color: var(--ctp-base);
  border-color: var(--ctp-blue);
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--ctp-lavender);
  border-color: var(--ctp-lavender);
}

.muted  { color: var(--ctp-subtext0); }
.error  { color: var(--ctp-red); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--ctp-base);
}
.badge-errors   { background: var(--ctp-red); }
.badge-warnings { background: var(--ctp-peach); }
.badge-clean    { background: var(--ctp-green); }

/* ── Dolfin suite nav bar ───────────────────────────────────────────── */
.dn-bar {
  display: flex;
  align-items: center;
  gap: 0;
  height: 48px;
  padding: 0 1rem;
  background-color: var(--ctp-mantle);
  border-bottom: 1px solid var(--ctp-surface0);
  position: sticky;
  top: 0;
  z-index: 100;
}

.dn-brand {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  color: var(--ctp-lavender);
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
  margin-right: 1.5rem;
}
.dn-brand:hover { text-decoration: none; color: var(--ctp-blue); }

.dn-brand__logo { height: 24px; width: auto; display: block; }
.dn-brand__app  { color: var(--ctp-text); font-weight: 600; font-size: 0.95rem; }

.dn-links {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex: 1;
  height: 100%;
}

.dn-link {
  display: flex;
  align-items: center;
  padding: 0 0.85rem;
  font-size: 0.875rem;
  color: var(--ctp-subtext1);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.dn-link:hover {
  color: var(--ctp-text);
  text-decoration: none;
  background-color: color-mix(in srgb, var(--ctp-blue) 5%, transparent);
}
.dn-link--active {
  color: var(--ctp-blue);
  border-bottom-color: var(--ctp-blue);
  font-weight: 500;
}

.dn-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

.dn-theme-btn {
  background: transparent;
  border-color: transparent;
  font-size: 1rem;
  padding: 0.25rem 0.5rem;
  color: var(--ctp-subtext0);
  line-height: 1;
}
.dn-theme-btn:hover:not(:disabled) {
  background-color: var(--ctp-surface0);
  border-color: transparent;
  color: var(--ctp-text);
}

/* ── Suite apps dropdown ────────────────────────────────────────────── */
.dn-suite {
  position: relative;
  display: flex;
  align-items: stretch;
}

.dn-suite-btn {
  background: transparent;
  border-color: transparent;
  color: var(--ctp-subtext1);
  font-size: 0.875rem;
  padding: 0 0.85rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s;
}
.dn-suite-btn:hover:not(:disabled) {
  background-color: color-mix(in srgb, var(--ctp-blue) 5%, transparent);
  border-color: transparent;
  color: var(--ctp-text);
}
.dn-suite-caret { font-size: 0.65rem; opacity: 0.7; }

.dn-suite-menu {
  display: none;
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  background: var(--ctp-mantle);
  border: 1px solid var(--ctp-surface1);
  border-radius: 6px;
  padding: 0.25rem;
  min-width: 130px;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  flex-direction: column;
}

.dn-suite:hover .dn-suite-menu,
.dn-suite:focus-within .dn-suite-menu {
  display: flex;
}

.dn-suite-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  color: var(--ctp-text);
  text-decoration: none;
  font-size: 0.875rem;
  white-space: nowrap;
}
.dn-suite-item:hover { background: var(--ctp-surface0); text-decoration: none; }
.dn-suite-item--active { color: var(--ctp-blue); font-weight: 500; }
.dn-suite-item__logo {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ── Nav action helpers ─────────────────────────────────────────────── */
.dn-avatar-link {
  display: flex;
  align-items: center;
  border-radius: 50%;
  text-decoration: none;
}
.dn-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--ctp-surface1);
}
.dn-avatar-link:hover .dn-avatar { border-color: var(--ctp-blue); }

.dn-label {
  font-size: 0.875rem;
  padding: 0 0.25rem;
  white-space: nowrap;
}

/* ── Version update banner (shared) ────────────────────────────────── */
.version-banner {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--ctp-blue);
  color: var(--ctp-base);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  z-index: 9999;
  white-space: nowrap;
}
.version-banner-text { font-size: 0.9rem; }
.version-banner-btn {
  background: var(--ctp-base);
  color: var(--ctp-blue);
  border: none;
  border-radius: 4px;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.version-banner-btn:hover { background: var(--ctp-surface0); }

/* ── Diagnostics panel (shared between playground and pangloss) ─────── */
.dolfin-problems-panel {
  background: var(--ctp-mantle);
  border-top: 1px solid var(--ctp-surface0);
  flex-shrink: 0;
  max-height: 200px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dolfin-problems-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-bottom: 1px solid var(--ctp-surface0);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ctp-subtext0);
  flex-shrink: 0;
}
.dolfin-problems-list { overflow-y: auto; padding: 4px 0; }
.dolfin-problems-empty {
  padding: 12px;
  color: var(--ctp-subtext0);
  font-size: 0.8rem;
  text-align: center;
}
.problem-card {
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  margin: 2px 6px;
  border-radius: 6px;
  background: var(--ctp-base);
  border: 1px solid var(--ctp-surface0);
  font-size: 0.8rem;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.15s;
}
.problem-card:hover { background: var(--ctp-surface0); border-color: var(--ctp-blue); }
.problem-card.error   .problem-message { color: var(--ctp-red); }
.problem-card.warning .problem-message { color: var(--ctp-peach); }
.problem-card.hint    .problem-message { color: var(--ctp-blue); }
.problem-card.info    .problem-message { color: var(--ctp-teal); }
.problem-icon    { font-size: 1rem; flex-shrink: 0; line-height: 1.4; }
.problem-body    { flex: 1; min-width: 0; }
.problem-message { color: var(--ctp-text); word-break: break-word; }
.problem-location {
  margin-top: 2px;
  font-size: 0.7rem;
  color: var(--ctp-subtext0);
  font-family: monospace;
}

/* ── Footer ─────────────────────────────────────────────────────────── */
.dn-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.25rem 1rem;
  border-top: 1px solid var(--ctp-surface0);
  background-color: var(--ctp-mantle);
  margin-top: auto;
}
.dn-footer__text {
  font-size: 0.8rem;
  color: var(--ctp-subtext0);
}
.dn-footer__link {
  color: var(--ctp-lavender);
  text-decoration: none;
}
.dn-footer__link:hover { text-decoration: underline; }

/* ── Inherited fields collapsible rows ──────────────────────────────── */
.inherited-group-header {
  cursor: pointer;
  user-select: none;
  background: var(--ctp-surface0);
}
.inherited-group-header td {
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ctp-subtext1);
  border-top: 2px solid var(--ctp-surface1);
}
.inherited-group-header:hover td {
  background: var(--ctp-surface1);
  color: var(--ctp-text);
}
.inherited-toggle-icon {
  display: inline-block;
  margin-right: 0.45rem;
  font-size: 0.6rem;
  color: var(--ctp-overlay1);
  transition: transform 0.15s ease;
}
.inherited-toggle-icon::before { content: "▶"; }
.inherited-toggle-icon.open { transform: rotate(90deg); }
.inherited-row.hidden { display: none; }
