/* Bug reporter widget — modal + FAB.
 *
 * Architektura: BEM classes .bug-reporter__* (templ HTML ich oczekuje),
 * ALE styling oparty wprost o DS tokens (--ink, --line, --bg-elev,
 * --r-lg, --sh-3, --accent). Dziedziczy tokens.css → wygląda spójnie
 * z resztą DS bez własnych aliasów typu --surface czy --text.
 *
 * Whitelabel embed: kiedy host renderuje BugReporter z BrandAccent,
 * accent kolorystyczny ląduje przez `--bug-reporter-accent` ustawiane
 * inline przez Alpine (zob. bug-reporter.js); poza tym widget używa
 * regulárnych zmiennych DS, więc dark-mode + theme dziedziczy się
 * automatycznie z <html data-theme>.
 */

.bug-reporter {
  /* Tylko accent jest osobno — host może go nadpisać per-tenant.
   * Reszta tokenów dziedziczy się z tokens.css. */
  --bug-reporter-accent: var(--accent);
}

/* ── FAB ─────────────────────────────────────────────────────────── */
/* Pływający przycisk tuż za lewym sidebarem (88px) z 12px odstępem.
 * Hosty z własnym triggerem w brandbarze renderują BugReporter z
 * ShowFAB=false. Na mobile (<= 960px) sidebar zwija się do dolnej
 * belki (64px) — FAB ląduje wtedy w lewym dolnym powyżej tej belki,
 * żeby nie zasłaniać dolnych ikon nav. */
.bug-reporter__fab {
  position: fixed;
  left: 20px;
  bottom: 80px;
  z-index: 9998;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--accent);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--sh-2);
  transition: transform .12s ease, box-shadow .12s ease;
}
@media (max-width: 960px) {
  .bug-reporter__fab {
    left: 16px;
    bottom: 80px; /* powyżej bottom-nav (64px) z .app grid */
  }
}
.bug-reporter__fab:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-3);
}
.bug-reporter__fab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ── Overlay + modal ──────────────────────────────────────────────── */
/* Te same wartości co .modal-backdrop / .modal z modal.css — żeby
 * wizualnie nie odstawał od innych DS modali. */
.bug-reporter__overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(20, 19, 15, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.bug-reporter__modal {
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-3);
  overflow: hidden;
}

.bug-reporter__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.bug-reporter__header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.bug-reporter__close {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-3);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
}
.bug-reporter__close:hover {
  background: var(--bg-sunk);
  color: var(--ink);
}

.bug-reporter__body {
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 13.5px;
}

/* ── Prompt ──────────────────────────────────────────────────────── */
.bug-reporter__prompt-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.bug-reporter__hint {
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}
.bug-reporter__permissions {
  color: var(--ink-2);
  background: var(--bg-tinted);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 12.5px;
  margin: 0;
}

/* ── Recording ───────────────────────────────────────────────────── */
.bug-reporter__recording {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 0;
}
.bug-reporter__rec-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
}
.bug-reporter__rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d04e4e;
  box-shadow: 0 0 0 4px rgba(208, 78, 78, .15);
  animation: bug-reporter-pulse 1.2s ease-in-out infinite;
}
@keyframes bug-reporter-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .5; transform: scale(.85); }
}

/* ── Preview + form ──────────────────────────────────────────────── */
.bug-reporter__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bug-reporter__preview {
  width: 100%;
  max-height: 240px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--bg-sunk);
}
.bug-reporter__label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
}
.bug-reporter__input {
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.bug-reporter__input:hover {
  border-color: var(--line-3);
}
.bug-reporter__input:focus-visible {
  outline: none;
  border-color: var(--accent-deep);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
textarea.bug-reporter__input {
  resize: vertical;
  min-height: 96px;
  line-height: 1.5;
}

.bug-reporter__error {
  background: var(--bg-tinted-2);
  color: var(--ink);
  border: 1px solid var(--line-2);
  border-left: 3px solid #d04e4e;
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-size: 12.5px;
}

/* ── Actions row ─────────────────────────────────────────────────── */
.bug-reporter__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 14px;
}

/* Buttons — visual match z .btn / .btn-primary z components.css.
 * Trzymane jako osobne klasy żeby widget działał stand-alone w
 * embed whitelabel (gdzie components.css może być nieobecne), ale
 * styling 1:1. */
.bug-reporter__btn {
  font: inherit;
  font-weight: 500;
  font-size: 13px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--bg-elev);
  color: var(--ink);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.bug-reporter__btn:hover:not(:disabled) {
  background: var(--bg-sunk);
  border-color: var(--line-3);
}
.bug-reporter__btn:active:not(:disabled) {
  transform: translateY(1px);
}
.bug-reporter__btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.bug-reporter__btn--primary {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: var(--ink);
  font-weight: 600;
}
.bug-reporter__btn--primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 88%, white);
  border-color: var(--accent-deep);
}

/* ── Success ─────────────────────────────────────────────────────── */
.bug-reporter__success {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0;
}
.bug-reporter__success p {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
}
.bug-reporter__success-hint {
  color: var(--ink-3) !important;
  font-size: 12.5px;
}

