/* ============================================================
   Frau Blücher — design system
   Tailwind 4 + DaisyUI 5
   Drop into wwwroot/css/frau-bluecher-theme.css and import from
   your main stylesheet AFTER tailwind/daisyui:

     @import "tailwindcss";
     @plugin "daisyui";
     @import "./frau-bluecher-theme.css";
   ============================================================ */

/* ---------- 1. Web fonts (self-hosted preferred in prod) ---- */
/* For dev, Google Fonts is fine; replace with @font-face blocks
   pointing at /fonts/... once you self-host. */
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Inter:wght@400;500;600;700&family=Caveat:wght@400;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

/* ---------- 2. Design tokens ------------------------------- */
:root {
  /* Paper palette */
  --fb-paper:        #f4ecd8;   /* main background */
  --fb-paper-light:  #faf4e3;   /* cards, inputs */
  --fb-paper-rule:   #e8dfc4;   /* dashed dividers */

  /* Ink */
  --fb-ink:          #1f1b16;   /* body + borders */
  --fb-ink-soft:     #5a5240;
  --fb-ink-faint:    #9c9275;

  /* Accents */
  --fb-accent:       #7c4d3a;   /* terracotta scura — primary */
  --fb-accent-soft:  #f0d9c8;
  --fb-oliva:        #5e6b3a;
  --fb-oliva-soft:   #e3e6cb;
  --fb-prugna:       #6b3a55;
  --fb-prugna-soft:  #ecd9e3;

  /* Washi tape */
  --fb-tape-1:       rgba(202, 174, 102, 0.55);
  --fb-tape-2:       rgba(124, 77, 58, 0.32);

  /* Avatar palette (consumed by frau-avatar.svg) */
  --fb-skin:   #f3e0d2;
  --fb-hair:   #ddd2bf;
  --fb-cheek:  #e8a89a;

  /* Type */
  --fb-font-serif: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;
  --fb-font-sans:  'Inter', ui-sans-serif, system-ui, sans-serif;
  --fb-font-hand:  'Caveat', 'Bradley Hand', cursive;
  --fb-font-mono:  'JetBrains Mono', ui-monospace, monospace;

  /* Shape */
  --fb-radius-card:   6px;
  --fb-radius-input:  6px;
  --fb-radius-pill:   999px;
  --fb-border:        1.5px solid var(--fb-ink);
  --fb-border-dashed: 1.5px dashed var(--fb-paper-rule);
  --fb-shadow-card:   3px 3px 0 rgba(31, 27, 22, 0.08);
  --fb-shadow-pop:    6px 6px 0 rgba(31, 27, 22, 0.12);
  --fb-shadow-btn:    2px 2px 0 rgba(31, 27, 22, 0.2);
}

/* ---------- 3. DaisyUI custom theme ------------------------ */
/* Activated by adding data-theme="frau" on <html>.
   Tailwind 4's @plugin "daisyui" reads themes from CSS
   declarations under [data-theme]. */
[data-theme="frau"] {
  color-scheme: light;
  --color-base-100: var(--fb-paper-light);
  --color-base-200: var(--fb-paper);
  --color-base-300: var(--fb-paper-rule);
  --color-base-content: var(--fb-ink);
  --color-primary: var(--fb-accent);
  --color-primary-content: #ffffff;
  --color-secondary: var(--fb-prugna);
  --color-secondary-content: #ffffff;
  --color-accent: var(--fb-oliva);
  --color-accent-content: #ffffff;
  --color-neutral: var(--fb-ink);
  --color-neutral-content: var(--fb-paper-light);
  --color-info: #4a6b7c;
  --color-success: var(--fb-oliva);
  --color-warning: #c79a3a;
  --color-error: #a8463a;
  --radius-selector: 0.375rem;
  --radius-field: 0.375rem;
  --radius-box: 0.5rem;
  --border: 1.5px;
}

/* ---------- 4. Base ---------------------------------------- */
html, body {
  background: var(--fb-paper);
  color: var(--fb-ink);
  font-family: var(--fb-font-sans);
}

/* Subtle horizontal rule lines, like notebook paper */
.fb-paper {
  background:
    repeating-linear-gradient(0deg,
      transparent 0, transparent 31px,
      var(--fb-paper-rule) 31px, var(--fb-paper-rule) 32px),
    radial-gradient(circle at 20% 10%, rgba(255,255,255,0.6), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(124, 77, 58, 0.04), transparent 60%),
    var(--fb-paper);
}

