/* ═══════════════════════════════════════════
   BGCK Prototype Feedback System v2
   ═══════════════════════════════════════════ */

:root {
  --fb-purple: #6b2d8b;
  --fb-purple-light: rgba(107, 45, 139, 0.08);
  --fb-purple-hover: #5a2578;
  --fb-green: #16a34a;
  --fb-red: #dc2626;
  --fb-gray-50: #f9fafb;
  --fb-gray-100: #f3f4f6;
  --fb-gray-200: #e5e7eb;
  --fb-gray-300: #d1d5db;
  --fb-gray-400: #9ca3af;
  --fb-gray-500: #6b7280;
  --fb-gray-600: #4b5563;
  --fb-gray-700: #374151;
  --fb-gray-900: #111827;
  --fb-radius: 10px;
  --fb-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Floating Action Button ── */
.fb-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--fb-purple);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(107, 45, 139, 0.35), 0 1px 3px rgba(0,0,0,0.1);
  transition: all 0.25s ease;
  animation: fb-pulse 3s ease-in-out infinite;
}
.fb-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(107, 45, 139, 0.45), 0 2px 6px rgba(0,0,0,0.1);
}
.fb-fab-active {
  background: var(--fb-gray-900);
  animation: none;
  border-radius: 16px;
}
@keyframes fb-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(107, 45, 139, 0.35); }
  50% { box-shadow: 0 4px 24px rgba(107, 45, 139, 0.55), 0 0 0 6px rgba(107, 45, 139, 0.08); }
}

/* ── Badge ── */
.fb-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--fb-red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-family: var(--fb-font);
  border: 2px solid white;
}

/* ── Side Panel ── */
.fb-panel {
  position: fixed;
  top: 0;
  right: -460px;
  z-index: 9999;
  width: 440px;
  max-width: 92vw;
  height: 100vh;
  background: #fff;
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--fb-font);
  font-size: 14px;
  color: var(--fb-gray-700);
}
.fb-panel-open {
  right: 0;
}

/* Panel Header */
.fb-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--fb-gray-200);
  background: white;
  flex-shrink: 0;
}
.fb-panel-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--fb-gray-900);
  margin: 0;
  letter-spacing: -0.01em;
}
.fb-panel-actions {
  display: flex;
  gap: 2px;
}

/* Tab Bar */
.fb-tabs {
  display: flex;
  border-bottom: 1px solid var(--fb-gray-200);
  background: white;
  padding: 0 20px;
  flex-shrink: 0;
}
.fb-tab {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fb-gray-400);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--fb-font);
  white-space: nowrap;
}
.fb-tab:hover {
  color: var(--fb-gray-600);
}
.fb-tab-active {
  color: var(--fb-purple);
  border-bottom-color: var(--fb-purple);
}
.fb-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  font-size: 10px;
  font-weight: 700;
  background: var(--fb-gray-100);
  color: var(--fb-gray-500);
  border-radius: 8px;
  padding: 0 4px;
  margin-left: 4px;
}
.fb-tab-active .fb-tab-count {
  background: var(--fb-purple-light);
  color: var(--fb-purple);
}

/* Toolbar row (author + pin mode) */
.fb-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--fb-gray-200);
  background: var(--fb-gray-50);
  flex-shrink: 0;
}
.fb-toolbar .fb-input {
  flex: 1;
}

/* ── Author display ── */
.fb-author-label {
  font-size: 12px;
  color: var(--fb-gray-500);
  flex: 1;
}
.fb-author-label strong {
  color: var(--fb-gray-900);
}
.fb-author-change {
  font-size: 11px;
  color: var(--fb-purple);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-family: var(--fb-font);
  padding: 0;
}
.fb-author-change:hover {
  text-decoration: underline;
}

/* ── Inputs ── */
.fb-input {
  padding: 7px 10px;
  border: 1px solid var(--fb-gray-200);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  font-family: inherit;
  color: var(--fb-gray-900);
  background: white;
}
.fb-input:focus {
  border-color: var(--fb-purple);
  box-shadow: 0 0 0 3px rgba(107, 45, 139, 0.08);
}
.fb-input::placeholder {
  color: var(--fb-gray-400);
}
.fb-input-error {
  border-color: var(--fb-red) !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1) !important;
}
.fb-input-error::placeholder {
  color: var(--fb-red);
}

.fb-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--fb-gray-200);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  resize: vertical;
  min-height: 60px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  font-family: inherit;
  color: var(--fb-gray-900);
  line-height: 1.5;
}
.fb-textarea:focus {
  border-color: var(--fb-purple);
  box-shadow: 0 0 0 3px rgba(107, 45, 139, 0.08);
}
.fb-textarea::placeholder {
  color: var(--fb-gray-400);
}