/* === 3-button menu start screen ====================================== */
.bug-reporter__menu {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.bug-reporter__menu-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bug-reporter__menu-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border, #e0e0e6);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s;
}
.bug-reporter__menu-btn:hover {
  border-color: var(--accent, #F5C518);
  background: var(--bg-elevated, #fafbfc);
}
.bug-reporter__menu-btn strong {
  color: var(--ink, #1a1a1f);
  font-size: 14px;
}
.bug-reporter__menu-btn span {
  color: var(--ink-3, #6b6b78);
  font-size: 12.5px;
}

/* === My reports list ================================================== */
.bug-reporter__myreports {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bug-reporter__back {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--accent, #F5C518);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}
.bug-reporter__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bug-reporter__list-item {
  padding: 10px 12px;
  border: 1px solid var(--border, #e0e0e6);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s;
}
.bug-reporter__list-item:hover {
  border-color: var(--accent, #F5C518);
}
.bug-reporter__list-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.bug-reporter__list-status {
  font-size: 11px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: #eef0f6;
  color: var(--ink-3, #6b6b78);
}
.bug-reporter__list-status--open {
  background: #fff3cd;
  color: #8a6d00;
}
.bug-reporter__list-status--in_progress {
  background: #cfe2ff;
  color: #084298;
}
.bug-reporter__list-status--resolved,
.bug-reporter__list-status--closed {
  background: #d1e7dd;
  color: #0a3622;
}
.bug-reporter__list-meta {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-3, #6b6b78);
}

/* === Popover (chmurka, Intercom-style) ============================== */
.bug-reporter__popover {
  position: fixed;
  bottom: 144px; /* nad FAB (FAB ma bottom: 80 + height: 48 + gap: 16) */
  left: 20px;    /* po lewej, zgodnie z pozycja FAB */
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 200px);
  background: var(--bg-surface, #fff);
  border: 1px solid var(--line-2, #e0e0e6);
  border-radius: 14px;
  box-shadow: var(--sh-3, 0 12px 40px rgba(0, 0, 0, 0.18));
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
}
@media (max-width: 960px) {
  .bug-reporter__popover { left: 16px; }
}
.bug-reporter__popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--accent, #F5C518);
  color: var(--ink, #1a1a1f);
}
.bug-reporter__popover-header h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
}
.bug-reporter__popover-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.bug-reporter__icon-btn {
  background: rgba(0, 0, 0, 0.08);
  border: none;
  color: var(--ink, #1a1a1f);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  transition: background .15s;
}
.bug-reporter__icon-btn:hover {
  background: rgba(0, 0, 0, 0.16);
}
.bug-reporter__popover-body {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafbfc;
}
.bug-reporter__popover-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border, #e0e0e6);
  background: var(--bg-surface, #fff);
  display: flex;
  gap: 8px;
  align-items: center;
}

/* === Chat view ====================================================== */
.bug-reporter__chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100%;
}
.bug-reporter__chat-intro {
  background: var(--bg-elevated, #fff);
  border: 1px solid var(--border, #e0e0e6);
  border-radius: 10px;
  padding: 12px;
}
.bug-reporter__chat-intro p {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ink-2, #2a2a32);
  line-height: 1.4;
}
.bug-reporter__chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bug-reporter__msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  gap: 2px;
}
.bug-reporter__msg--out {
  align-self: flex-end;
  align-items: flex-end;
}
.bug-reporter__msg--in {
  align-self: flex-start;
  align-items: flex-start;
}
.bug-reporter__msg-bubble {
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.bug-reporter__msg--out .bug-reporter__msg-bubble {
  background: var(--accent, #F5C518);
  color: var(--ink, #1a1a1f);
  border-bottom-right-radius: 4px;
}
.bug-reporter__msg--in .bug-reporter__msg-bubble {
  background: #fff;
  color: var(--ink, #1a1a1f);
  border: 1px solid var(--border, #e0e0e6);
  border-bottom-left-radius: 4px;
}
.bug-reporter__msg-time {
  font-size: 10.5px;
  color: var(--ink-3, #6b6b78);
  display: flex;
  gap: 6px;
}
.bug-reporter__chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.bug-reporter__chat-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border, #e0e0e6);
  border-radius: 999px;
  font-size: 13.5px;
  outline: none;
  background: var(--bg-surface, #fff);
  color: var(--ink, #1a1a1f);
}
.bug-reporter__chat-input:focus {
  border-color: var(--accent, #F5C518);
}
.bug-reporter__chat-send {
  background: var(--accent, #F5C518);
  color: var(--ink, #1a1a1f);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, opacity .15s;
}
.bug-reporter__chat-send:hover { background: var(--accent-deep, #C99C0D); }
.bug-reporter__chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === Choose-new view ================================================ */
.bug-reporter__choose h3 {
  margin: 0 0 4px;
  font-size: 15px;
}
.bug-reporter__choose-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

/* === FAB active state (gdy popover otwarty) ========================= */
.bug-reporter__fab--active {
  transform: rotate(45deg);
}
.bug-reporter__quick-bug {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bug-reporter__quick-bug textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--line-2, #e0e0e6);
  border-radius: 10px;
  font-family: inherit;
  font-size: 13.5px;
  resize: vertical;
}
.bug-reporter__quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
