/* Feedback Widget Base Styles */
.feedback-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  font-family: "ROsanswebtextregular", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  z-index: 999;
  pointer-events: none;
}

.feedback-widget > * {
  pointer-events: auto;
}

/* Toggle Button */
.feedback-widget__toggle {
  position: fixed;
  bottom: 20px;
  right: 50px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background-color: #007bc7;
  color: #ffffff;
  border: none;
  border-radius: 0rem;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  flex-shrink: 0;
  white-space: nowrap;
  z-index: 999;
}

.feedback-widget__toggle:hover {
  background-color: #3d85c9;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.feedback-widget__toggle:focus {
  outline: 2px solid #316fb3;
  outline-offset: 2px;
}

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

.feedback-widget__toggle-text {
  display: inline;
}

/* Dismiss Button */
.feedback-widget__dismiss {
  position: fixed;
  bottom: 30px;
  right: 20px;
  background: none;
  color: #666;
  border: none;
  cursor: pointer;
  font-size: 20px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.2s ease;
  z-index: 999;
}

.feedback-widget__dismiss:hover {
  color: #154273;
}

.feedback-widget__dismiss:focus {
  outline: 2px solid #316fb3;
  outline-offset: 2px;
}

/* Feedback Panel */
.feedback-widget__panel {
  position: fixed;
  width: 400px;
  background-color: #ffffff;
  border: 1px solid #B9C7D5;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.3s ease-out;
  max-height: 85vh;
  overflow-y: auto;
  z-index: 998;
  /* Position just above the button */
  /* Button is at bottom: 20px, right: 20px, height ~48px */
  bottom: calc(20px + 48px + 8px);
  right: 20px;
  top: auto;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feedback-widget__panel[hidden] {
  display: none;
}

/* Panel Header */
.feedback-widget__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #e0e0e0;
}

.feedback-widget__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #154273;
}

.feedback-widget__guideline {
  margin: 8px 0 0 0;
  font-size: 13px;
  color: #666;
  font-weight: 400;
}

.feedback-widget__close {
  background: none;
  border: none;
  font-size: 24px;
  color: #666;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.feedback-widget__close:hover {
  background-color: #f5f5f5;
}

.feedback-widget__close:focus {
  outline: 2px solid #316fb3;
  outline-offset: 2px;
  background-color: #eeeeee;
}

.feedback-widget__close:focus-visible {
  outline: 2px solid #316fb3;
  outline-offset: 2px;
  background-color: #eeeeee;
}

/* Form Styles */
.feedback-widget__form {
  padding: 16px;
}

.feedback-widget__instructions {
  margin: 0 0 16px 0;
  font-size: 14px;
  color: #555;
  line-height: 1.4;
}

/* Form Fields */
.feedback-widget__field {
  margin-bottom: 16px;
}

.feedback-widget__label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: #154273;
}

.feedback-widget__required {
  color: #d32f2f;
  margin-left: 2px;
}

.feedback-widget__optional {
  color: #666;
  font-size: 12px;
  font-weight: 400;
  margin-left: 4px;
}

.feedback-widget__input,
.feedback-widget__select,
.feedback-widget__textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  border: 1px solid #B9C7D5;
  border-radius: 4px;
  background-color: #ffffff;
  color: #154273;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.feedback-widget__input:focus,
.feedback-widget__select:focus,
.feedback-widget__textarea:focus {
  outline: none;
  border-color: #316fb3;
  box-shadow: 0 0 0 3px rgba(49, 111, 179, 0.1);
}

.feedback-widget__textarea {
  resize: vertical;
  min-height: 100px;
}

.feedback-widget__textarea--small {
  min-height: 60px;
}

/* Link Fields Container */
.feedback-widget__links-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.feedback-widget__link-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.feedback-widget__link-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.feedback-widget__input--link {
  flex: 1;
}

/* Add Link Button */
.feedback-widget__add-link {
  background: none;
  border: 1px dashed #B9C7D5;
  color: #154273;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}

.feedback-widget__add-link:hover {
  border-color: #316fb3;
  background-color: #f5f5f5;
}

.feedback-widget__add-link:focus {
  outline: 2px solid #316fb3;
  outline-offset: 2px;
}

/* Remove Link Button */
.feedback-widget__remove-link {
  background: none;
  border: 1px solid #d32f2f;
  color: #d32f2f;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.feedback-widget__remove-link:hover {
  background-color: #d32f2f;
  color: #ffffff;
}

.feedback-widget__remove-link:focus {
  outline: 2px solid #d32f2f;
  outline-offset: 2px;
}

.feedback-widget__select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23154273' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 20px;
  padding-right: 32px;
}

