/**
 * 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: 2rem;
    height: 2rem;
    border-radius: 0.375rem;
    color: var(--color-content, #1f2937);
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 1.125rem;
    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;
}

.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);
}
