/* ========================================
   Frontend Bug Report Widget
   ======================================== */

.bug-report-widget {
  position: relative;
  z-index: 60;
}

.bug-report-trigger {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0 1rem;
  color: #ffffff;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9999px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.22);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
}

.bug-report-trigger:hover {
  background: #1e293b;
}

body:not(.admin-container) .bug-report-trigger,
[data-approval-shell="true"] .bug-report-trigger {
  right: auto;
  left: max(1rem, env(safe-area-inset-left));
}

.bug-report-trigger:focus-visible,
.bug-report-icon-button:focus-visible,
.bug-report-primary-button:focus-visible,
.bug-report-secondary-button:focus-visible,
.bug-report-file-remove:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.bug-report-trigger-icon {
  width: 1.125rem;
  height: 1.125rem;
  flex: none;
}

.bug-report-backdrop {
  position: fixed;
  inset: 0;
  z-index: 68;
  background: rgba(15, 23, 42, 0.32);
}

.bug-report-panel {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: calc(4.5rem + env(safe-area-inset-bottom));
  z-index: 69;
  width: min(25rem, calc(100vw - 2rem));
  max-height: min(42rem, calc(100dvh - 6rem - env(safe-area-inset-bottom)));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #ffffff;
  border: 1px solid #dbe3ef;
  border-radius: 0.75rem;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

body:not(.admin-container) .bug-report-panel,
[data-approval-shell="true"] .bug-report-panel {
  right: auto;
  left: max(1rem, env(safe-area-inset-left));
}

.bug-report-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
}

.bug-report-title {
  color: #0f172a;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
}

.bug-report-context {
  margin-top: 0.125rem;
  color: #64748b;
  font-size: 0.75rem;
  line-height: 1.4;
  word-break: break-word;
}

.bug-report-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  color: #475569;
  background: transparent;
  border-radius: 9999px;
}

.bug-report-icon-button:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.bug-report-form {
  display: grid;
  gap: 0.875rem;
  padding: 1rem;
}

.bug-report-field {
  display: grid;
  gap: 0.375rem;
}

.bug-report-label {
  color: #334155;
  font-size: 0.8125rem;
  font-weight: 600;
}

.bug-report-textarea {
  width: 100%;
  min-height: 8rem;
  resize: vertical;
  color: #0f172a;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  padding: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
}

.bug-report-textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.bug-report-field-error {
  border-color: #dc2626;
}

.bug-report-upload {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem;
  border: 1px dashed #94a3b8;
  border-radius: 0.625rem;
  background: #f8fafc;
  cursor: pointer;
}

.bug-report-upload:hover {
  border-color: #475569;
  background: #f1f5f9;
}

.bug-report-upload-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  color: #334155;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
}

.bug-report-upload-title,
.bug-report-upload-copy {
  display: block;
}

.bug-report-upload-title {
  color: #0f172a;
  font-size: 0.875rem;
  font-weight: 600;
}

.bug-report-upload-copy {
  margin-top: 0.125rem;
  color: #64748b;
  font-size: 0.75rem;
  line-height: 1.4;
}

.bug-report-files {
  display: grid;
  gap: 0.5rem;
}

.bug-report-file {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  background: #ffffff;
}

.bug-report-file-name {
  min-width: 0;
  overflow: hidden;
  color: #0f172a;
  font-size: 0.8125rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bug-report-file-size {
  color: #64748b;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.bug-report-file-remove {
  color: #b91c1c;
  font-size: 0.75rem;
  font-weight: 600;
}

.bug-report-status {
  min-height: 1.25rem;
  color: #475569;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.bug-report-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.bug-report-secondary-button,
.bug-report-primary-button {
  min-height: 2.5rem;
  padding: 0 0.875rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.bug-report-secondary-button {
  color: #334155;
  background: #ffffff;
  border: 1px solid #cbd5e1;
}

.bug-report-secondary-button:hover {
  background: #f8fafc;
}

.bug-report-primary-button {
  color: #ffffff;
  background: #1d4ed8;
}

.bug-report-primary-button:hover {
  background: #1e40af;
}

.bug-report-primary-button:disabled {
  cursor: wait;
  background: #94a3b8;
}

@media (max-width: 640px) {
  .bug-report-trigger {
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
    width: 3rem;
    min-height: 3rem;
    justify-content: center;
    padding: 0;
  }

  body:not(.admin-container) .bug-report-trigger,
  [data-approval-shell="true"] .bug-report-trigger {
    right: auto;
    left: max(0.75rem, env(safe-area-inset-left));
  }

  .bug-report-trigger-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .bug-report-panel {
    inset: auto 0 0 0;
    width: 100%;
    max-height: min(40rem, calc(100dvh - 2rem));
    padding-bottom: env(safe-area-inset-bottom);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 1rem 1rem 0 0;
  }
}
