/* =============================================
   WCAG Chat – Frontend stílusok
   ============================================= */

/* Screen-reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link */
.wcag-chat__skip {
  position: absolute;
  left: -9999px;
  top: auto;
  z-index: 100;
  padding: 0.5em 1em;
  background: #005a9c;
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  border-radius: 0 0 4px 0;
}

.wcag-chat__skip:focus {
  left: 0;
  top: 0;
}

/* Container */
.wcag-chat {
  position: relative;
  max-width: 800px;
  margin: 1.5em auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  border: 2px solid #333;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.wcag-chat__title {
  margin: 0;
  padding: 0.75em 1em;
  background: #005a9c;
  color: #fff;
  font-size: 1.25em;
}

/* Intro */
.wcag-chat__intro {
  margin: 0;
  padding: 0.75em 1em;
  font-size: 0.95em;
  line-height: 1.5;
  color: #333;
  background: #f0f4f8;
  border-bottom: 1px solid #ddd;
}

/* Chat log — halványszürke alap az üzenetbuborékok kontrasztjához */
.wcag-chat__log {
  height: 450px;
  overflow-y: auto;
  padding: 1em;
  background: #f8f9fa;
}

/* Üzenetek — modernebb, lekerekített buborékok az oldal márkás színeivel */
.wcag-chat__message {
  margin-bottom: 1em;
  padding: 0.85em 1.1em;
  border-radius: 12px;
  border: 1px solid transparent;
}

.wcag-chat__message--user {
  /* indigo-50/100, illeszkedik a téma #5b5de9 márkás indigo-jához */
  background: #eef2ff;
  border-color: #c7d2fe;
  margin-left: 2em;
}

.wcag-chat__message--assistant {
  background: #fff;
  border-color: #e2e8f0;
  margin-right: 2em;
}

.wcag-chat__message-heading {
  font-size: 0.85em;
  font-weight: 700;
  margin: 0 0 0.4em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wcag-chat__message--user .wcag-chat__message-heading {
  /* #3730a3 (indigo-800): ~8.6:1 kontraszt fehéren — WCAG AAA */
  color: #3730a3;
}

.wcag-chat__message--assistant .wcag-chat__message-heading {
  /* #005a9c (az oldal/plugin márkás kékje): ~7.2:1 kontraszt fehéren — WCAG AAA */
  color: #005a9c;
}

.wcag-chat__message-body {
  font-size: 0.95em;
  line-height: 1.6;
  overflow-wrap: break-word;
}

.wcag-chat__loader {
  color: #64748b;
  font-style: italic;
  margin: 0;
  animation: wcag-chat-pulse 1.5s ease-in-out infinite;
}

/* Tool-futás progress badge — akkor látszik, ha a body-ban már van szöveg
   (loader eltűnt), de a háttérben tool fut és nem érkezik új chunk. Feltűnő
   blokk, animációval, hogy a felhasználó NE higgye lefagyásnak. */
.wcag-chat__tool-progress {
  margin: 12px 0 4px;
  padding: 10px 14px;
  background: #fff7e0;
  border-left: 4px solid #d97706;
  border-radius: 4px;
  color: #78350f;
  font-weight: 600;
  animation: wcag-chat-pulse 1.5s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .wcag-chat__loader,
  .wcag-chat__tool-progress { animation: none; }
}

@keyframes wcag-chat-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.wcag-chat__message-body h3,
.wcag-chat__message-body h4,
.wcag-chat__message-body h5 {
  margin: 0.8em 0 0.3em;
}

.wcag-chat__message-body h3 { font-size: 1.1em; }
.wcag-chat__message-body h4 { font-size: 1em; }
.wcag-chat__message-body h5 { font-size: 0.95em; }

.wcag-chat__message-body ul,
.wcag-chat__message-body ol {
  padding-left: 1.4em;
  margin: 0.4em 0;
}

.wcag-chat__message-body pre {
  background: #263238;
  color: #eeffff;
  padding: 0.75em 1em;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.9em;
}

.wcag-chat__message-body code {
  background: #e8e8e8;
  padding: 0.15em 0.35em;
  border-radius: 3px;
  font-size: 0.9em;
}

.wcag-chat__message-body pre code {
  background: none;
  padding: 0;
}

.wcag-chat__message-body a {
  color: #005a9c;
  text-decoration: underline;
}

.wcag-chat__message-body a:focus {
  outline: 2px solid #005a9c;
  outline-offset: 2px;
}

.wcag-chat__message-body p {
  margin: 0.4em 0;
}

/* Toolbar (értékelés + másolás) — minden assistant válasz alatt */
.wcag-chat__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5em;
  margin: 0.75em 0 0;
  padding-top: 0.6em;
  border-top: 1px dashed #cdd5df;
  font-size: 0.85em;
}

.wcag-chat__toolbar-group {
  display: inline-flex;
  gap: 0.25em;
}

.wcag-chat__rate,
.wcag-chat__copy {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.35em 0.75em;
  font-size: inherit;
  line-height: 1.2;
  font-family: inherit;
  background: #fff;
  color: #1f2937;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  cursor: pointer;
}

