/*
 * Support widget — floating member-facing UI on every logged-in
 * non-admin page. Scoped under .hfm-spt so it can't leak into the
 * surrounding page styles.
 *
 * Palette anchors brotherhood BRAND.md tokens directly so it stays
 * pixel-aligned with the rest of the member site: bronze for primary,
 * cream for dark sections, accent cyan only for the unread dot.
 */

.hfm-spt,
.hfm-spt * { box-sizing: border-box; }

/* ───────────────────────────────────────────────────────────────
   Collapsed pill — bottom-right floating button
   ─────────────────────────────────────────────────────────────── */
.hfm-spt-launcher {
  position: fixed;
  /* --hfm-bottom-occupied is set by other bottom-fixed UI (audio player,
     cookie banner, etc.) so this floating button lifts above them. */
  bottom: calc(24px + var(--hfm-bottom-occupied, 0px));
  right: 24px;
  transition: bottom .22s cubic-bezier(.4, 0, .2, 1), transform .18s cubic-bezier(.4, 0, .2, 1), box-shadow .18s ease;
  width: 60px;
  height: 60px;
  /* Chat-bubble silhouette: round circle with the bottom-right corner pulled to
     a point (a speech-bubble tail toward the screen corner it sits in), so the
     shape reads as a chat widget, not just a round button. */
  border-radius: 50% 50% 7px 50%;
  background: linear-gradient(135deg, #1fb0f0 0%, #019ae0 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(42, 29, 18, 0.32), 0 2px 6px rgba(42, 29, 18, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #F9F2E9;
  z-index: 9990;
  -webkit-tap-highlight-color: transparent;
}
.hfm-spt-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(42, 29, 18, 0.40), 0 4px 10px rgba(42, 29, 18, 0.22);
}
.hfm-spt-launcher:active { transform: translateY(0); }
.hfm-spt-launcher:focus-visible { outline: 3px solid var(--bronze, #a87c50); outline-offset: 3px; }
.hfm-spt-launcher__icon { width: 26px; height: 26px; }
.hfm-spt-launcher__icon--close { display: none; }
.hfm-spt[data-open="1"] .hfm-spt-launcher__icon--bubble { display: none; }
.hfm-spt[data-open="1"] .hfm-spt-launcher__icon--close { display: block; }

.hfm-spt-launcher__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--accent, #019ae0);
  color: #fff;
  font: 700 11px/18px 'Poppins', system-ui, sans-serif;
  text-align: center;
  padding: 0 5px;
  border: 2px solid #fff;
  display: none;
}
.hfm-spt[data-unread="1"] .hfm-spt-launcher__badge { display: block; }

/* ───────────────────────────────────────────────────────────────
   Panel — anchored bottom-right
   ─────────────────────────────────────────────────────────────── */
.hfm-spt-panel {
  position: fixed;
  right: 24px;
  bottom: calc(100px + var(--hfm-bottom-occupied, 0px));
  width: 380px;
  /* Height must subtract --hfm-bottom-occupied too — otherwise when the
     audio player is active and shifts the panel's bottom edge up, the
     top can clip above the viewport. */
  height: min(620px, calc(100vh - 130px - var(--hfm-bottom-occupied, 0px)));
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 48px rgba(42, 29, 18, 0.28), 0 6px 16px rgba(42, 29, 18, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9989;
  font-family: 'Poppins', system-ui, sans-serif;
  color: var(--text, #000);
  transform: translateY(20px) scale(.96);
  opacity: 0;
  pointer-events: none;
  transition: transform .22s cubic-bezier(.4, 0, .2, 1), opacity .18s ease;
}
.hfm-spt[data-open="1"] .hfm-spt-panel {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

/* Off entirely on a phone. A floating bubble parked over the bottom-right
   corner is a lot of furniture on a small screen — it sat on top of content and
   competed with the app's own controls. Support moved into the mobile menu
   instead (shared/header.php's drawer, and the admin drawer's foot), which is
   where someone looks for it anyway. The panel rules below still apply on a
   small tablet, above this breakpoint. */
@media (max-width: 768px) {
  .hfm-spt { display: none !important; }
}

/* Mobile: full-screen takeover */
@media (max-width: 640px) {
  .hfm-spt-panel {
    right: 0; bottom: 0;
    left: 0; top: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  .hfm-spt-launcher { bottom: calc(16px + var(--hfm-bottom-occupied, 0px)); right: 16px; }
}

/* Header bar */
.hfm-spt-head {
  background: linear-gradient(rgba(0,0,0,.20), rgba(0,0,0,.32)), #2a1d12 url('/assets/images/spt-header-leather.webp') center/cover no-repeat;
  color: #F9F2E9;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.hfm-spt-head__title {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
  letter-spacing: -0.005em;
}
.hfm-spt-head__sub {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 2px;
  font-weight: 400;
}
.hfm-spt-head__back {
  background: rgba(249, 242, 233, 0.12);
  border: none;
  color: #F9F2E9;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.hfm-spt-head__back:hover { background: rgba(249, 242, 233, 0.22); }
.hfm-spt-head__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(249, 242, 233, 0.35);
  color: #F9F2E9;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
  transition: background .14s;
}
.hfm-spt-head__close:hover { background: rgba(255, 255, 255, 0.24); }

/* Tabs (hub view) */
.hfm-spt-tabs {
  display: flex;
  border-bottom: 1px solid var(--line, #e6e2db);
  flex-shrink: 0;
}
.hfm-spt-tab {
  flex: 1;
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted, #555);
  cursor: pointer;
  text-align: center;
  transition: .14s;
}
.hfm-spt-tab:hover { color: var(--bronze-dk, #6b4f3a); }
.hfm-spt-tab.is-active {
  color: var(--bronze-dk, #6b4f3a);
  border-bottom-color: var(--bronze, #a87c50);
}
.hfm-spt-tab__count {
  display: inline-block;
  background: var(--line, #e6e2db);
  color: var(--muted, #555);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 9px;
  margin-left: 4px;
  vertical-align: 1px;
}
.hfm-spt-tab.is-active .hfm-spt-tab__count {
  background: var(--bronze, #a87c50);
  color: #fff;
}

/* Body */
.hfm-spt-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.hfm-spt-pane { display: none; flex: 1; overflow-y: auto; flex-direction: column; }
.hfm-spt-pane.is-active { display: flex; }

/* ───────────────────────────────────────────────────────────────
   New-ticket form
   ─────────────────────────────────────────────────────────────── */
.hfm-spt-form { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.hfm-spt-form label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--bronze-dk, #6b4f3a);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.hfm-spt-form input[type="text"],
.hfm-spt-form select,
.hfm-spt-form textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--text, #000);
  background: #fff;
  border: 1px solid var(--line, #e6e2db);
  border-radius: 8px;
  padding: 10px 12px;
  transition: border-color .14s;
}
.hfm-spt-form input:focus,
.hfm-spt-form select:focus,
.hfm-spt-form textarea:focus {
  outline: none;
  border-color: var(--bronze, #a87c50);
}
.hfm-spt-form textarea {
  resize: vertical;
  min-height: 130px;
  line-height: 1.5;
}
/* New-ticket "choose files" — bronze outline button + filename + hint */
.hfm-spt-form__file { display: flex; align-items: center; gap: 16px; cursor: pointer; padding: 2px 0; }
.hfm-spt-form__file-btn {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border-radius: 8px;
  background: #fff; color: var(--bronze-dk, #6b4f3a);
  border: 1.5px solid var(--bronze, #a87c50);
  font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  transition: background .14s, color .14s;
}
.hfm-spt-form__file:hover .hfm-spt-form__file-btn { background: var(--bronze, #a87c50); color: #fff; }
.hfm-spt-form__file-name { font-size: 12px; color: var(--muted, #555); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hfm-spt-form__file-hint { font-size: 11px; color: var(--muted, #555); margin-top: -4px; opacity: .8; }
/* Paperclip glyph sits to the RIGHT of the attach button label */
.hfm-spt-form__file-btn svg, .hfm-spt-composer__file-btn svg { width: 14px; height: 14px; flex: 0 0 auto; }
.hfm-spt-form__file input, .hfm-spt-composer__file input { display: none; }
.hfm-spt-form__submit {
  display: block;
  width: 100%;
  padding: 13px 18px;
  background: #019ae0;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .14s;
}
.hfm-spt-form__submit:hover { background: #000; }   /* "sand" Send button → blue (per request) */
.hfm-spt-form__submit:disabled { opacity: 0.5; cursor: wait; }
.hfm-spt-form__err {
  font-size: 12px;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 8px 10px;
  border-radius: 6px;
  display: none;
}
.hfm-spt-form__err.is-on { display: block; }

/* ───────────────────────────────────────────────────────────────
   Tickets list (My tickets)
   ─────────────────────────────────────────────────────────────── */
.hfm-spt-list { padding: 8px 0; }
.hfm-spt-item {
  padding: 14px 18px;
  cursor: pointer;
  border-bottom: 1px solid var(--line, #e6e2db);
  transition: background .12s;
}
.hfm-spt-item:hover { background: #faf7f2; }
.hfm-spt-item:last-child { border-bottom: none; }
.hfm-spt-item__row { display: flex; align-items: baseline; gap: 8px; }
.hfm-spt-item__subject {
  font-weight: 600;
  color: var(--text, #000);
  font-size: 14px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hfm-spt-item__time { font-size: 11px; color: var(--muted, #555); flex-shrink: 0; }
.hfm-spt-item__meta {
  font-size: 12px;
  color: var(--muted, #555);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.hfm-spt-item__pill {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 9px;
}
.hfm-spt-item__pill--new            { background: var(--bronze-dk, #6b4f3a); color: #fff; }
.hfm-spt-item__pill--open           { background: var(--bronze, #a87c50); color: #fff; }
.hfm-spt-item__pill--pending_admin  { background: #fef3c7; color: #92400e; }
.hfm-spt-item__pill--pending_member { background: #e0e7ff; color: #3730a3; }
.hfm-spt-item__pill--closed         { background: var(--line, #e6e2db); color: var(--muted, #555); }

/* ───────────────────────────────────────────────────────────────
   Conversation thread
   ─────────────────────────────────────────────────────────────── */
.hfm-spt-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hfm-spt-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
/* Chat bubbles: 50%-opacity translucent FILL (per request), with text darkened
   so it stays legible on the washed-out colour (whole-element opacity would
   fade the text below WCAG AA). */
.hfm-spt-msg--member {
  background: rgba(1, 154, 224, 0.25);
  color: #00314f;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.hfm-spt-msg--member a { color: #002740; }
.hfm-spt-msg--admin {
  background: rgba(74, 53, 37, 0.25);
  color: #241a10;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(58, 42, 28, 0.45);
}
.hfm-spt-msg--admin a { color: #241a10; text-decoration: underline; }
.hfm-spt-msg--admin .hfm-spt-msg__att a { background: rgba(0,0,0,0.10); }
/* Assistant (automated) reply. Sits on the same side as HFM Support because it
   IS us answering, but stays visually distinct from a bronze human reply — a
   member should be able to tell at a glance which he got. */
.hfm-spt-msg--ai {
  background: rgba(74, 53, 37, 0.10);
  color: #241a10;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px dashed rgba(58, 42, 28, 0.45);
}
.hfm-spt-msg--ai a { color: #241a10; text-decoration: underline; }
.hfm-spt-msg--ai .hfm-spt-msg__att a { background: rgba(0,0,0,0.10); }
.hfm-spt-msg--system {
  background: transparent;
  border: 1px dashed var(--line, #e6e2db);
  color: var(--muted, #555);
  font-style: italic;
  font-size: 12px;
  align-self: center;
  text-align: center;
  max-width: 100%;
}

/* "Did that solve it?" prompt, appended under a live assistant answer. */
.hfm-spt-resolve {
  align-self: stretch;
  margin-top: 2px;
  padding: 12px;
  border: 1px solid var(--line, #e6e2db);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.02);
  text-align: center;
}
.hfm-spt-resolve__q {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text, #1a1a1a);
  margin-bottom: 9px;
}
.hfm-spt-resolve__btns {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.hfm-spt-resolve__btn {
  flex: 0 1 auto;
  padding: 7px 13px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text, #1a1a1a);
  background: #fff;
  border: 1px solid var(--line, #e6e2db);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.hfm-spt-resolve__btn:hover:not(:disabled) { background: #000; color: #fff; border-color: #000; }
.hfm-spt-resolve__btn.is-yes {
  background: rgba(74, 53, 37, 0.9);
  border-color: rgba(74, 53, 37, 0.9);
  color: #fff;
}
.hfm-spt-resolve__btn.is-yes:hover:not(:disabled) { background: #000; border-color: #000; }
.hfm-spt-resolve__btn:disabled { opacity: .55; cursor: default; }
.hfm-spt-msg__time {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
  font-weight: 600;
}
.hfm-spt-msg__att { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.hfm-spt-msg__att a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.1);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  color: inherit;
  text-decoration: none;
}
.hfm-spt-msg--member .hfm-spt-msg__att a { background: rgba(0, 0, 0, 0.10); }

/* Composer */
.hfm-spt-composer {
  border-top: 1px solid var(--line, #e6e2db);
  padding: 12px 14px 14px;
  background: #faf7f2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.hfm-spt-composer__closed-note {
  font-size: 12px;
  color: var(--muted, #555);
  background: #fff;
  border: 1px solid var(--line, #e6e2db);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.hfm-spt-composer textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line, #e6e2db);
  border-radius: 8px;
  resize: none;
  min-height: 60px;
  background: #fff;
  color: var(--text, #000);
  line-height: 1.5;
}
.hfm-spt-composer textarea:focus {
  outline: none;
  border-color: var(--bronze, #a87c50);
}
.hfm-spt-composer__row {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Reply attach — compact bronze outline button + filename */
.hfm-spt-composer__file { flex: 1; display: flex; align-items: center; gap: 8px; cursor: pointer; min-width: 0; }
.hfm-spt-composer__file-btn {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px;
  background: #fff; color: var(--bronze-dk, #6b4f3a); border: 1.5px solid var(--bronze, #a87c50);
  font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  transition: background .14s, color .14s;
}
.hfm-spt-composer__file:hover .hfm-spt-composer__file-btn { background: var(--bronze, #a87c50); color: #fff; }
.hfm-spt-composer__file-name { font-size: 11px; color: var(--muted, #555); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
/* Accepted-extensions hint under the reply attach row */
.hfm-spt-composer__file-hint { font-size: 10px; color: var(--muted, #555); opacity: .8; margin-top: 2px; }
.hfm-spt-composer__send {
  background: #019ae0;   /* "sand" Send button → blue (per request) */
  color: #fff;
  border: none;
  padding: 9px 18px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 6px;
  cursor: pointer;
}
.hfm-spt-composer__send:hover { background: #000; }
.hfm-spt-composer__send:disabled { opacity: 0.5; cursor: wait; }

/* Submitted-confirmation state */
.hfm-spt-success {
  padding: 32px 24px;
  text-align: center;
}
.hfm-spt-success__icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #019ae0;
  color: #fff;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.hfm-spt-success__title {
  font-size: 17px;
  font-weight: 700;
  color: var(--bronze-dk, #6b4f3a);
  margin-bottom: 8px;
}
.hfm-spt-success__msg {
  font-size: 13px;
  color: var(--muted, #555);
  line-height: 1.5;
  margin-bottom: 20px;
}
.hfm-spt-success__cta {
  background: #019ae0;
  color: #fff;
  border: none;
  padding: 10px 20px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 6px;
  cursor: pointer;
}
.hfm-spt-success__cta:hover { background: #000; }

/* Upload progress bar */
.hfm-spt-progress {
  height: 6px; border-radius: 3px; background: var(--line, #e6e2db);
  overflow: hidden; margin-top: 10px;
}
.hfm-spt-progress[hidden] { display: none; }
.hfm-spt-progress__bar {
  height: 100%; width: 0%; border-radius: 3px;
  background: linear-gradient(90deg, #1fb0f0, #019ae0);
  transition: width .15s ease;
}

/* Empty / loading states */
.hfm-spt-empty {
  padding: 32px 24px;
  text-align: center;
  color: var(--muted, #555);
  font-size: 13px;
}
.hfm-spt-loading {
  padding: 32px 24px;
  text-align: center;
  color: var(--muted, #555);
  font-size: 12px;
}
.hfm-spt-loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid var(--line, #e6e2db);
  border-top-color: var(--bronze, #a87c50);
  border-radius: 50%;
  animation: hfm-spt-spin .7s linear infinite;
  vertical-align: -3px;
}
@keyframes hfm-spt-spin { to { transform: rotate(360deg); } }

/* Toast — bottom of panel */
.hfm-spt-toast {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1f2937;
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 10;
}
.hfm-spt-toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
.hfm-spt-toast.is-err { background: #b91c1c; }