/* ---------- 5. Type roles ---------------------------------- */
.fb-display {
  font-family: var(--fb-font-serif);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fb-ink);
}
.fb-hand {
  font-family: var(--fb-font-hand);
  color: var(--fb-accent);
  display: inline-block;
}
.fb-mono {
  font-family: var(--fb-font-mono);
  font-size: 0.78rem;
  color: var(--fb-ink-faint);
}
.fb-eyebrow {
  font-family: var(--fb-font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fb-ink-soft);
}

/* ---------- 6. Surfaces ------------------------------------ */
.fb-card {
  background: var(--fb-paper-light);
  border: var(--fb-border);
  border-radius: var(--fb-radius-card);
  box-shadow: var(--fb-shadow-card);
}
.fb-card-flat {
  background: var(--fb-paper-light);
  border: var(--fb-border);
  border-radius: var(--fb-radius-card);
}
.fb-card-pop {
  background: var(--fb-paper-light);
  border: var(--fb-border);
  border-radius: 8px;
  box-shadow: var(--fb-shadow-pop);
}
.fb-divider-dashed {
  border-bottom: var(--fb-border-dashed);
}

/* ---------- 7. Buttons override ---------------------------- */
/* Soften DaisyUI defaults with our notebook treatment.
   Use plain .btn classes from DaisyUI; these overrides apply
   automatically inside [data-theme="frau"]. */
[data-theme="frau"] .btn {
  border-width: 1.5px;
  border-color: var(--fb-ink);
  box-shadow: var(--fb-shadow-btn);
  font-weight: 600;
}
[data-theme="frau"] .btn:hover {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(31, 27, 22, 0.18);
}
[data-theme="frau"] .btn:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}
[data-theme="frau"] .btn-ghost {
  border-color: transparent;
  box-shadow: none;
}
[data-theme="frau"] .btn-ghost:hover {
  background: var(--fb-accent-soft);
  transform: none;
  box-shadow: none;
}

/* ---------- 8. Form inputs --------------------------------- */
[data-theme="frau"] .input,
[data-theme="frau"] .select,
[data-theme="frau"] .textarea {
  border: var(--fb-border);
  background: var(--fb-paper-light);
  color: var(--fb-ink);
  font-family: var(--fb-font-sans);
}
[data-theme="frau"] .input:focus,
[data-theme="frau"] .select:focus,
[data-theme="frau"] .textarea:focus {
  outline: 2px solid var(--fb-accent);
  outline-offset: 2px;
}

/* ---------- 9. Washi tape decoration ----------------------- */
/* Sparingly. Drop a <span class="fb-tape"></span> as a child
   of a relatively-positioned card. */
.fb-tape {
  position: absolute;
  top: -8px;
  left: 50%;
  width: 64px;
  height: 18px;
  background: var(--fb-tape-1);
  transform: translateX(-50%) rotate(-3deg);
  box-shadow: inset 0 0 12px rgba(0,0,0,0.06);
  pointer-events: none;
}
.fb-tape--alt { background: var(--fb-tape-2); transform: translateX(-50%) rotate(4deg); }

/* ---------- 10. Active nav underline ----------------------- */
/* Highlighter swipe under the active nav item. Apply
   .fb-nav-item to the link, .fb-nav-item--active when active. */
.fb-nav-item {
  position: relative;
  color: var(--fb-ink-soft);
  font-weight: 500;
  padding-bottom: 4px;
  text-decoration: none;
  font-family: var(--fb-font-sans);
}
.fb-nav-item--active {
  color: var(--fb-ink);
  font-weight: 600;
}
.fb-nav-item--active::before {
  content: '';
  position: absolute;
  left: -2px; right: -2px; bottom: 1px;
  height: 6px;
  background: var(--fb-accent-soft);
  z-index: -1;
  transform: rotate(-1deg);
}

/* ---------- 11. Badges & chips ----------------------------- */
.fb-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border: 1px solid var(--fb-ink);
  border-radius: 3px;
  background: var(--fb-paper);
  font-family: var(--fb-font-mono);
  font-size: 10px;
  color: var(--fb-ink);
}

/* ---------- 12. Avatar helper ------------------------------ */
.fb-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: var(--fb-border);
  background: var(--fb-accent-soft);
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fb-avatar svg { width: 100%; height: 100%; display: block; }

/* ---------- 13. Empty-state hand-drawn note ---------------- */
.fb-empty {
  font-family: var(--fb-font-hand);
  font-size: 1.15rem;
  color: var(--fb-ink-faint);
  transform: rotate(-1deg);
  display: inline-block;
}