.wcag-chat__rate:hover,
.wcag-chat__copy:hover {
  background: #f1f5f9;
  border-color: #475569;
}

.wcag-chat__rate:focus-visible,
.wcag-chat__copy:focus-visible {
  outline: 3px solid #005a9c;
  outline-offset: 2px;
}

.wcag-chat__rate--good[aria-pressed="true"] {
  background: #dcfce7;
  border-color: #166534;
  color: #14532d;
  font-weight: 600;
}

.wcag-chat__rate--bad[aria-pressed="true"] {
  background: #fee2e2;
  border-color: #991b1b;
  color: #7f1d1d;
  font-weight: 600;
}

.wcag-chat__toolbar-feedback {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.85em;
  color: #166534;
}

@media (forced-colors: active) {
  .wcag-chat__rate,
  .wcag-chat__copy {
    border: 1px solid ButtonText;
  }
  .wcag-chat__rate[aria-pressed="true"] {
    border: 2px solid Highlight;
  }
}

/* Form */
.wcag-chat__form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  padding: 0.85em 1em;
  /* Modernebb: vékonyabb, halványszürke elválasztó */
  border-top: 1px solid #e5e7eb;
  background: #fff;
  align-items: flex-end;
}

.wcag-chat__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.6em 0.75em;
  font-size: 1em;
  /* Dupla vastag (4px) kék keret */
  border: 4px solid #005a9c;
  border-radius: 4px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.4;
}

.wcag-chat__input:focus {
  outline: 3px solid #005a9c;
  outline-offset: 1px;
  border-color: #005a9c;
}

.wcag-chat__hint {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.8em;
  color: #555;
}

.wcag-chat__send {
  padding: 0.6em 1.5em;
  font-size: 1em;
  font-weight: 600;
  /* Aktív állapot: lila (a téma márkás indigo színe) */
  background: #5b5de9;
  color: #fff;
  border: 2px solid #4338ca;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  /* Az ablakban középre — a flex sorban (a hint 100%-os flex-basis miatt
     külön sorban van a gomb), margin: auto középre rakja a flex item-et */
  margin: 0 auto;
}

.wcag-chat__send:hover,
.wcag-chat__send:focus {
  background: #4338ca;
  outline: 3px solid #ffbf47;
  outline-offset: 1px;
}

.wcag-chat__send[aria-disabled="true"] {
  /* Inaktív (küldés folyamatban) — az eredeti kék marad */
  background: #005a9c;
  border-color: #004080;
  opacity: 0.6;
  cursor: not-allowed;
}

/* Status */
.wcag-chat__status {
  padding: 0 1em 0.5em;
  font-size: 0.85em;
  color: #555;
  min-height: 1.2em;
}

/* Focus visible globális */
.wcag-chat *:focus-visible {
  outline: 3px solid #005a9c;
  outline-offset: 2px;
}

/* Magas kontraszt mód */
@media (forced-colors: active) {
  .wcag-chat__message {
    border: 1px solid ButtonText;
  }

  .wcag-chat__send {
    border: 2px solid ButtonText;
  }
}

/* Round-limit kijelző (mind inline-, mind modal-módban) */
.wcag-chat__rounds {
  margin: 0;
  padding: 0.5em 1em;
  font-size: 0.85em;
  color: #1f2937;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.wcag-chat__rounds--warn {
  background: #fff7e0;
  color: #78350f;
  font-weight: 600;
}

.wcag-chat__rounds--reached {
  background: #fee2e2;
  color: #7f1d1d;
  font-weight: 600;
}

/* =============================================
   Floating launcher gomb (minden oldal alsó-jobb sarka)
   ============================================= */

.wcag-chat-launcher {
  position: fixed;
  right: clamp(12px, 3vw, 24px);
  bottom: clamp(12px, 3vw, 24px);
  z-index: 99990;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.75em 1.1em;
  font: 600 1rem/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  background: #005a9c;
  border: 2px solid #003e6b;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.wcag-chat-launcher:hover {
  background: #004273;
  border-color: #00203e;
}

.wcag-chat-launcher:focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 3px;
}

.wcag-chat-launcher__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}

/* Desktop: hosszú felirat látszik, rövid rejtett.
   Mobil (max-width: 520px): rövid felirat látszik, hosszú rejtett.
   Mindkettő aria-hidden="true" — a teljes accessible name a button aria-label-jében. */
.wcag-chat-launcher__label--short {
  display: none;
}

@media (max-width: 520px) {
  .wcag-chat-launcher__label--full {
    display: none;
  }
  .wcag-chat-launcher__label--short {
    display: inline;
  }
  .wcag-chat-launcher {
    padding: 0.6em 0.9em;
    font-size: 0.95rem;
  }
}

@media (forced-colors: active) {
  .wcag-chat-launcher {
    border: 2px solid ButtonText;
  }
}

/* =============================================
   Modal dialog – natív <dialog> + showModal()
   A backdrop maga a böngészőből jön (::backdrop), a fókusz-trap-et és a
   háttér-inertet a böngésző kezeli; mi a vizuális stílusért és a consent
   nézetért felelünk.
   ============================================= */

