/**
 * Nexilo Custom Styles
 *
 * Onest Variable Font (self-hosted, GDPR-konform).
 * Onest 300 = Light (kleine UI-Elemente)
 * Onest 400 = Regular (Default)
 * Onest 500/600/700 = Medium / SemiBold / Bold
 *
 * Alle Subsets sind Variable-Font-Dateien (font-weight 300..700 in einer Datei).
 */

/* ============================================
   Onest Font Faces (Variable Font, 4 Subsets)
   ============================================ */
@font-face {
    font-family: 'Onest';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('/nexilo/fonts/onest/onest-cyrillic-ext.woff2') format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
    font-family: 'Onest';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('/nexilo/fonts/onest/onest-cyrillic.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: 'Onest';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('/nexilo/fonts/onest/onest-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Onest';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('/nexilo/fonts/onest/onest-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ============================================
   Global Defaults
   ============================================ */
:root {
    --font-family-primary: 'Onest', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    --font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Cascadia Mono', Consolas, 'Courier New', monospace;
}

html {
    font-size: 16px;
    line-height: 1.65;
}

body {
    font-family: var(--font-family-primary);
    font-weight: 400;
}

/* Code-Elemente bleiben Monospace (Lesbarkeit) */
code,
kbd,
samp,
pre,
.font-mono {
    font-family: var(--font-family-mono);
}

/* Utility: kleine UI-Elemente in Onest Light 300 */
.font-light-ui {
    font-weight: 300;
}

/* ============================================
   Sidebar Navigation: 15px
   ============================================ */
aside nav a,
aside nav button,
aside nav li,
aside nav span {
    font-size: 15px;
}

/* ============================================
   Chat: User-Nachrichten visuell hervorheben
   ============================================ */
.message[data-role="user"] .content {
    background-color: #f5f6f6;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
}

[data-mode="dark"] .message[data-role="user"] .content {
    background-color: #191a1c;
}

/* ============================================
   Chat: KI-Antworten in Onest (einheitlich)
   Code-Blöcke darin bleiben Monospace.
   ============================================ */
.message[data-role="assistant"] x-markdown > div,
.message[data-role="user"] x-markdown > div {
    font-family: var(--font-family-primary);
    line-height: 1.65;
}

.message x-markdown > div pre,
.message x-markdown > div code,
.message x-markdown > div :not(pre) > code {
    font-family: var(--font-family-mono);
}

/* ============================================
   Rich Text Editor (TipTap) für Dokument-Quellen
   ============================================ */
.rich-editor {
    border: 1px solid var(--color-line, #e5e7eb);
    border-radius: 0.75rem;
    background: var(--color-background, #fff);
    overflow: hidden;
}

.rich-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.125rem;
    padding: 0.5rem;
    border-bottom: 1px solid var(--color-line, #e5e7eb);
    background: var(--color-line-dimmed, #f5f6f6);
}

.rich-editor-toolbar-sep {
    width: 1px;
    height: 1.25rem;
    margin: 0 0.375rem;
    background: var(--color-line, #d4d4d8);
}

.rich-editor-toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1rem;
    border-radius: 0.375rem;
    color: var(--color-content, #1f2937);
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.15s, color 0.15s;
}

.rich-editor-toolbar-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.06);
}

.rich-editor-toolbar-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.rich-editor-toolbar-btn.is-active {
    background: var(--color-content, #1f2937);
    color: var(--color-background, #fff);
}

[data-mode="dark"] .rich-editor-toolbar-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
}

.rich-editor-surface {
    max-height: 60vh;
    overflow-y: auto;
}

.rich-editor-content {
    padding: 1rem 1.25rem;
    min-height: 14rem;
    font-family: var(--font-family-primary);
    line-height: 1.65;
    outline: none;
    color: var(--color-content, #1f2937);
}
[data-mode="dark"] .rich-editor-content {
    color: #e2e8f0;
}
[data-mode="dark"] .rich-editor-content h1,
[data-mode="dark"] .rich-editor-content h2,
[data-mode="dark"] .rich-editor-content h3,
[data-mode="dark"] .rich-editor-content h4,
[data-mode="dark"] .rich-editor-content h5,
[data-mode="dark"] .rich-editor-content h6,
[data-mode="dark"] .rich-editor-content strong,
[data-mode="dark"] .rich-editor-content b {
    color: #f1f5f9;
}

.rich-editor-content > *:first-child { margin-top: 0; }
.rich-editor-content > *:last-child { margin-bottom: 0; }

.rich-editor-content h1 { font-size: 1.5rem; font-weight: 700; margin: 1rem 0 0.5rem; }
.rich-editor-content h2 { font-size: 1.25rem; font-weight: 700; margin: 0.875rem 0 0.5rem; }
.rich-editor-content h3 { font-size: 1.125rem; font-weight: 600; margin: 0.75rem 0 0.5rem; }
.rich-editor-content p { margin: 0.5rem 0; }
.rich-editor-content ul,
.rich-editor-content ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.rich-editor-content ul { list-style: disc; }
.rich-editor-content ol { list-style: decimal; }
.rich-editor-content ul[data-type="taskList"] { list-style: none; padding-left: 0; }
.rich-editor-content ul[data-type="taskList"] li { display: flex; gap: 0.5rem; }
.rich-editor-content ul[data-type="taskList"] li > label { user-select: none; }
.rich-editor-content blockquote {
    border-left: 3px solid var(--color-line, #d4d4d8);
    padding-left: 0.875rem;
    color: var(--color-content-dimmed, #6b7280);
    margin: 0.75rem 0;
}
.rich-editor-content code {
    font-family: var(--font-family-mono);
    background: rgba(0, 0, 0, 0.06);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.95em;
}
.rich-editor-content pre {
    font-family: var(--font-family-mono);
    background: var(--color-line-dimmed, #f5f6f6);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin: 0.75rem 0;
    overflow-x: auto;
}
.rich-editor-content pre code {
    background: transparent;
    padding: 0;
}
.rich-editor-content a { color: var(--color-primary, #3b82f6); text-decoration: underline; }
.rich-editor-content hr {
    border: 0;
    border-top: 1px solid var(--color-line, #e5e7eb);
    margin: 1rem 0;
}
.rich-editor-content img {
    max-width: 100%;
    border-radius: 0.5rem;
    margin: 0.5rem 0;
}
.rich-editor-content table {
    border-collapse: collapse;
    margin: 0.75rem 0;
    width: 100%;
    table-layout: fixed;
}
.rich-editor-content table td,
.rich-editor-content table th {
    border: 1px solid var(--color-line, #e5e7eb);
    padding: 0.375rem 0.5rem;
    vertical-align: top;
    min-width: 4rem;
}
.rich-editor-content table th {
    background: var(--color-line-dimmed, #f5f6f6);
    font-weight: 600;
}

[data-mode="dark"] .rich-editor {
    background: var(--color-intermediate, #191a1c);
}
[data-mode="dark"] .rich-editor-content code,
[data-mode="dark"] .rich-editor-content pre {
    background: rgba(255, 255, 255, 0.06);
}

/* === Rich-Editor Tabellen-Popover === */
.rich-editor-popover {
  display: flex;
  background: var(--color-main, #fff);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 0.75rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  padding: 0.5rem;
  gap: 0.5rem;
  min-width: 22rem;
  font-size: 0.875rem;
}
[data-mode="dark"] .rich-editor-popover {
  background: #1f1f23;
  border-color: rgba(255, 255, 255, 0.08);
}
.rich-editor-popover-list {
  display: flex;
  flex-direction: column;
  min-width: 11rem;
  border-right: 1px solid rgba(0, 0, 0, 0.06);
  padding-right: 0.5rem;
}
[data-mode="dark"] .rich-editor-popover-list {
  border-right-color: rgba(255, 255, 255, 0.08);
}
.rich-editor-popover-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: transparent;
  border: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font-size: inherit;
}
.rich-editor-popover-item:hover:not(:disabled),
.rich-editor-popover-item.is-active {
  background: rgba(0, 0, 0, 0.05);
}
[data-mode="dark"] .rich-editor-popover-item:hover:not(:disabled),
[data-mode="dark"] .rich-editor-popover-item.is-active {
  background: rgba(255, 255, 255, 0.06);
}
.rich-editor-popover-item.is-danger {
  color: #d6336c;
}
.rich-editor-popover-item:disabled,
.rich-editor-popover-submenu.is-disabled .rich-editor-popover-item {
  opacity: 0.4;
  cursor: not-allowed;
}
.rich-editor-popover-sep {
  height: 1px;
  background: rgba(0, 0, 0, 0.06);
  margin: 0.25rem 0;
}
[data-mode="dark"] .rich-editor-popover-sep {
  background: rgba(255, 255, 255, 0.08);
}
.rich-editor-popover-submenu {
  position: relative;
}
.rich-editor-popover-flyout {
  display: none;
  position: absolute;
  top: -0.5rem;
  left: 100%;
  margin-left: -0.25rem;
  background: var(--color-main, #fff);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 0.75rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  padding: 0.5rem;
  min-width: 13rem;
  flex-direction: column;
  z-index: 1;
}
[data-mode="dark"] .rich-editor-popover-flyout {
  background: #1f1f23;
  border-color: rgba(255, 255, 255, 0.08);
}
.rich-editor-popover-submenu:hover .rich-editor-popover-flyout {
  display: flex;
}
.rich-editor-popover-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem;
  gap: 0.5rem;
}
.rich-editor-grid {
  display: grid;
  gap: 4px;
}
.rich-editor-grid-cell {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: background 80ms, border-color 80ms;
}
[data-mode="dark"] .rich-editor-grid-cell {
  border-color: rgba(255, 255, 255, 0.25);
}
.rich-editor-grid-cell.is-active {
  border-color: #111;
  background: rgba(0, 0, 0, 0.05);
}
[data-mode="dark"] .rich-editor-grid-cell.is-active {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.1);
}
.rich-editor-grid-label {
  font-size: 0.8rem;
  color: var(--color-content-dimmed, #6b7280);
}

/* === Rich-Editor Inline Caption (Bildbeschreibung unter dem Bild) === */
.rich-editor-figure {
  display: block;
  margin: 0;
}
/* Marker text list below image */
.rich-editor-marker-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  color: var(--color-content, #1f2937);
  line-height: 1.6;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}
.rich-editor-marker-list li {
  list-style: none;
  padding: 0.05rem 0;
}
[data-mode="dark"] .rich-editor-marker-list {
  border-top-color: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.rich-editor-caption {
  display: block;
  margin-top: 0.25rem;
  padding: 0.3rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  color: var(--color-content, #1f2937);
  font-style: italic;
  text-align: center;
  line-height: 1.4;
  transition: background 120ms;
}
.rich-editor-caption.is-placeholder {
  font-style: normal;
  color: var(--color-content-dimmed, #9ca3af);
  border: 1px dashed rgba(0, 0, 0, 0.18);
  cursor: pointer;
}
.rich-editor-caption.is-placeholder:hover {
  background: rgba(0, 0, 0, 0.03);
}
[data-mode="dark"] .rich-editor-caption.is-placeholder {
  border-color: rgba(255, 255, 255, 0.18);
}
[data-mode="dark"] .rich-editor-caption.is-placeholder:hover {
  background: rgba(255, 255, 255, 0.04);
}
/* clicking existing caption text to edit */
.rich-editor-caption:not(.is-placeholder):not(.is-editing) {
  cursor: pointer;
}
.rich-editor-caption:not(.is-placeholder):not(.is-editing):hover {
  background: rgba(0, 0, 0, 0.04);
}
[data-mode="dark"] .rich-editor-caption:not(.is-placeholder):not(.is-editing):hover {
  background: rgba(255, 255, 255, 0.05);
}
.rich-editor-caption.is-editing {
  cursor: default;
  padding: 0;
  border: none;
  text-align: left;
  font-style: normal;
}
/* Inline edit panel */
.rich-editor-caption-hint {
  font-size: 0.75rem;
  color: var(--color-content-dimmed, #6b7280);
  line-height: 1.45;
  margin: 0 0 0.45rem;
  padding: 0.45rem 0.625rem;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 0.375rem;
}
[data-mode="dark"] .rich-editor-caption-hint {
  background: rgba(255, 255, 255, 0.04);
}
.rich-editor-caption-input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0.5rem;
  background: transparent;
  color: inherit;
  font-size: 0.875rem;
  font-style: normal;
  outline: none;
  transition: border-color 150ms;
}
.rich-editor-caption-input:focus {
  border-color: var(--color-primary, #3b82f6);
}
[data-mode="dark"] .rich-editor-caption-input {
  border-color: rgba(255, 255, 255, 0.15);
}
[data-mode="dark"] .rich-editor-caption-input:focus {
  border-color: var(--color-primary, #818cf8);
}
.rich-editor-caption-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
/* Shared button style (used by caption save/cancel) */
.rich-editor-alttext-btn {
  padding: 0.375rem 0.875rem;
  border-radius: 0.5rem;
  border: 0;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms;
}
.rich-editor-alttext-btn--cancel {
  background: transparent;
  color: var(--color-content-dimmed, #6b7280);
}
.rich-editor-alttext-btn--cancel:hover {
  background: rgba(0, 0, 0, 0.06);
}
[data-mode="dark"] .rich-editor-alttext-btn--cancel:hover {
  background: rgba(255, 255, 255, 0.08);
}
.rich-editor-alttext-btn--ok {
  background: var(--color-content, #1f2937);
  color: var(--color-background, #fff);
}
.rich-editor-alttext-btn--ok:hover {
  opacity: 0.85;
}
[data-mode="dark"] .rich-editor-alttext-btn--ok {
  background: rgba(255, 255, 255, 0.9);
  color: #111;
}
.rich-editor-alttext-btn--delete {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  margin-right: auto;
}
.rich-editor-alttext-btn--delete:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* ============================================
   Image Marker Pins
   ============================================ */
/* Wrapper that anchors the absolute-positioned pins overlay */
.rich-editor-img-wrap {
  position: relative;
  display: block;
  line-height: 0;
}
.rich-editor-img-wrap img {
  display: block;
  width: 100%;
}
/* Transparent overlay that holds pin <button>s */
.rich-editor-marker-pins {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
/* Circular numbered pin */
.rich-editor-marker-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #101927;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: transform 120ms, background 120ms;
  padding: 0;
}
.rich-editor-marker-pin:hover {
  transform: translate(-50%, -50%) scale(1.18);
  background: #1d3047;
}
/* Cursor crosshair when marker-mode is active */
.rich-editor-img-wrap.is-marker-mode {
  cursor: crosshair;
}
.rich-editor-img-wrap.is-marker-mode img {
  cursor: crosshair;
}
/* "+ Marker" overlay button */
.rich-editor-add-marker-btn {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.625rem;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: 0;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 0.35rem;
  z-index: 3;
  transition: background 120ms;
  pointer-events: auto;
}
.rich-editor-add-marker-btn:hover,
.rich-editor-add-marker-btn.is-active {
  background: rgba(0, 0, 0, 0.75);
}
/* Show button when hovering the image wrapper (edit mode only) */
.rich-editor-img-wrap:hover .rich-editor-add-marker-btn {
  display: flex;
}
/* Marker dialog (small inline popup on pins overlay) */
.rich-editor-marker-dialog {
  position: absolute;
  z-index: 10;
  background: var(--color-background, #fff);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 0.625rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 0.75rem;
  min-width: 13rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: auto;
}
[data-mode="dark"] .rich-editor-marker-dialog {
  background: var(--color-surface, #1f2937);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.rich-editor-marker-dialog-title {
  font-size: 0.8125rem;
  font-weight: 600;
  font-style: normal;
  color: var(--color-content-dimmed, #6b7280);
}

/* ============================================
   Version Diff Modal
   ============================================ */
.version-diff-ins {
    background: rgba(34, 197, 94, 0.18);
    color: #15803d;
    text-decoration: none;
    border-radius: 2px;
    padding: 0 1px;
}
.version-diff-del {
    background: rgba(239, 68, 68, 0.15);
    color: #b91c1c;
    text-decoration: line-through;
    border-radius: 2px;
    padding: 0 1px;
}
[data-mode="dark"] .version-diff-ins {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}
[data-mode="dark"] .version-diff-del {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* ============================================
   Color / Highlight Picker in der Toolbar
   ============================================ */
.rich-editor-color-wrap {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    cursor: pointer;
    overflow: hidden;
}
.rich-editor-color-swatch {
    width: 14px;
    height: 3px;
    border-radius: 2px;
    pointer-events: none;
    flex-shrink: 0;
}
.rich-editor-color-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
}

/* ============================================
   Zeichenzähler (Character Count)
   ============================================ */
.rich-editor-char-count {
    padding: 0.25rem 1.25rem;
    font-size: 0.75rem;
    color: var(--color-content-dimmed, #9ca3af);
    border-top: 1px solid var(--color-border, rgba(0,0,0,0.1));
    text-align: right;
    user-select: none;
}
[data-mode="dark"] .rich-editor-char-count {
    border-top-color: rgba(255,255,255,0.08);
}

/* ============================================
   Placeholder-Text (TipTap)
   ============================================ */
.rich-editor-content p.is-editor-empty:first-child::before,
.rich-editor-content p.is-empty:first-child::before {
    content: attr(data-placeholder);
    float: left;
    color: var(--color-content-dimmed, #9ca3af);
    pointer-events: none;
    height: 0;
}
