/* ============================================================
   Feedback Widget Styles
   Floating FAB with responsive panel/bottom-sheet
   ============================================================ */

/* ========== Main Container ========== */

.feedback-widget {
  position: fixed;
  z-index: var(--z-popover);
  font-family: var(--font-sans);
}

/* ========== Trigger Button (FAB) ========== */

.feedback-trigger-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-popover);
}

.feedback-trigger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
  color: var(--color-text-on-primary);
  cursor: pointer;
  box-shadow: var(--shadow-lg), var(--shadow-primary);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  position: relative;
}

.feedback-trigger-btn:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-xl), var(--shadow-primary);
}

.feedback-trigger-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-lg), var(--shadow-focus);
}

.feedback-trigger-btn:active {
  transform: scale(0.98);
}

.feedback-trigger-btn.is-open {
  background: var(--color-text);
}

.trigger-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  transition: transform var(--transition-base), opacity var(--transition-base);
}

.trigger-icon svg {
  width: 24px;
  height: 24px;
}

.feedback-trigger-btn.is-open .trigger-icon-default {
  transform: rotate(90deg);
  opacity: 0;
}

.feedback-trigger-btn.is-open .trigger-icon-close {
  transform: rotate(0deg);
}

/* Tooltip */
.trigger-tooltip {
  position: absolute;
  right: calc(100% + var(--space-3));
  top: 50%;
  transform: translateY(-50%);
  padding: var(--space-2) var(--space-3);
  background: var(--color-text);
  color: var(--color-text-inverse);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  border-radius: var(--radius);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.feedback-trigger-btn:hover .trigger-tooltip,
.trigger-tooltip.visible {
  opacity: 1;
}

/* Pulse animation */
@keyframes feedback-pulse {
  0% {
    box-shadow: var(--shadow-lg), 0 0 0 0 rgba(13, 148, 136, 0.4);
  }
  70% {
    box-shadow: var(--shadow-lg), 0 0 0 15px rgba(13, 148, 136, 0);
  }
  100% {
    box-shadow: var(--shadow-lg), 0 0 0 0 rgba(13, 148, 136, 0);
  }
}

.feedback-trigger-btn.pulse {
  animation: feedback-pulse 1s ease-out;
}

/* ========== Desktop Panel ========== */

.feedback-panel-container {
  position: fixed;
  bottom: calc(var(--space-6) + 72px);
  right: var(--space-6);
  z-index: var(--z-popover);
}

.feedback-panel {
  width: 380px;
  max-height: calc(100vh - 150px);
  background: var(--color-bg-elevated);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  opacity: 0;
  transition: transform 0.2s var(--ease-spring), opacity 0.2s var(--ease-out);
}

.feedback-panel.is-open {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.feedback-panel-content {
  max-height: calc(100vh - 150px);
  overflow-y: auto;
}

/* ========== Mobile Bottom Sheet ========== */

.feedback-sheet-container {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
}

.feedback-bottom-sheet {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  pointer-events: none;
}

.feedback-bottom-sheet.is-open {
  pointer-events: auto;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.3s var(--ease-out);
}

.feedback-bottom-sheet.is-open .sheet-backdrop {
  opacity: 1;
}

.sheet-content {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-height: 90vh;
  transform: translateY(100%);
  transition: transform 0.3s var(--ease-out);
  display: flex;
  flex-direction: column;
}

.feedback-bottom-sheet.is-open .sheet-content {
  transform: translateY(0);
}

.sheet-handle {
  display: flex;
  justify-content: center;
  padding: var(--space-3) 0;
  cursor: grab;
}

.handle-bar {
  width: 36px;
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Prevent body scroll when sheet is open */
body.sheet-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* ========== Feedback Form ========== */

.feedback-form {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.feedback-form-header {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
}

.feedback-form-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  margin: 0 0 var(--space-1);
}

.feedback-form-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
}

.feedback-form-body {
  padding: var(--space-5);
  flex: 1;
  overflow-y: auto;
}

.feedback-form-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border-light);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* Form Groups */
.form-group {
  margin-bottom: var(--space-5);
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.label-required {
  color: var(--color-danger);
}

/* Type Selector */
.feedback-type-selector {
  display: flex;
  gap: var(--space-2);
}

.feedback-type-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1-5);
  padding: var(--space-3);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.feedback-type-btn:hover {
  border-color: var(--color-border-hover);
  background: var(--color-bg-hover);
}

.feedback-type-btn.active {
  border-color: var(--color-primary);
  background: var(--color-primary-subtle);
}

.feedback-type-btn svg {
  width: 20px;
  height: 20px;
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
}

.feedback-type-btn.active svg {
  color: var(--color-primary);
}

.type-label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
}

.feedback-type-btn.active .type-label {
  color: var(--color-primary);
}