.wcag-chat-dialog {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  /* Köztes szélesség: nagyobb képernyőn 900px-ig nyílik, kisebb képernyőn
     a 96vw arányosan zsugorítja. Mobilon a 520px-es media query 100vw-re
     veszi át. */
  max-width: min(900px, 96vw);
  width: 100%;
  /* Magasság: szinte az oldal aljáig (95vh) — kis margó marad esztétikailag,
     a chat panel a flex layout-ának köszönhetően a log scrollolható, a form
     (input + küldés) láthatóan az alján marad. */
  max-height: 95vh;
  overflow: visible;
}

.wcag-chat-dialog[open] {
  position: fixed;
  inset: 0;
  margin: auto;
}

.wcag-chat-dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
}

.wcag-chat-dialog__panel {
  display: flex;
  flex-direction: column;
  max-height: 95vh;
  background: #fff;
  /* Modernebb megjelenés: vékony márkás-indigo keret + nagyobb radius +
     lágy, kicsit lila árnyék */
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 20px 60px rgba(91, 93, 233, 0.18),
    0 4px 12px rgba(15, 23, 42, 0.10);
}

.wcag-chat-dialog__header {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.6em 0.75em 0.6em 1em;
  background: #005a9c;
  color: #fff;
}

.wcag-chat-dialog__title {
  flex: 1 1 auto;
  margin: 0;
  font-size: 1.15em;
  line-height: 1.3;
  font-weight: 700;
  color: #fff;
}

/* tabindex="-1" miatt programozottan kap fókuszt nyitáskor, de Tab-bal
   nem érhető el — vizuális gyűrűt itt nem kell mutatni. */
.wcag-chat-dialog__title:focus {
  outline: none;
}

.wcag-chat-dialog__close {
  flex: 0 0 auto;
  width: 2.25em;
  height: 2.25em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5em;
  line-height: 1;
  color: #1f2937;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.wcag-chat-dialog__close:hover {
  background: rgba(0, 0, 0, 0.08);
}

.wcag-chat-dialog__close:focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 2px;
  border-color: #1f2937;
}

/* Consent nézet */
.wcag-chat-dialog__consent {
  padding: 1.25em 1.25em 1.5em;
  overflow-y: auto;
  font-size: 1rem;
  line-height: 1.55;
  color: #1f2937;
}

.wcag-chat-dialog__consent-title {
  margin: 0 0 0.5em;
  font-size: 1.1em;
}

.wcag-chat-dialog__consent p {
  margin: 0 0 0.75em;
}

.wcag-chat-dialog__consent-sub {
  font-size: 0.95em;
  color: #475569;
}

.wcag-chat-dialog__consent-list {
  margin: 0 0 1em;
  padding-left: 1.25em;
}

.wcag-chat-dialog__consent-list li {
  margin-bottom: 0.5em;
}

.wcag-chat-dialog__consent-list li:last-child {
  margin-bottom: 0;
}

.wcag-chat-dialog__consent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
  margin-top: 1em;
}

.wcag-chat-dialog__btn {
  padding: 0.6em 1.2em;
  font: 600 1rem/1.2 inherit;
  border-radius: 6px;
  cursor: pointer;
}

.wcag-chat-dialog__btn--primary {
  color: #fff;
  background: #005a9c;
  border: 2px solid #003e6b;
}

.wcag-chat-dialog__btn--primary:hover {
  background: #004273;
}

.wcag-chat-dialog__btn--secondary {
  color: #1f2937;
  background: #fff;
  border: 2px solid #475569;
}

.wcag-chat-dialog__btn--secondary:hover {
  background: #f1f5f9;
}

.wcag-chat-dialog__btn:focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 2px;
}

/* Chat-nézet a dialogon belül — a wcag-chat__* osztályok újrahasznosulnak.
   A log scrollable, minden más fix; 92vh-be elférjen. */
.wcag-chat-dialog__conversation {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.wcag-chat-dialog__conversation .wcag-chat__intro {
  border-bottom: 1px solid #e2e8f0;
}

.wcag-chat-dialog__conversation .wcag-chat__log {
  flex: 1 1 auto;
  height: auto;
  min-height: 180px;
  /* Nincs explicit max-height: a flex grow tölti ki a rendelkezésre álló
     teret a panelben (95vh – header – intro – form – status). Saját scrollje
     van, így a form (input + küldés) mindig látható az alján. */
}

@media (max-width: 520px) {
  .wcag-chat-dialog {
    max-width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
  }
  .wcag-chat-dialog__panel {
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    height: 100dvh;
  }
  .wcag-chat-dialog__conversation .wcag-chat__log {
    max-height: none;
  }
}

@media (forced-colors: active) {
  .wcag-chat-dialog__panel {
    border: 2px solid ButtonText;
  }
  .wcag-chat-dialog__btn--primary,
  .wcag-chat-dialog__btn--secondary {
    border: 2px solid ButtonText;
  }
}

/* Body scroll-lock, amíg a dialog nyitva van. */
body.wcag-chat-dialog-open {
  overflow: hidden;
}
