/* Feedback Widget Styles */
:root {
  --fb-bg: #ffffff;
  --fb-text: #1f2937;
  --fb-accent: #4b9fff;
  --fb-border: #e5e7eb;
  --fb-shadow: rgba(0, 0, 0, 0.1);
  --fb-shadow-lg: rgba(0, 0, 0, 0.25);
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
  :root {
    --fb-bg: #1f2937;
    --fb-text: #f9fafb;
    --fb-accent: #60a5fa;
    --fb-border: #374151;
    --fb-shadow: rgba(0, 0, 0, 0.3);
    --fb-shadow-lg: rgba(0, 0, 0, 0.5);
  }
}

/* Theme-specific overrides */
html[data-palette="earthy"] {
  --fb-bg: var(--wheat);
  --fb-text: var(--rich-black);
  --fb-accent: var(--mahogany);
  --fb-border: var(--dark-slate-gray);
}

html[data-palette="vibrant"] {
  --fb-bg: #fef7f0;
  --fb-text: #cc0068;
  --fb-accent: #fc9a00;
  --fb-border: #e683b5;
}

html[data-palette="delft"] {
  --fb-bg: var(--bg-main);
  --fb-text: var(--text-primary);
  --fb-accent: var(--accent-primary);
  --fb-border: var(--border-color);
}

html[data-palette="claude"] {
  --fb-bg: var(--bg-main);
  --fb-text: var(--text-primary);
  --fb-accent: var(--accent-primary);
  --fb-border: var(--border-color);
}

html[data-palette="gemini"] {
  --fb-bg: var(--gemini-deep-space);
  --fb-text: var(--gemini-starlight);
  --fb-accent: var(--gemini-hyper-blue);
  --fb-border: var(--gemini-cool-gray);
}

/* Launcher */
.fb-launcher {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  transition: bottom 0.3s ease;
}

/* Pill wrapper for dark themes */
html[data-palette="gemini"] .fb-launcher,
html[data-palette="claude"] .fb-launcher {
  background: white;
  border-radius: 32px;
  padding: 8px;
  box-shadow: 0 4px 15px var(--fb-shadow-lg);
}

/* Make buttons transparent in dark themes so white background shows through */
html[data-palette="gemini"] .fb-btn,
html[data-palette="claude"] .fb-btn {
  background: transparent;
  border: none;
  box-shadow: none;
}

@media (prefers-color-scheme: dark) {
  .fb-launcher {
    background: white;
    border-radius: 32px;
    padding: 8px;
    box-shadow: 0 4px 15px var(--fb-shadow-lg);
  }

  .fb-btn {
    background: transparent;
    border: none;
    box-shadow: none;
  }
}

/* Ensure launcher stays above footer */
.fb-launcher.fb-above-footer {
  position: absolute;
  bottom: auto;
  top: -80px; /* Adjust based on launcher height */
}

.fb-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--fb-bg);
  border: 1px solid var(--fb-border);
  box-shadow: 0 2px 10px var(--fb-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  outline: none;
}

.fb-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px var(--fb-shadow-lg);
}

.fb-btn:focus {
  outline: 2px solid var(--fb-accent);
  outline-offset: 2px;
}

.fb-btn:active {
  transform: translateY(0);
}

.fb-btn img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}


/* Modal */
.fb-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 1000000000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.fb-modal.fb-modal-open {
  opacity: 1;
  visibility: visible;
}

.fb-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

.fb-card {
  position: relative;
  width: min(92vw, 520px);
  max-height: 90vh;
  background: var(--fb-bg);
  color: var(--fb-text);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 25px -5px var(--fb-shadow-lg);
  border: 1px solid var(--fb-border);
  transform: scale(0.95);
  transition: transform 0.2s ease;
  overflow-y: auto;
}

.fb-modal.fb-modal-open .fb-card {
  transform: scale(1);
}

.fb-card h2 {
  margin: 0 0 16px 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--fb-text);
}

.fb-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: color-mix(in srgb, var(--fb-accent), transparent 90%);
  border-radius: 8px;
  font-size: 0.9rem;
}

.fb-choice-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}


.fb-form-group {
  margin-bottom: 16px;
}

.fb-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fb-text);
}

.fb-textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--fb-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--fb-bg);
  color: var(--fb-text);
  transition: border-color 0.2s ease;
}

.fb-textarea:focus {
  outline: none;
  border-color: var(--fb-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--fb-accent), transparent 80%);
}

.fb-textarea::placeholder {
  color: color-mix(in srgb, var(--fb-text), transparent 50%);
}

.fb-turnstile-container {
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
}

.fb-turnstile-error {
  color: #ef4444;
  font-size: 0.85rem;
  margin-top: 8px;
  text-align: center;
}

.fb-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

.fb-btn-secondary, .fb-btn-primary {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid;
  text-decoration: none;
  outline: none;
}

.fb-btn-secondary {
  background: transparent;
  color: var(--fb-text);
  border-color: var(--fb-border);
}

.fb-btn-secondary:hover {
  background: color-mix(in srgb, var(--fb-text), transparent 95%);
}

.fb-btn-primary {
  background: var(--fb-accent);
  color: white;
  border-color: var(--fb-accent);
}

.fb-btn-primary:hover {
  background: color-mix(in srgb, var(--fb-accent), black 10%);
  border-color: color-mix(in srgb, var(--fb-accent), black 10%);
}

.fb-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.fb-btn-secondary:focus, .fb-btn-primary:focus {
  outline: 2px solid var(--fb-accent);
  outline-offset: 2px;
}

/* Loading state */
.fb-loading .fb-btn-primary {
  position: relative;
  color: transparent;
}

.fb-loading .fb-btn-primary::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: white;
  border-radius: 50%;
  animation: fb-spin 1s linear infinite;
}

@keyframes fb-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Success state */
.fb-success {
  text-align: center;
}

.fb-success-icon {
  font-size: 3rem;
  color: #10b981;
  margin-bottom: 16px;
}

.fb-success h2 {
  color: #10b981;
  margin-bottom: 8px;
}

.fb-success p {
  color: var(--fb-text);
  opacity: 0.8;
  margin-bottom: 20px;
}

/* Error messages */
.fb-error {
  color: #ef4444;
  font-size: 0.85rem;
  margin-top: 8px;
  text-align: center;
  padding: 8px;
  background: color-mix(in srgb, #ef4444, transparent 90%);
  border-radius: 6px;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .fb-launcher {
    right: 12px;
    bottom: 12px;
    max-height: calc(100vh - 120px); /* Ensure it doesn't go off screen */
  }

  .fb-btn {
    width: 44px;
    height: 44px;
  }

  .fb-btn img {
    width: 20px;
    height: 20px;
  }

  .fb-card {
    width: min(95vw, 400px);
    padding: 20px;
    margin: 16px;
  }

  .fb-actions {
    flex-direction: column-reverse;
  }

  .fb-btn-secondary, .fb-btn-primary {
    width: 100%;
    justify-content: center;
    display: flex;
  }
}

/* Ensure launcher never overlaps footer on any screen size */
.fb-launcher {
  pointer-events: auto;
}

/* Add some breathing room from footer */
footer + .fb-launcher {
  margin-bottom: 8px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .fb-btn {
    border-width: 2px;
  }

  .fb-card {
    border-width: 2px;
  }
}