/* ── Buttons ── */
.fb-btn-icon {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fb-gray-400);
  transition: all 0.15s;
  flex-shrink: 0;
}
.fb-btn-icon:hover {
  background: var(--fb-gray-100);
  color: var(--fb-gray-600);
}
.fb-btn-active {
  background: var(--fb-purple) !important;
  color: white !important;
}

.fb-submit {
  padding: 9px 16px;
  background: var(--fb-purple);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.fb-submit:hover {
  background: var(--fb-purple-hover);
}
.fb-submit:disabled {
  background: var(--fb-gray-300);
  cursor: not-allowed;
}

/* ── Comments List ── */
.fb-comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.fb-empty {
  text-align: center;
  color: var(--fb-gray-400);
  font-size: 13px;
  padding: 48px 24px;
  line-height: 1.7;
}
.fb-empty svg {
  display: block;
  margin: 0 auto 12px;
  opacity: 0.3;
}

/* Comment Card */
.fb-comment {
  background: white;
  border-radius: var(--fb-radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--fb-gray-200);
  transition: all 0.2s;
}
.fb-comment:hover {
  border-color: var(--fb-gray-300);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.fb-comment.fb-resolved {
  background: var(--fb-gray-50);
  border-color: var(--fb-gray-200);
}
.fb-comment.fb-resolved .fb-comment-body,
.fb-comment.fb-resolved .fb-comment-author,
.fb-comment.fb-resolved .fb-comment-type {
  opacity: 0.5;
}
.fb-comment.fb-resolved:hover .fb-comment-body,
.fb-comment.fb-resolved:hover .fb-comment-author,
.fb-comment.fb-resolved:hover .fb-comment-type {
  opacity: 0.8;
}

.fb-comment-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.fb-comment-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 7px;
  border-radius: 4px;
  line-height: 1;
}
.fb-type-general {
  background: #ede9fe;
  color: #6d28d9;
}
.fb-type-pin {
  background: #fee2e2;
  color: #dc2626;
}
.fb-type-selection {
  background: #dbeafe;
  color: #2563eb;
}
.fb-comment-author {
  font-size: 13px;
  font-weight: 600;
  color: var(--fb-gray-900);
}
.fb-comment-time {
  font-size: 11px;
  color: var(--fb-gray-400);
  margin-left: auto;
}

.fb-resolved-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--fb-green);
  background: #dcfce7;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.fb-selection-preview {
  font-size: 12px;
  color: #2563eb;
  background: #eff6ff;
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-style: italic;
  border-left: 2px solid #3b82f6;
  line-height: 1.5;
}

.fb-pin-coords {
  font-size: 11px;
  color: var(--fb-gray-400);
  margin-bottom: 4px;
}

.fb-comment-body {
  font-size: 13px;
  color: var(--fb-gray-700);
  line-height: 1.55;
  white-space: pre-wrap;
}

.fb-comment-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--fb-gray-100);
}

.fb-action-btn {
  font-size: 11px;
  color: var(--fb-gray-400);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-weight: 600;
  font-family: inherit;
  transition: color 0.15s;
}
.fb-action-btn:hover {
  color: var(--fb-gray-700);
}
.fb-action-resolve {
  color: var(--fb-green);
}
.fb-action-resolve:hover {
  color: #15803d;
}
.fb-action-delete:hover {
  color: var(--fb-red);
}
.fb-action-confirm-delete {
  color: white !important;
  background: var(--fb-red) !important;
  padding: 2px 8px !important;
  border-radius: 4px;
}

/* ── Attachments ── */
.fb-attachments {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.fb-attachment {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--fb-purple);
  background: var(--fb-purple-light);
  padding: 3px 8px;
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.15s;
}
.fb-attachment:hover {
  background: rgba(107, 45, 139, 0.15);
}

/* ── Compose Area ── */
.fb-compose {
  padding: 14px 16px;
  border-top: 1px solid var(--fb-gray-200);
  background: white;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

/* Formatting toolbar */
.fb-format-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: var(--fb-gray-50);
  border: 1px solid var(--fb-gray-200);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}
.fb-format-bar + .fb-textarea {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
.fb-fmt-btn {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fb-gray-500);
  transition: all 0.12s;
  padding: 0;
}
.fb-fmt-btn:hover {
  background: var(--fb-gray-200);
  color: var(--fb-gray-700);
}
.fb-fmt-sep {
  width: 1px;
  height: 16px;
  background: var(--fb-gray-200);
  margin: 0 4px;
}