/* Hints and Error Messages */
.feedback-widget__hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #666;
}

.feedback-widget__error {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #d32f2f;
  font-weight: 500;
}

.feedback-widget__error:empty {
  display: none;
}

/* Honeypot Field (Hidden) */
.feedback-widget__honeypot {
  position: absolute;
  left: -9999px;
  opacity: 0;
}

.feedback-widget__honeypot input {
  display: none;
}

/* Screen Reader Only Text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Skip Link to Feedback Widget */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background-color: #154273;
  color: #ffffff;
  padding: 12px 16px;
  text-decoration: none;
  z-index: 10000;
  border-radius: 0 0 4px 0;
  font-weight: 500;
  font-size: 14px;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid #316fb3;
  outline-offset: 0;
}

.skip-link:focus-visible {
  top: 0;
  outline: 2px solid #316fb3;
  outline-offset: 0;
}

.skip-link:hover {
  background-color: #0d3152;
}

/* Form Actions */
.feedback-widget__actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.feedback-widget__actions .md-button {
  flex: 1;
}

.feedback-widget__actions .md-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Status Messages */
.feedback-widget__status {
  padding: 12px;
  margin: 12px 0 0 0;
  border-radius: 4px;
  background-color: #f5f5f5;
  color: #154273;
  font-size: 13px;
}

.feedback-widget__status[hidden] {
  display: none;
}

.feedback-widget__status.loading::after {
  content: ' ...';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% {
    content: '';
  }
  40% {
    content: '.';
  }
  60% {
    content: '..';
  }
  80%, 100% {
    content: '...';
  }
}

/* Success Message */
.feedback-widget__success {
  padding: 12px;
  margin: 12px 0 0 0;
  border-radius: 4px;
  background-color: #e8f5e9;
  border: 1px solid #4caf50;
  animation: slideIn 0.3s ease-out;
}

.feedback-widget__success[hidden] {
  display: none;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feedback-widget__success-content {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.feedback-widget__success-icon {
  font-size: 20px;
  color: #4caf50;
  flex-shrink: 0;
}

.feedback-widget__success-title {
  margin: 0 0 6px 0;
  font-weight: 600;
  color: #2e7d32;
  font-size: 14px;
}

.feedback-widget__success-reference {
  margin: 0;
  font-size: 12px;
  color: #555;
}

.feedback-widget__success-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #666;
  cursor: pointer;
  padding: 0;
  margin-top: -4px;
  align-self: flex-end;
}

.feedback-widget__success-close:focus {
  outline: 2px solid #316fb3;
  outline-offset: 2px;
}

/* Error State */
.feedback-widget__input.has-error,
.feedback-widget__select.has-error,
.feedback-widget__textarea.has-error,
.feedback-widget__input--invalid {
  border-color: #d32f2f;
}

.feedback-widget__input--invalid:focus {
  border-color: #d32f2f;
  box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
}

/* Loading State */
.feedback-widget__actions .md-button[aria-busy="true"] {
  pointer-events: none;
  opacity: 0.7;
}

.feedback-widget__actions .md-button[aria-busy="true"]::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 6px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

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

/* Responsive Design */
@media (max-width: 480px) {
  .feedback-widget {
    bottom: 16px;
    right: 16px;
  }

  .feedback-widget__panel {
    width: calc(100vw - 32px);
  }

  .feedback-widget__button {
    font-size: 13px;
    padding: 12px 14px;
  }

  .feedback-widget__select {
    background-size: 18px;
    padding-right: 30px;
  }
}


/* Print Styles */
@media print {
  .feedback-widget {
    display: none;
  }
}

/* Dark Mode Support (if implemented) */
@media (prefers-color-scheme: dark) {
  .feedback-widget__panel {
    background-color: #2c2c2c;
    border-color: #444;
  }

  .feedback-widget__input,
  .feedback-widget__select,
  .feedback-widget__textarea {
    background-color: #3c3c3c;
    color: #e0e0e0;
    border-color: #555;
  }

  .feedback-widget__label,
  .feedback-widget__title {
    color: #e0e0e0;
  }

  .feedback-widget__optional {
    color: #999;
  }

  .feedback-widget__instructions {
    color: #b0b0b0;
  }

  .feedback-widget__hint {
    color: #999;
  }
}
