/*
 * fab-feedback.css
 * Styles for the FAB feedback widget (Phase 2 Workstream B2).
 *
 * Relies on brand CSS custom properties already defined by the surface's
 * primary stylesheet (--primary, --accent, --bg, --text etc).
 * Loaded after dashmeshtoys/css/brand.css so tokens are available.
 *
 * z-index stack:
 *   9000 — FAB button
 *   9100 — PIN / capture sheets backdrop
 *   9200 — PIN / capture sheets
 *   9500+ — toast (reserved by dashboard; FAB toasts use 9600)
 */

/* ============================================================
   FAB BUTTON
   ============================================================ */

.fab-feedback {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary, #7A1F2B);
  border: 2px solid color-mix(in srgb, var(--accent, #C9A227) 40%, transparent);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;

  /* Hidden by default */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fab-feedback.fab--visible {
  opacity: 1;
  pointer-events: auto;
}

/* Position variant: bottom-left (customer site — B4) */
.fab-feedback.fab--bottom-left {
  right: auto;
  left: 20px;
}

/* Narrow screens */
@media (max-width: 359px) {
  .fab-feedback {
    bottom: 16px;
    right: 16px;
  }
  .fab-feedback.fab--bottom-left {
    right: auto;
    left: 16px;
  }
}

.fab-feedback__icon {
  width: 22px;
  height: 22px;
  stroke: var(--bg, #FBF7F0);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

/* Reduced motion: skip fade, use instant show/hide */
@media (prefers-reduced-motion: reduce) {
  .fab-feedback {
    transition: none;
  }
}

/* ============================================================
   SHEET BACKDROP
   ============================================================ */

.fab-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.fab-sheet-backdrop.fab-sheet-backdrop--visible {
  opacity: 1;
  pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
  .fab-sheet-backdrop {
    transition: none;
  }
}

/* ============================================================
   SHARED SHEET BASE
   ============================================================ */

.fab-sheet {
  position: fixed;
  inset: auto 0 0 0;
  max-width: 360px;
  margin: 0 auto;
  background: var(--bg, #FBF7F0);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
  z-index: 9200;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.fab-sheet.fab-sheet--open {
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .fab-sheet {
    transition: none;
  }
}

.fab-sheet__handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--accent, #C9A227);
  opacity: 0.5;
  margin: 12px auto 0;
}

/* ============================================================
   PIN SHEET
   ============================================================ */

.fab-pin-sheet {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.fab-pin-sheet__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 16px 4px;
}

.fab-pin-sheet__title {
  font-family: var(--font-heading, 'Playfair Display', serif);
  font-size: 13px;
  color: var(--text, #2A2522);
  opacity: 0.7;
}

.fab-pin-sheet__dots {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 12px 16px 4px;
}

.fab-pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--accent, #C9A227);
  background: transparent;
  transition: background 0.12s ease;
}

.fab-pin-dot.is-filled {
  background: var(--primary, #7A1F2B);
  border-color: var(--primary, #7A1F2B);
}

.fab-pin-sheet__caption {
  text-align: center;
  font-size: 13px;
  color: var(--text, #2A2522);
  opacity: 0.65;
  padding: 0 16px 8px;
  min-height: 20px;
}

/* Shake animation for wrong PIN */
@keyframes fab-shake {
  0%, 100% { transform: translateX(0); }
  12%  { transform: translateX(-4px); }
  25%  { transform: translateX(4px); }
  37%  { transform: translateX(-4px); }
  50%  { transform: translateX(4px); }
  62%  { transform: translateX(-4px); }
  75%  { transform: translateX(4px); }
  87%  { transform: translateX(-4px); }
}

.fab-pin-sheet__dots.is-shaking {
  animation: fab-shake 0.35s ease;
}

@media (prefers-reduced-motion: reduce) {
  .fab-pin-sheet__dots.is-shaking {
    animation: none;
  }
}

/* Numpad */
.fab-pin-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding: 4px 0 8px;
}

.fab-pin-key {
  height: 56px;
  font-size: 22px;
  font-family: var(--font-body, 'Inter', sans-serif);
  color: var(--primary, #7A1F2B);
  background: var(--bg, #FBF7F0);
  border: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent, #C9A227) 35%, transparent);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  min-width: 48px;
}

.fab-pin-key:active,
.fab-pin-key:focus-visible {
  background: var(--primary, #7A1F2B);
  color: var(--bg, #FBF7F0);
  outline: none;
}

.fab-pin-key:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.fab-pin-key--del {
  font-size: 18px;
}

.fab-pin-key--close {
  font-size: 18px;
}

/* ============================================================
   CAPTURE PANEL
   ============================================================ */

.fab-capture-sheet {
  max-height: 90vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.fab-capture-sheet__header {
  padding: 8px 16px 4px;
}

.fab-capture-sheet__title {
  font-family: var(--font-heading, 'Playfair Display', serif);
  font-size: 16px;
  color: var(--primary, #7A1F2B);
  font-weight: 700;
}

.fab-capture-sheet__subtitle {
  font-size: 11px;
  color: var(--text, #2A2522);
  opacity: 0.55;
  margin-top: 2px;
  word-break: break-all;
}

.fab-capture-sheet__body {
  padding: 8px 16px;
}

/* Dropdowns */
.fab-capture-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.fab-select {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--primary, #7A1F2B) 30%, transparent);
  border-radius: 6px;
  background: var(--bg, #FBF7F0);
  color: var(--text, #2A2522);
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 13px;
  appearance: none;
  cursor: pointer;
}

.fab-select:focus {
  outline: 2px solid var(--primary, #7A1F2B);
  outline-offset: 1px;
}

/* Textarea wrapper */
.fab-textarea-wrap {
  position: relative;
  margin-bottom: 6px;
}

.fab-textarea {
  width: 100%;
  min-height: 80px;
  max-height: 240px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--primary, #7A1F2B) 30%, transparent);
  border-radius: 6px;
  background: var(--bg, #FBF7F0);
  color: var(--text, #2A2522);
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 14px;
  resize: none;
  box-sizing: border-box;
  line-height: 1.5;
  overflow-y: auto;
}

.fab-textarea:focus {
  outline: 2px solid var(--primary, #7A1F2B);
  outline-offset: 1px;
}

.fab-char-counter {
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-size: 10px;
  color: var(--text, #2A2522);
  opacity: 0.5;
  pointer-events: none;
}

.fab-char-counter.is-warning {
  color: var(--accent, #C9A227);
  opacity: 1;
}

.fab-char-counter.is-over {
  color: #c0392b;
  opacity: 1;
}

.fab-textarea-hint {
  font-size: 11px;
  color: var(--primary, #7A1F2B);
  opacity: 0.7;
  margin-top: 2px;
  min-height: 16px;
}

/* Mic button */
.fab-mic-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary, #7A1F2B);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 2px;
}

.fab-mic-btn svg {
  width: 18px;
  height: 18px;
  stroke: var(--bg, #FBF7F0);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Pulse animation while listening */
@keyframes fab-mic-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.8; }
}

.fab-mic-btn.is-listening {
  background: #C8102E;
}

.fab-mic-btn.is-listening {
  animation: fab-mic-pulse 1s infinite;
}

@media (prefers-reduced-motion: reduce) {
  .fab-mic-btn.is-listening {
    animation: none;
    outline: 3px solid #C8102E;
  }
}

/* Lang pills (shown on surfaces without voice pills) */
.fab-lang-pills {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.fab-lang-pill {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-family: var(--font-body, 'Inter', sans-serif);
  border: 1px solid color-mix(in srgb, var(--primary, #7A1F2B) 40%, transparent);
  background: transparent;
  color: var(--primary, #7A1F2B);
  cursor: pointer;
}

.fab-lang-pill.is-active {
  background: var(--primary, #7A1F2B);
  color: var(--bg, #FBF7F0);
  border-color: var(--primary, #7A1F2B);
}

/* Submit row */
.fab-submit-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 8px 0 4px;
}

.fab-btn-cancel {
  background: none;
  border: none;
  color: var(--primary, #7A1F2B);
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
}

.fab-btn-cancel:hover,
.fab-btn-cancel:focus-visible {
  background: color-mix(in srgb, var(--primary, #7A1F2B) 8%, transparent);
  outline: none;
}

.fab-btn-submit {
  background: var(--primary, #7A1F2B);
  color: var(--bg, #FBF7F0);
  border: 2px solid transparent;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.1s, opacity 0.15s;
}

.fab-btn-submit:active {
  border-color: var(--accent, #C9A227);
}

.fab-btn-submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================================
   FAB MINI-TOAST
   ============================================================ */

.fab-toast {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: var(--primary, #7A1F2B);
  color: var(--bg, #FBF7F0);
  padding: 10px 16px;
  border-radius: 8px;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  z-index: 9600;
  max-width: 280px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.fab-toast.fab-toast--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.fab-toast.fab--bottom-left {
  right: auto;
  left: 20px;
}

@media (prefers-reduced-motion: reduce) {
  .fab-toast {
    transition: none;
  }
}