/* Inputs */
.form-input,
.form-textarea {
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-text-subtle);
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
}

.form-input.has-error,
.form-textarea.has-error {
  border-color: var(--color-danger);
}

.form-input.has-error:focus,
.form-textarea.has-error:focus {
  box-shadow: var(--shadow-focus-danger);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* Form Hints & Errors */
.form-hint {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-1);
}

.char-count {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.char-count .char-current.over-limit {
  color: var(--color-danger);
  font-weight: var(--font-medium);
}

.char-count .min-hint {
  color: var(--color-text-muted);
}

.form-error {
  display: none;
  font-size: var(--text-sm);
  color: var(--color-danger);
  margin-top: var(--space-2);
}

.submit-error {
  width: 100%;
  text-align: center;
  margin-bottom: var(--space-3);
}

/* ========== Image Uploader ========== */

.feedback-image-uploader {
  position: relative;
}

.image-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.image-drop-zone:hover {
  border-color: var(--color-primary-muted);
  background: var(--color-primary-subtle);
}

.image-drop-zone.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}

.image-input {
  display: none;
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
}

.upload-icon {
  width: 32px;
  height: 32px;
  color: var(--color-text-muted);
}

.drop-zone-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  text-align: center;
}

.drop-primary {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
}

.drop-secondary {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Image Preview */
.image-preview-container {
  position: relative;
  display: flex;
  justify-content: center;
  padding: var(--space-3);
  background: var(--color-bg-subtle);
  border-radius: var(--radius-md);
}

.image-preview {
  max-width: 100%;
  max-height: 150px;
  border-radius: var(--radius);
  object-fit: contain;
}

.image-remove-btn {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--color-danger);
  color: white;
  cursor: pointer;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.image-remove-btn:hover {
  background: var(--color-danger-hover);
  transform: scale(1.1);
}

.image-remove-btn svg {
  width: 14px;
  height: 14px;
}

/* Upload/Compress State */
.image-uploading,
.image-compressing {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  background: var(--color-bg-subtle);
  border-radius: var(--radius-md);
  border: 2px dashed var(--color-border);
}

.upload-spinner,
.compress-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Image Info */
.image-info {
  position: absolute;
  bottom: var(--space-2);
  left: var(--space-2);
  padding: var(--space-1) var(--space-2);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: var(--text-xs);
  border-radius: var(--radius);
}

.image-upload-error {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-danger-bg);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--color-danger-text);
}

/* ========== Success View ========== */

.feedback-panel-success,
.sheet-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-6);
  text-align: center;
}

.success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: var(--space-4);
  background: var(--color-success-bg);
  border-radius: var(--radius-full);
  color: var(--color-success);
}

.success-icon svg {
  width: 32px;
  height: 32px;
}

.success-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  margin: 0 0 var(--space-2);
}

.success-message {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-6);
}

.success-close-btn {
  min-width: 120px;
}

/* ========== Buttons ========== */

.feedback-form .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2-5) var(--space-4);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.feedback-form .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.feedback-form .btn-primary {
  background: var(--color-primary);
  color: var(--color-text-on-primary);
}

.feedback-form .btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.feedback-form .btn-secondary {
  background: var(--color-bg-muted);
  color: var(--color-text-secondary);
}

.feedback-form .btn-secondary:hover:not(:disabled) {
  background: var(--color-bg-hover);
}

.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.loading-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========== Mobile Responsiveness ========== */

@media (max-width: 767px) {
  /* Hide panel on mobile */
  .feedback-panel-container {
    display: none !important;
  }

  /* Adjust trigger position for mobile */
  .feedback-trigger-container {
    bottom: var(--space-4);
    right: var(--space-4);
  }

  .feedback-trigger-btn {
    width: 52px;
    height: 52px;
  }

  /* Hide tooltip on mobile */
  .trigger-tooltip {
    display: none;
  }

  /* Form adjustments */
  .feedback-type-btn {
    padding: var(--space-2);
  }

  .feedback-type-btn svg {
    width: 18px;
    height: 18px;
  }

  .type-label {
    font-size: 10px;
  }

  .feedback-form-body {
    padding: var(--space-4);
  }
}

@media (min-width: 768px) {
  /* Hide bottom sheet on desktop */
  .feedback-sheet-container {
    display: none !important;
  }
}

/* ========== Dark Mode Support ========== */

@media (prefers-color-scheme: dark) {
  .feedback-trigger-btn {
    background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-primary) 100%);
  }

  .sheet-backdrop {
    background: rgba(0, 0, 0, 0.6);
  }
}

/* Manual dark mode class support */
.dark-mode .feedback-trigger-btn {
  background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-primary) 100%);
}

.dark-mode .sheet-backdrop {
  background: rgba(0, 0, 0, 0.6);
}