/* Links in formatted comments */
.fb-comment-body .fb-link {
  color: var(--fb-purple);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.fb-comment-body .fb-link:hover {
  color: var(--fb-purple-hover);
}
.fb-comment-body ul {
  margin: 4px 0;
  padding-left: 18px;
}

/* Context banner for pin/selection comments */
.fb-compose-context {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: var(--fb-gray-50);
  border: 1px solid var(--fb-gray-200);
  border-radius: 8px;
  font-size: 12px;
  color: var(--fb-gray-600);
  line-height: 1.4;
}
.fb-compose-context-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.fb-compose-context-text {
  flex: 1;
  min-width: 0;
}
.fb-compose-context-text em {
  color: #2563eb;
  font-style: italic;
}
.fb-compose-context-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fb-gray-400);
  padding: 0;
  display: flex;
  align-items: center;
}
.fb-compose-context-dismiss:hover {
  color: var(--fb-gray-600);
}

.fb-compose-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.fb-compose-row .fb-textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
}
.fb-compose-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.fb-file-upload {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.fb-file-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--fb-gray-400);
  cursor: pointer;
  padding: 4px 8px;
  border: 1px dashed var(--fb-gray-300);
  border-radius: 6px;
  transition: all 0.15s;
}
.fb-file-label:hover {
  border-color: var(--fb-purple);
  color: var(--fb-purple);
}
.fb-file-hidden {
  display: none;
}
.fb-file-names {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.fb-file-name {
  font-size: 11px;
  color: var(--fb-purple);
  background: var(--fb-purple-light);
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.fb-file-remove {
  cursor: pointer;
  opacity: 0.5;
  font-size: 13px;
  line-height: 1;
}
.fb-file-remove:hover {
  opacity: 1;
}
.fb-file-error {
  font-size: 11px;
  color: var(--fb-red);
}

/* ── All Pages View ── */
.fb-page-group {
  margin-bottom: 16px;
}
.fb-page-group-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fb-gray-400);
  padding: 6px 0;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--fb-gray-100);
  display: flex;
  align-items: center;
  gap: 6px;
}
.fb-page-group-header a {
  color: var(--fb-purple);
  text-decoration: none;
  font-family: monospace;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
}
.fb-page-group-header a:hover {
  text-decoration: underline;
}
.fb-page-group-count {
  margin-left: auto;
  background: var(--fb-gray-100);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
}

/* ── Selection Tooltip ── */
.fb-sel-tooltip {
  position: absolute;
  z-index: 9997;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.fb-sel-tooltip.fb-sel-visible {
  opacity: 1;
  pointer-events: auto;
}

.fb-sel-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--fb-gray-900);
  color: white;
  border: none;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  font-family: var(--fb-font);
  transition: background 0.15s;
}
.fb-sel-btn:hover {
  background: var(--fb-purple);
}

/* ── Pin Overlay ── */
.fb-pin-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.fb-pin-overlay-active {
  pointer-events: auto;
  opacity: 1;
  cursor: crosshair;
}
.fb-pin-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 20px;
  background: var(--fb-purple);
  color: white;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--fb-font);
  z-index: 9991;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ── Pin Markers ── */
.fb-pins {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0;
  pointer-events: none;
  z-index: 9000;
}
.fb-pin-marker {
  position: absolute;
  transform: translate(-50%, -100%);
  cursor: pointer;
  pointer-events: auto;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
  transition: transform 0.15s;
  animation: fb-pin-drop 0.35s ease-out;
}
.fb-pin-marker:hover {
  transform: translate(-50%, -100%) scale(1.15);
}
@keyframes fb-pin-drop {
  0% { opacity: 0; transform: translate(-50%, -150%) scale(0.5); }
  60% { transform: translate(-50%, -95%) scale(1.05); }
  100% { opacity: 1; transform: translate(-50%, -100%) scale(1); }
}

/* ── Text Selection Highlights ── */
.fb-highlight {
  background: rgba(107, 45, 139, 0.12);
  border-bottom: 2px solid var(--fb-purple);
  cursor: pointer;
  padding: 1px 0;
  border-radius: 2px;
  transition: background 0.15s;
  position: relative;
}
.fb-highlight:hover {
  background: rgba(107, 45, 139, 0.25);
}

/* ── Toast notifications ── */
.fb-toast {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 10001;
  background: var(--fb-gray-900);
  color: white;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  font-family: var(--fb-font);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.fb-toast-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Mobile ── */
@media (max-width: 480px) {
  .fb-panel {
    width: 100vw;
    right: -100vw;
  }
  .fb-fab {
    bottom: 16px;
    right: 16px;
    width: 46px;
    height: 46px;
    border-radius: 14px;
  }
}
