/* Floating n8n chat, themed to match the site (dark glass + red accent). Load after the n8n style.css. */
html:root {
  --chat--font-family: var(--body);
  --chat--spacing: 1rem;
  --chat--border-radius: 0.8rem;
  --chat--window--z-index: 50;            /* below the lightbox (60) and toast */
  --chat--window--width: min(380px, calc(100vw - 32px));
  --chat--window--height: min(560px, calc(100dvh - 120px));
  --chat--window--border: 1px solid var(--edge);
  --chat--window--border-radius: 1.25rem;

  --chat--color--primary: var(--accent);
  --chat--color--primary-shade-50: var(--accent-hi);
  --chat--color--primary--shade-100: var(--accent-hi);
  --chat--color--secondary: var(--accent);
  --chat--color-secondary-shade-50: var(--accent-hi);
  --chat--color-white: var(--bg2);        /* n8n uses "white" as surface color */
  --chat--color-light: var(--bg2);
  --chat--color-light-shade-50: #14172C;
  --chat--color-light-shade-100: #1C2038;
  --chat--color-medium: var(--muted);
  --chat--color-dark: var(--bg);
  --chat--color-disabled: var(--dim);
  --chat--color-typing: var(--muted);

  --chat--header--background: #0B0C1E;
  --chat--header--color: var(--ink);
  --chat--header--padding: 1.1rem 1.25rem;
  --chat--header--border-bottom: 1px solid var(--edge);
  --chat--heading--font-size: 1.15rem;
  --chat--subtitle--font-size: 0.85rem;
  --chat--subtitle--line-height: 1.5;
  --chat--close--button--color-hover: var(--accent-soft);

  --chat--body--background: var(--bg2);
  --chat--messages-list--padding: 1.1rem;
  --chat--message--font-size: 0.95rem;
  --chat--message-line-height: 1.6;
  --chat--message--padding: 0.7rem 0.95rem;
  --chat--message--border-radius: 1rem;
  --chat--message--bot--background: var(--glass2);
  --chat--message--bot--color: var(--ink);
  --chat--message--bot--border: 1px solid var(--edge);
  --chat--message--user--background: var(--accent);
  --chat--message--user--color: #fff;
  --chat--message--user--border: none;
  --chat--message--pre--background: rgba(0,0,0,.35);

  --chat--footer--background: var(--bg2);
  --chat--footer--color: var(--muted);
  --chat--footer--border-top: 1px solid var(--edge);
  --chat--input--background: var(--bg2);
  --chat--input--text-color: var(--ink);
  --chat--input--border: 0;
  --chat--input--border-active: 0;
  --chat--input--font-size: 0.95rem;
  --chat--input--send--button--background: transparent;
  --chat--input--send--button--color: var(--accent);
  --chat--input--send--button--background-hover: transparent;
  --chat--input--send--button--color-hover: var(--accent-hi);

  --chat--toggle--size: 56px;
  --chat--toggle--background: var(--accent);
  --chat--toggle--hover--background: var(--accent-hi);
  --chat--toggle--active--background: var(--accent-hi);
  --chat--toggle--color: #fff;
}

#n8n-chat .chat-window-wrapper {
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
}
#n8n-chat .chat-window {
  background: var(--bg2);
  box-shadow: 0 30px 80px -24px rgba(0,0,0,.85), 0 0 0 1px rgba(255,255,255,.03);
}
/* Header: compact title + subtitle; reset the site's global h1/p sizes that leak in */
#n8n-chat .chat-header { font-family: var(--body); gap: 0.2rem; padding: 0.9rem 0.75rem 0.9rem 1.25rem; height: auto; min-height: 0; }
#n8n-chat .chat-heading { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
#n8n-chat .chat-header h1 { margin: 0; font: 700 var(--chat--heading--font-size)/1.3 var(--display); letter-spacing: -0.01em; }
#n8n-chat .chat-header p { margin: 0; color: var(--muted); font-size: var(--chat--subtitle--font-size); line-height: 1.4; }
#n8n-chat .chat-close-button { display: none; }   /* use our own X */
#n8n-chat .ud-chat-close {
  flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0;
  border: 0; border-radius: 0.6rem; background: transparent; color: var(--muted); cursor: pointer;
  transition: background .2s, color .2s;
}
#n8n-chat .ud-chat-close svg { width: 14px; height: 14px; }
#n8n-chat .ud-chat-close:hover { background: var(--glass2); color: var(--ink); }
#n8n-chat .ud-chat-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#n8n-chat .chat-window-toggle {
  box-shadow: 0 10px 30px -8px rgba(240,56,75,.7);
  transition: transform .2s, box-shadow .3s, background .2s;
}
#n8n-chat .chat-window-toggle:hover { transform: translateY(-2px); box-shadow: 0 14px 36px -8px rgba(240,56,75,.85); }
#n8n-chat .chat-window-toggle:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 3px; }
/* Input bar: text and send button centered vertically; left edge lines up with the message bubbles */
#n8n-chat .chat-inputs { background: var(--bg2); align-items: center; padding: 0.5rem 0.4rem 0.5rem 0; }
#n8n-chat .chat-inputs-controls { align-self: center; height: auto; }
#n8n-chat .chat-input-send-button { margin: 0; height: 2.5rem; width: 2.5rem; padding: 0; justify-content: center; border-radius: 0.6rem; }
#n8n-chat .chat-input-send-button:hover:not(:disabled) { background: var(--glass2); }
#n8n-chat .chat-input-send-button svg { width: 20px; height: 20px; }
/* One text line (22px) + 9px top/bottom = exactly 40px, so the text sits in the middle of the box (n8n default box is 50px, which pushed the text up) */
#n8n-chat { --chat--textarea--height: 40px; }
#n8n-chat .chat-input textarea { margin: 0; height: 40px; min-height: 40px; padding: 9px 0.5rem 9px var(--chat--messages-list--padding); line-height: 22px; color: var(--ink); background: transparent; caret-color: var(--accent); }
#n8n-chat .chat-input-send-button:not(:disabled) { color: var(--accent); }
#n8n-chat .chat-input textarea::placeholder { color: var(--dim); }
#n8n-chat .chat-message-markdown a { color: var(--accent-soft); }
#n8n-chat .chat-powered-by { display: none; }
:lang(ko) #n8n-chat .chat-message { word-break: keep-all; }
/* Phones: 16px input stops iOS from zooming in on focus */
@media (max-width: 600px) {
  #n8n-chat .chat-input textarea { font-size: 16px; }
}