/* ============================================================
   Frau Blücher — variante "Sobrio" (data-theme="frau-cool")
   Stessa struttura .fb-*, palette fredda, tipografia tutta sans,
   niente texture quaderno, niente washi tape. Il markup non cambia.
   ============================================================ */
[data-theme="frau-cool"] {
  color-scheme: light;

  --fb-paper:        #f6f7f8;
  --fb-paper-light:  #fbfbfc;
  --fb-paper-rule:   #e3e6ea;

  --fb-ink:          #1c2126;
  --fb-ink-soft:     #4a5360;
  --fb-ink-faint:    #8c95a1;

  --fb-accent:       #36506e;
  --fb-accent-soft:  #dbe4ee;
  --fb-oliva:        #5a6a64;
  --fb-oliva-soft:   #dee4e1;
  --fb-prugna:       #5d4f55;
  --fb-prugna-soft:  #e6e0e3;

  --fb-skin:   #e9eaec;
  --fb-hair:   #c9ccd1;
  --fb-cheek:  #b8b1ad;

  --fb-shadow-card:   2px 2px 0 rgba(28, 33, 38, 0.06);
  --fb-shadow-pop:    4px 4px 0 rgba(28, 33, 38, 0.08);
  --fb-shadow-btn:    1px 1px 0 rgba(28, 33, 38, 0.15);

  --color-base-100: var(--fb-paper-light);
  --color-base-200: var(--fb-paper);
  --color-base-300: var(--fb-paper-rule);
  --color-base-content: var(--fb-ink);
  --color-primary: var(--fb-accent);
  --color-primary-content: #ffffff;
  --color-secondary: var(--fb-prugna);
  --color-secondary-content: #ffffff;
  --color-accent: var(--fb-oliva);
  --color-accent-content: #ffffff;
  --color-neutral: var(--fb-ink);
  --color-neutral-content: var(--fb-paper-light);
  --color-info: #4a6b7c;
  --color-success: var(--fb-oliva);
  --color-warning: #b07a2a;
  --color-error: #8a3b32;
  --radius-selector: 0.375rem;
  --radius-field: 0.375rem;
  --radius-box: 0.5rem;
  --border: 1.5px;
}

[data-theme="frau-cool"] .fb-display {
  font-family: var(--fb-font-sans);
  font-weight: 700;
  letter-spacing: -0.01em;
}
[data-theme="frau-cool"] .fb-hand {
  font-family: var(--fb-font-sans);
  font-style: italic;
  font-weight: 500;
  color: var(--fb-accent);
}
[data-theme="frau-cool"] .fb-empty {
  font-family: var(--fb-font-sans);
  font-style: italic;
  font-weight: 500;
  font-size: 0.95rem;
  transform: none;
}

[data-theme="frau-cool"] .fb-paper {
  background: var(--fb-paper);
}

[data-theme="frau-cool"] .fb-tape,
[data-theme="frau-cool"] .fb-tape--alt {
  display: none;
}

[data-theme="frau-cool"] .fb-nav-item--active::before {
  background: var(--fb-accent-soft);
  height: 4px;
  transform: none;
}

/* ============================================================
   Frau Blücher — variante "Notte" (data-theme="frau-dark")
   Tema scuro coerente: inchiostro caldo come fondo, avorio come
   testo, accenti schiariti per restare sopra AA.
   Frau mantiene il suo colorito originale grazie allo scope
   locale su .fb-avatar (vedi in fondo a questo blocco).
   ============================================================ */
