/* ============================================
   Feedback Widget — Origin Wines
   In-site review tool (text + voice + screenshots)
   ============================================ */

#fw-root,
#fw-root *,
.fw-popover,
.fw-popover *,
.fw-panel,
.fw-panel *,
.fw-modal,
.fw-modal *,
.fw-toast {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#fw-root {
  position: fixed;
  z-index: 2147483000;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

/* Toolbar buttons */
.fw-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 999px;
  border: none;
  background: #1a1a1a;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.fw-btn:hover {
  transform: translateY(-1px);
  background: #2a2a2a;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}
.fw-btn[data-active="true"] {
  background: var(--fw-brand, #c1272d);
}
.fw-btn .fw-badge {
  background: #fff;
  color: #1a1a1a;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1;
}
.fw-btn-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.fw-btn-small {
  padding: 9px 14px;
  font-size: 13px;
}

/* First-time gentle pulse on the main button */
@keyframes fw-pulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(0,0,0,.18), 0 0 0 0 rgba(193,39,45,.4); }
  50%      { box-shadow: 0 4px 14px rgba(0,0,0,.18), 0 0 0 14px rgba(193,39,45,0); }
}
.fw-btn[data-pulse="true"] {
  animation: fw-pulse 2.2s ease-out 2;
}

/* Comment mode body state */
body.fw-comment-mode * { cursor: crosshair !important; }
body.fw-comment-mode #fw-root,
body.fw-comment-mode #fw-root * { cursor: pointer !important; }

