/* Base styles for JSON:API Explorer - these get applied before the gin.css styles */
body {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Oxygen,
    Ubuntu,
    Cantarell,
    "Fira Sans",
    "Droid Sans",
    "Helvetica Neue",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
}

/* Main container */
.jsonapi-explorer-container {
  overflow: visible;
  max-width: 1600px;
  height: auto;
  margin: 0 auto;
  padding: 0;
}

/* Initial loading state */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  text-align: center;
}

/* Layout grid structure */
.jsonapi-explorer-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-gap: 20px;
}

@media (max-width: 992px) {
  .jsonapi-explorer-grid {
    grid-template-columns: 1fr;
  }
}

/* Helper classes for spacing */
.mb-1 {
  margin-bottom: 4px;
}
.mb-2 {
  margin-bottom: 8px;
}
.mb-3 {
  margin-bottom: 16px;
}
.mb-4 {
  margin-bottom: 24px;
}
.mt-1 {
  margin-top: 4px;
}
.mt-2 {
  margin-top: 8px;
}
.mt-3 {
  margin-top: 16px;
}
.mt-4 {
  margin-top: 24px;
}
.mr-1 {
  margin-right: 4px;
}
.mr-2 {
  margin-right: 8px;
}
.ml-1 {
  margin-left: 4px;
}
.ml-2 {
  margin-left: 8px;
}

/* Helper classes for text alignment */
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}
.text-left {
  text-align: left;
}

/* Default visually-hidden class for screen readers */
.visually-hidden {
  position: absolute !important;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  width: 1px;
  height: 1px;
  word-wrap: normal;
}

/* Tooltip styles */
.field-tooltip-wrapper {
  position: relative;
  z-index: 5;
  display: inline-block;
}

/* Ensure JS tooltips have proper positioning */
#js-tooltip {
  position: fixed !important;
  z-index: 10000 !important;
}

/* CSS-based tooltips - only apply to elements that don't use JS tooltips */
.field-tooltip-wrapper:not(.js-tooltip):hover::after {
  position: absolute;
  z-index: 10000;
  bottom: 100%;
  left: 50%;
  min-width: 150px;
  max-width: 300px;
  margin-bottom: 5px;
  padding: 8px 12px;
  content: attr(data-tooltip);
  transform: translateX(-50%);
  white-space: pre-wrap;
  pointer-events: none;
  color: var(--explorer-text, #fff);
  border-radius: 4px;
  background-color: var(--explorer-background-tertiary, #333);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  font-size: 13px;
  line-height: 1.5;
}

.field-tooltip-wrapper:not(.js-tooltip):hover::before {
  position: absolute;
  z-index: 10001;
  bottom: 100%;
  left: 50%;
  content: "";
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: var(--explorer-background-tertiary, #333) transparent transparent transparent;
}

/* Field chips display */
.field-chips {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

/* Remove max-width from description text in authentication section */
.jsonapi-explorer-container .form-item__description {
  max-width: none !important;
}

/* Ensure containers don't clip tooltips */
.explorer-panel-content,
.tab-content-section,
.claro-details__wrapper,
.available-fields,
.available-relationships {
  overflow: visible !important;
}

/* Allow fields-list and relationship-list to scroll vertically but keep horizontal visibility for tooltips */
.fields-list,
.relationship-chips,
.relationship-list {
  position: relative;
  z-index: 1;
  overflow-x: visible !important;
  overflow-y: auto;
}

/* Make chips display inline */
.field-chips__direct,
.field-chips__relationship {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}

/* Group title styles */
.fields-group-title,
.relationship-fields-title {
  flex-basis: 100%;
  margin: 8px 0;
  color: var(--explorer-text-secondary);
  font-size: 14px;
  font-weight: 600;
}

/* Style for search field input container */
.search-field-container {
  margin-bottom: 16px !important; /* Ensure consistent margin under search fields */
}

/* Style for relationship fields */
.gin-chip--base-relationship {
  border-style: dashed !important;
  background-color: rgba(var(--gin-color-primary-rgb), 0.1);
}

.relationship-field-notice {
  margin-left: 8px;
  color: var(--gin-color-text-light);
  font-size: 0.85em;
  font-style: italic;
}

/* Notification container and styles */
.notification-container {
  position: relative;
  z-index: 1000;
  display: flex;
  overflow: visible;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  margin: 0;
  padding: 0;
  pointer-events: none; /* Only allow interaction with the notification itself */
}

.jsonapi-explorer-container .messages {
  position: relative !important;
  z-index: 5000 !important;
  width: auto !important;
  max-width: 1200px !important;
  margin: 0 auto 16px auto !important;
  transform-origin: center top;
  text-align: center !important;
  pointer-events: auto; /* Make notification clickable */
  border-radius: 4px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

/* Apply font styles to notification message */
.jsonapi-explorer-container .messages__content {
  padding: 12px 16px !important;
  color: #000 !important; /* Ensure message text is always black */
  font-size: 14px !important;
  line-height: 1.5 !important;
}

/* Style close button */
.jsonapi-explorer-container .messages__close {
  position: absolute;
  top: 50%;
  right: 12px;
  padding: 4px 8px;
  cursor: pointer;
  transition: opacity 0.2s;
  transform: translateY(-50%);
  opacity: 0.7;
  border: none;
  background: none;
  font-size: 18px;
  line-height: 1;
}

.jsonapi-explorer-container .messages__close:hover {
  opacity: 1;
}

/* Animation for notifications */
@keyframes fade-in {
  from {
    transform: translateY(-10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

/* Fix for include chips to show immediate feedback when toggled */
.relationship-chips .gin-chip {
  position: relative;
  transition:
    background-color 0s,
    color 0s,
    border-color 0s !important;
}

/* Ensure the active/hover state doesn't override the selected state */
.relationship-chips .gin-chip--primary:active,
.relationship-chips .gin-chip--primary:hover {
  color: var(--gin-color-button-text) !important;
  border-color: var(--gin-color-primary) !important;
  background-color: var(--gin-color-primary) !important;
}

/* Ensure non-selected chips maintain their appearance when active/hover */
.relationship-chips .gin-chip:not(.gin-chip--primary):active,
.relationship-chips .gin-chip:not(.gin-chip--primary):hover {
  color: var(--gin-color-text) !important;
  background-color: var(--gin-bg-app) !important;
}