[data-theme="frau-dark"] {
  color-scheme: dark;

  --fb-paper:        #1a1612;
  --fb-paper-light:  #252019;
  --fb-paper-rule:   #3a3328;

  --fb-ink:          #f0e6d0;
  --fb-ink-soft:     #bdb29a;
  --fb-ink-faint:    #7a715f;

  --fb-accent:       #d68a6e;
  --fb-accent-soft:  rgba(214, 138, 110, 0.18);
  --fb-oliva:        #a3b676;
  --fb-oliva-soft:   rgba(163, 182, 118, 0.18);
  --fb-prugna:       #c389a8;
  --fb-prugna-soft:  rgba(195, 137, 168, 0.18);

  /* Bordi e ombre adattati: in dark un bordo "ink" è troppo
     stridulo, e i drop shadow scuri spariscono. */
  --fb-border:        1px solid var(--fb-paper-rule);
  --fb-border-dashed: 1.2px dashed var(--fb-paper-rule);
  --fb-shadow-card:   0 1px 0 rgba(255, 255, 255, 0.04);
  --fb-shadow-pop:    0 2px 0 rgba(255, 255, 255, 0.05);
  --fb-shadow-btn:    0 1px 0 rgba(255, 255, 255, 0.06);

  --color-base-100: var(--fb-paper-light);
  --color-base-200: var(--fb-paper);
  --color-base-300: var(--fb-paper-rule);
  --color-base-content: var(--fb-ink);
  --color-primary: var(--fb-accent);
  --color-primary-content: #1a1612;
  --color-secondary: var(--fb-prugna);
  --color-secondary-content: #1a1612;
  --color-accent: var(--fb-oliva);
  --color-accent-content: #1a1612;
  --color-neutral: var(--fb-paper-rule);
  --color-neutral-content: var(--fb-ink);
  --color-info: #6fa3c0;
  --color-success: var(--fb-oliva);
  --color-warning: #e0b463;
  --color-error: #e07a6e;
  --radius-selector: 0.375rem;
  --radius-field: 0.375rem;
  --radius-box: 0.5rem;
  --border: 1px;
}

/* La texture a righe del quaderno in dark sembra "ledger".
   Appiattisco come fa frau-cool. */
[data-theme="frau-dark"] .fb-paper {
  background: var(--fb-paper);
}

/* Washi tape: su fondi scuri sembrano Post-it dimenticati. */
[data-theme="frau-dark"] .fb-tape,
[data-theme="frau-dark"] .fb-tape--alt {
  display: none;
}

[data-theme="frau-dark"] .fb-hand {
  opacity: 0.95;
}

[data-theme="frau-dark"] .fb-nav-item--active::before {
  height: 5px;
}

[data-theme="frau-dark"] .fb-chip {
  border-color: var(--fb-paper-rule);
  background: var(--fb-paper-light);
  color: var(--fb-ink-soft);
}

/* Frau Blücher è un personaggio: i colori del viso restano costanti
   tra i temi, altrimenti cambierebbe carnagione. Le custom properties
   locali sovrascrivono per discendenza quelle del tema, quindi l'SVG
   via <use> usa i fallback "warm" anche in dark.
   Lo sfondo è l'accent-soft del tema chiaro, pieno (non rgba): l'avatar
   appare in un medaglione caldo riconoscibile sulla card scura. */
[data-theme="frau-dark"] .fb-avatar {
  --fb-ink:   #1f1b16;
  --fb-skin:  #f3e0d2;
  --fb-hair:  #ddd2bf;
  --fb-cheek: #e8a89a;
  background: #f0d9c8;
  border-color: var(--fb-paper-rule);
}

/* ---- Tool call / tool result cards nel drawer (Fase 3) ----
   Card collassabili native (<details>/<summary>) per ogni tool call dell'assistant
   e ogni risultato del tool. Stile compatto, font monospaziato per il "codice",
   bordo discreto coerente col paper. */

.fb-tool-card,
.fb-tool-result {
  border: 1px solid var(--fb-paper-rule);
  border-radius: var(--fb-radius-card);
  background: var(--fb-paper-light);
  padding: 4px 8px;
  font-size: 0.78rem;
  color: var(--fb-ink-soft);
}

.fb-tool-result {
  /* leggera indentazione per suggerire il legame con la call sopra */
  margin-left: 16px;
  background: transparent;
  border-style: dashed;
}

.fb-tool-card summary,
.fb-tool-result summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 6px;
  outline: none;
  white-space: nowrap;
  overflow: hidden;
}

.fb-tool-card summary::-webkit-details-marker,
.fb-tool-result summary::-webkit-details-marker {
  display: none;
}

.fb-tool-badge {
  font-family: var(--fb-mono, monospace);
  font-weight: 600;
  color: var(--fb-ink);
  flex-shrink: 0;
}

.fb-tool-result-marker {
  color: var(--fb-ink-faint);
  flex-shrink: 0;
}

.fb-tool-compressed-icon {
  color: var(--fb-accent);
  flex-shrink: 0;
  cursor: help;
}

.fb-tool-args-preview {
  font-family: var(--fb-mono, monospace);
  color: var(--fb-ink-faint);
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}

.fb-tool-pre {
  margin-top: 6px;
  padding: 6px 8px;
  background: var(--fb-paper-bg, var(--fb-paper-light));
  border-radius: 4px;
  font-family: var(--fb-mono, monospace);
  font-size: 0.72rem;
  color: var(--fb-ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
}