/* Hover highlight */
.fw-hover-highlight {
  outline: 2px dashed var(--fw-brand, #c1272d) !important;
  outline-offset: 2px !important;
  background-color: rgba(193, 39, 45, 0.06) !important;
}

/* Persistent outline on the element the popover is anchored to,
   so the reviewer can always see what they clicked. */
.fw-target-active {
  outline: 3px solid var(--fw-brand, #c1272d) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 6px rgba(193, 39, 45, 0.18) !important;
  position: relative;
  z-index: 1 !important;
}

/* Pins for existing comments */
.fw-pin {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--fw-brand, #c1272d);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.32);
  z-index: 2147482000;
  transform: translate(-50%, -50%);
  transition: transform 0.15s ease;
  border: 2px solid #fff;
}
.fw-pin:hover { transform: translate(-50%, -50%) scale(1.18); }
.fw-pin[data-status="resolved"] { background: #4a8c43; }
.fw-pin[data-status="in_progress"] { background: #d4a017; }

/* ===========================
   Comment popover
   =========================== */
.fw-popover {
  position: absolute;
  z-index: 2147483100;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.28);
  padding: 18px;
  width: 360px;
  border: 1px solid #e5e5e5;
}
.fw-popover-header {
  font-size: 12px;
  color: #777;
  margin-bottom: 6px;
  word-break: break-all;
}
.fw-popover-target {
  font-size: 11px;
  color: #888;
  background: #f7f7f7;
  padding: 7px 9px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-family: Menlo, Monaco, monospace;
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fw-popover textarea {
  width: 100%;
  min-height: 90px;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  resize: vertical;
  font-family: inherit;
}
.fw-popover textarea:focus,
.fw-popover input:focus {
  outline: none;
  border-color: var(--fw-brand, #c1272d);
}
.fw-popover input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
}

/* "Restored your draft" hint */
.fw-draft-hint {
  font-size: 12px;
  color: #4a8c43;
  background: #f0f7ef;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
  border-left: 3px solid #4a8c43;
  transition: opacity 0.6s ease;
}

/* Field labels (question prompts above each section) */
.fw-field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
  margin-bottom: 6px;
}

/* Compact "Reviewing as <name>" display (when a name is already set) */
.fw-name-current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  color: #333;
  background: #f7f7f7;
  border-radius: 8px;
  padding: 9px 12px;
}
.fw-name-current strong {
  color: #1a1a1a;
  font-weight: 600;
}
.fw-name-change {
  background: none;
  border: none;
  color: var(--fw-brand, #c1272d);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.fw-name-change:hover { opacity: 0.8; }

/* Name quick-pick chips */
.fw-name-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.fw-name-chip {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid #ddd;
  background: #fff;
  color: #444;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.12s ease;
}
.fw-name-chip:hover {
  border-color: var(--fw-brand, #c1272d);
  color: var(--fw-brand, #c1272d);
}
.fw-name-chip.is-active {
  background: var(--fw-brand, #c1272d);
  color: #fff;
  border-color: var(--fw-brand, #c1272d);
}

/* Tag chips */
.fw-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 4px;
}
.fw-tag-chip {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid #ddd;
  background: #fff;
  color: #555;
  cursor: pointer;
  transition: all 0.12s ease;
}
.fw-tag-chip:hover { border-color: #888; }
.fw-tag-chip[data-active="true"] {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}
/* Auto-suggested (lighter than user-picked) — pulses softly to draw attention */
.fw-tag-chip[data-suggested="true"] {
  background: linear-gradient(135deg, #f5efff, #ede0ff);
  color: #4a2d80;
  border: 1px solid #c7b3f0;
  position: relative;
}
.fw-tag-chip[data-suggested="true"]::after {
  content: "✨";
  font-size: 10px;
  margin-left: 4px;
}

/* Voice recorder block in popover */
.fw-voice {
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed #e0e0e0;
  border-radius: 10px;
  background: #fafafa;
}
.fw-voice-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #555;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.fw-voice-toggle:hover { color: var(--fw-brand, #c1272d); }

.fw-voice-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
.fw-voice-rec {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--fw-brand, #c1272d);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.12s ease;
}
.fw-voice-rec:hover { transform: scale(1.06); }
.fw-voice-rec[data-recording="true"] {
  background: #1a1a1a;
  animation: fw-rec-pulse 1.2s infinite;
}
@keyframes fw-rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(193, 39, 45, 0.5); }
  50%      { box-shadow: 0 0 0 10px rgba(193, 39, 45, 0); }
}
.fw-voice-icon { width: 18px; height: 18px; }

.fw-voice-meta {
  flex: 1;
  font-size: 13px;
  color: #555;
}
.fw-voice-timer {
  font-family: Menlo, Monaco, monospace;
  font-size: 14px;
  color: #1a1a1a;
  font-weight: 500;
}
.fw-voice-hint {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}
.fw-voice-playback {
  width: 100%;
  margin-top: 10px;
  height: 36px;
}
.fw-voice-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.fw-voice-actions button {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #fff;
  color: #555;
  cursor: pointer;
}
.fw-voice-actions button:hover { border-color: var(--fw-brand, #c1272d); color: var(--fw-brand, #c1272d); }

.fw-popover-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: flex-end;
}
.fw-popover-actions button {
  padding: 9px 16px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.fw-btn-primary {
  background: var(--fw-brand, #c1272d);
  color: #fff;
}
.fw-btn-primary:hover:not(:disabled) { background: var(--fw-brand-dark, #a01f24); }
.fw-btn-primary:disabled { background: #ccc; cursor: not-allowed; }
.fw-btn-secondary {
  background: #f0f0f0;
  color: #333;
}
.fw-btn-secondary:hover { background: #e5e5e5; }

/* ===========================
   Follow-up popover (AI clarifying question)
   =========================== */
.fw-followup {
  background: linear-gradient(135deg, #fefcff, #f9f5ff);
  border: 1px solid #d8c4f0;
  width: 340px;
}
.fw-followup-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  background: #4a2d80;
  color: #fff;
  margin-bottom: 10px;
}
.fw-followup-q {
  font-size: 15px;
  color: #1a1a1a;
  line-height: 1.45;
  font-weight: 500;
  margin-bottom: 12px;
}
.fw-followup textarea {
  min-height: 70px;
}

/* ===========================
   Side panel (comments list)
   =========================== */
.fw-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 440px;
  max-width: 100vw;
  height: 100vh;
  background: #fff;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
  z-index: 2147483200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}
.fw-panel[data-open="true"] { transform: translateX(0); }
.fw-panel-header {
  padding: 18px 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.fw-panel-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
}
.fw-panel-sub {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
}
.fw-panel-close {
  background: none;
  border: none;
  font-size: 26px;
  color: #777;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.fw-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px 20px;
}
.fw-panel-footer {
  padding: 14px 20px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 10px;
}
.fw-panel-footer button {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.fw-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #999;
  margin: 18px 0 8px;
}
.fw-group-title:first-child { margin-top: 4px; }

.fw-comment-card {
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fafafa;
}
.fw-comment-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.fw-comment-meta {
  font-size: 11px;
  color: #999;
}
.fw-comment-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 7px;
  border-radius: 4px;
  background: #1a1a1a;
  color: #fff;
  margin-right: 6px;
}
.fw-comment-selector {
  font-family: Menlo, Monaco, monospace;
  font-size: 11px;
  color: #666;
  background: #fff;
  padding: 4px 6px;
  border-radius: 4px;
  margin-bottom: 6px;
  word-break: break-all;
}
.fw-comment-quote {
  font-size: 12px;
  color: #666;
  font-style: italic;
  margin-bottom: 6px;
}
.fw-comment-text {
  font-size: 14px;
  color: #1a1a1a;
  line-height: 1.45;
  white-space: pre-wrap;
  margin-bottom: 8px;
}
.fw-comment-text-empty {
  font-size: 13px;
  color: #aaa;
  font-style: italic;
  margin-bottom: 8px;
}
.fw-comment-audio {
  width: 100%;
  height: 36px;
  margin-bottom: 8px;
}
.fw-comment-screenshot {
  width: 100%;
  border-radius: 6px;
  border: 1px solid #eee;
  display: block;
  cursor: zoom-in;
  margin-bottom: 8px;
}
.fw-comment-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.fw-comment-actions button {
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #ddd;
  background: #fff;
  font-size: 12px;
  color: #555;
  cursor: pointer;
}
.fw-comment-actions button:hover { border-color: var(--fw-brand, #c1272d); color: var(--fw-brand, #c1272d); }

.fw-empty {
  text-align: center;
  color: #999;
  padding: 40px 20px;
  font-size: 14px;
  line-height: 1.5;
}
.fw-empty strong { color: #1a1a1a; }

/* ===========================
   Welcome modal (first-run)
   =========================== */
.fw-modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  z-index: 2147483400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.fw-modal-bg[data-open="true"] {
  opacity: 1;
  pointer-events: auto;
}
.fw-modal {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
  transform: scale(0.94);
  transition: transform 0.25s ease;
}
.fw-modal-bg[data-open="true"] .fw-modal { transform: scale(1); }
.fw-modal-emoji {
  font-size: 44px;
  margin-bottom: 12px;
}
.fw-modal h2 {
  font-size: 22px;
  margin: 0 0 12px;
  color: #1a1a1a;
  font-weight: 600;
}
.fw-modal p {
  font-size: 14px;
  color: #555;
  margin: 0 0 8px;
  line-height: 1.55;
}
.fw-modal ul {
  text-align: left;
  font-size: 14px;
  color: #444;
  margin: 16px auto;
  padding: 0 0 0 22px;
  max-width: 380px;
  line-height: 1.7;
  list-style: disc outside !important;  /* host CSS may have reset list-style */
}
.fw-modal ul li {
  list-style: disc outside !important;
  display: list-item !important;
  margin-bottom: 4px;
}
.fw-modal ul li::marker { color: var(--fw-brand, #c1272d); }
.fw-modal-actions {
  margin-top: 22px;
  display: flex;
  gap: 10px;
  justify-content: center;
}
.fw-modal-actions button {
  padding: 11px 22px;
  border-radius: 999px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

/* Idle nudge — gentle hint after 90s of no commenting */
#fw-idle-nudge {
  position: fixed;
  bottom: 86px;
  right: 24px;
  background: #1a1a1a;
  color: #fff;
  padding: 14px 32px 14px 18px;
  border-radius: 12px;
  max-width: 280px;
  font-size: 13px;
  line-height: 1.5;
  z-index: 2147482900;
  box-shadow: 0 12px 32px rgba(0,0,0,0.28);
  animation: fw-nudge-in 0.35s ease-out;
  border: 1px solid rgba(255,255,255,0.08);
}
#fw-idle-nudge::after {
  content: "";
  position: absolute;
  bottom: -8px;
  right: 60px;
  width: 0; height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #1a1a1a;
}
.fw-idle-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  line-height: 1;
}
.fw-idle-close:hover { color: #fff; }
.fw-idle-out {
  animation: fw-nudge-out 0.25s ease-in forwards;
}
@keyframes fw-nudge-in {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes fw-nudge-out {
  from { transform: translateY(0);    opacity: 1; }
  to   { transform: translateY(10px); opacity: 0; }
}

/* Toast */
.fw-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 2147483300;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  max-width: 80vw;
}
.fw-toast[data-visible="true"] { opacity: 1; }

/* ===========================
   Mobile
   =========================== */
@media (max-width: 600px) {
  #fw-root { bottom: 14px; right: 14px; gap: 8px; }
  .fw-btn { padding: 10px 14px; font-size: 13px; }
  .fw-btn-small { padding: 8px 12px; font-size: 12px; }
  .fw-popover {
    position: fixed !important;
    left: 12px !important;
    right: 12px !important;
    top: auto !important;
    bottom: 12px !important;
    width: auto !important;
    max-height: 80vh;
    overflow-y: auto;
  }
  .fw-panel { width: 100vw; }
  .fw-modal { padding: 24px; }
}

@media print {
  #fw-root, .fw-panel, .fw-popover, .fw-pin, .fw-toast, .fw-modal-bg, #fw-session-bar { display: none !important; }
}

/* ============================================
   Voice Session bar (top of screen)
   ============================================ */
#fw-session-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: linear-gradient(135deg, #1a1a1a, #2a1414);
  color: #fff;
  padding: 12px 18px;
  z-index: 2147483400;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.fw-session-content {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1280px;
  margin: 0 auto;
}
.fw-session-rec-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff3838;
  flex-shrink: 0;
  animation: fw-pulse-dot 1.2s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(255, 56, 56, 0.6);
}
@keyframes fw-pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255, 56, 56, 0.6); }
  50%      { opacity: 0.55; box-shadow: 0 0 0 8px rgba(255, 56, 56, 0); }
}
.fw-session-timer {
  font-family: Menlo, Monaco, monospace;
  font-size: 14px;
  font-weight: 600;
  min-width: 52px;
  color: #fff;
}
.fw-session-caption {
  flex: 1;
  font-size: 14px;
  color: #d8d8d8;
  font-style: italic;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.fw-session-caption[data-placeholder="true"] { color: #888; }
.fw-session-end {
  background: var(--fw-brand, #c1272d);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s ease;
}
.fw-session-end:hover { background: var(--fw-brand-dark, #a01f24); }
.fw-session-processing {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #ddd;
  flex: 1;
  justify-content: center;
}
.fw-session-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #555;
  border-top-color: #fff;
  border-radius: 50%;
  animation: fw-spin 0.9s linear infinite;
}
@keyframes fw-spin { to { transform: rotate(360deg); } }

/* Push body content down while session bar visible */
body.fw-session-active {
  padding-top: 56px !important;
}

/* Cursor tracker — visible halo following the mouse during a session.
   Tells the reviewer "we're watching where you point". */
#fw-cursor-track {
  position: fixed;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  border: 2px solid var(--fw-brand, #c1272d);
  background: rgba(193, 39, 45, 0.12);
  border-radius: 50%;
  pointer-events: none;
  z-index: 2147483380;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 0 rgba(193, 39, 45, 0.5);
  animation: fw-cursor-pulse 1.6s ease-out infinite;
}
@keyframes fw-cursor-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(193, 39, 45, 0.45); }
  70%  { box-shadow: 0 0 0 16px rgba(193, 39, 45, 0); }
  100% { box-shadow: 0 0 0 0 rgba(193, 39, 45, 0); }
}

/* Voice-session chip in panel */
.fw-comment-card[data-session="true"] {
  background: linear-gradient(to right, #faf7ff, #fafafa);
  border-color: #e0d5f5;
}

@media (max-width: 600px) {
  #fw-session-bar { padding: 10px 12px; }
  .fw-session-content { gap: 10px; }
  .fw-session-caption { font-size: 13px; }
  .fw-session-end { padding: 8px 14px; font-size: 12px; }
  body.fw-session-active { padding-top: 64px !important; }
}
