/* Hide shoelace library components until they have been defined */
:not(:defined) {
  visibility: hidden;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  /* Apply to all elements */
}


body {
  font-family: sans-serif;
  height: 100vh;
  width: 100vw;
  margin: 0;
  padding: 0;
  overflow: hidden;
  box-sizing: border-box;
  /* Add this to the body */
}


h1,
h2,
h3 {
  margin: auto
}

.hidden {
  visibility: hidden;
}

.hbox-with-gap {
  display: flex;
  flex-direction: row;
  margin: 0px;
  padding: 0px;
  gap: 10px;
}

#container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  padding: 10px;
}

#toolbar {
  height: 55px;
}

/* z-index issues */
tool-bar {
  z-index: calc(var(--sl-z-index-dropdown)-1) !important;
}

tool-bar.dropdown-open {
  z-index: var(--sl-z-index-dropdown) !important;
}

div[name = "xmlEditor"] tool-bar sl-button {
  max-height: 19px;
}

div[name = "xmlEditor"] tool-bar sl-button::part(label) {
  line-height: 19px;
}


/* special styling of the toolbar to align the labels of the selectboxes and button groups */
#toolbar sl-button-group[label]:before {
  content: attr(label);
  position: absolute;
  top: -8px;
  left: 0;
  color: var(--sl-color-gray-500);
  font-size: smaller;
  white-space: nowrap;
  display: block;
}

#toolbar sl-select::part(form-control) {
  transform: translateY(-5px);
}

#toolbar sl-button::part(base) {
  margin-top: 5px;
}

sl-select::part(form-control-label) {
  font-size: smaller;
  color: var(--sl-color-gray-500)
}

/* Loading state for file selection selectboxes */
sl-select.loading::part(combobox) {
  opacity: 0.6;
  cursor: wait;
}

sl-select.loading::part(form-control-label) {
  opacity: 0.6;
}


#editors {
  flex-grow: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
  --divider-width: 4px;
  --divider-hit-area: 12px;
}

#editors::part(panel) {
  overflow: hidden;
  height: 100%;
  min-width: 0;
}

#editors::part(start),
#editors::part(end) {
  height: 100%;
  overflow: hidden;
  min-width: 0;
}

/* Ensure split panel slots fill their space and constrain content */
#editors [slot="start"],
#editors [slot="end"] {
  height: 100%;
  min-width: 0;
  overflow: hidden;
}

#pdf-viewer {
  width: 100%;
  height: 100%;
  border: 1px solid #ccc;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

iframe {
  width: 100%;
  flex-grow: 1;
  border: none;
  order: 1;
  /* Ensure iframe appears after headerbar and before statusbar */
}

#xml-editor {
  width: 100%;
  height: 100%;
  border: 1px solid #ccc;
  display: flex;
  /* Use flexbox to manage codemirror-container height */
  flex-direction: column;
}

#codemirror-container {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
}


sl-dialog {
  --header-spacing: var(--sl-spacing-small);
  --body-spacing: var(--sl-spacing-small);
  --footer-spacing: var(--sl-spacing-small);
}

/* Ensure dialog and drawer text is readable regardless of browser dark mode settings */
sl-dialog::part(header),
sl-dialog::part(body),
sl-dialog::part(footer),
sl-drawer::part(header),
sl-drawer::part(body),
sl-drawer::part(footer) {
  color: var(--sl-color-neutral-900);
}

/* Headerbar styling */
status-bar[name="headerbar"] {
  border-bottom: 1px solid #e0e0e0;
  background: #f5f5f5;
  min-height: 28px;
  display: flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 12px;
  order: 0;
  /* Ensure headerbar appears first */
}

/* Statusbar styling */
status-bar {
  border-top: 1px solid #e0e0e0;
  background: #f5f5f5;
  min-height: 28px;
  display: flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 12px;
  order: 2;
  /* Ensure statusbar appears after iframe */
}

.dialog-big {
  --width: 75vw;
}

.dialog-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dialog-row {
  display: flex block;
  flex-direction: row;
  gap: 10px;
}

sl-select::part(display-input) {
  caret-color: transparent !important;
  font-size: smaller;
}

sl-select::part(listbox) {
  width: max-content;
}

sl-option::part(label),
sl-menu-item::part(label) {
  font-size: smaller;
}

sl-button-group[label] {
  position: relative;
  /* To contain the absolute positioning of the :before pseudo-element */
}

.invalid-xml {
  background-color: #ff000030;
}

.editor-readonly {
  background-color: #f8e8b7ba;
}

sl-icon.rotating {
  animation: spin 1s linear infinite;
}

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

/* File Selection Drawer Tree Styling */

/* Font size of the tree item labels (always use a span) */
sl-tree-item span {
  font-size: smaller;
}

/* Collection items - light blue background */
sl-tree-item.collection-item::part(item) {
  background-color: var(--sl-color-blue-50);
  border-radius: var(--sl-border-radius-small);
  margin-bottom: 2px;
}

/* Gold section - light yellow/gold background */
sl-tree-item.gold-section::part(item) {
  background-color: var(--sl-color-amber-50);
  border-radius: var(--sl-border-radius-small);
  margin-bottom: 1px;
}

/* Versions section - light gray background */
sl-tree-item.versions-section {
  font-weight: 600;
}
sl-tree-item.versions-section::part(item) {
  background-color: var(--sl-color-neutral-100);
  border-radius: var(--sl-border-radius-small);
  margin-bottom: 1px;
}

/* PDF items - subtle green background */
sl-tree-item.pdf-item::part(item) {
  background-color: var(--sl-color-green-50);
  border-radius: var(--sl-border-radius-small);
  margin-bottom: 1px;
}

/* Gold and version items - normal styling with hover */
sl-tree-item.gold-item::part(item):hover,
sl-tree-item.version-item::part(item):hover {
  background-color: var(--sl-color-neutral-200);
}

/* Spacing between tree items */
sl-tree-item {
  margin-bottom: 2px;
}

/* Icon spacing */
sl-tree-item sl-icon[slot="prefix"] {
  margin-right: 0.5rem;
}

/* Backend plugins menu styling */
sl-menu[name="pluginsMenu"] small {
  display: block;
  padding: 0.5rem 1rem 0.25rem;
  color: var(--sl-color-neutral-500);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}



/* CodeMirror Merge View - Neutral Color Scheme */

/* Deleted chunks and lines - use blue tones instead of red */
.cm-deletedChunk {
  background-color: #e3f2fd !important; /* Light blue background */
}

.cm-deletedLine {
  background-color: #e3f2fd !important;
}

.cm-deletedLine del {
  background-color: #bbdefb !important; /* Slightly darker blue for del elements */
  text-decoration: line-through;
}

.cm-deletedText {
  background-color: #90caf9 !important; /* Even darker blue for deleted text */
}

/* Inserted/changed lines - use orange tones instead of green */
.cm-insertedLine {
  background-color: #fff3e0 !important; /* Light orange background */
}

.cm-changedLine ins,
.cm-insertedLine ins {
  background-color: #ffe0b2 !important; /* Slightly darker orange for ins elements */
  text-decoration: none;
}

.cm-changedText {
  background-color: #ffcc80 !important; /* Even darker orange for changed text */
}

/* Button styling to match neutral theme */
.cm-chunkButtons button[name="accept"],
.cm-chunkButtons button[name="reject"] {
  max-width: 10vw !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  color: white !important;
}

.cm-chunkButtons button[name="accept"] {
  background-color: #ff9800 !important; /* Orange (matches inserted/incoming) */
  border-color: #f57c00 !important;
}

.cm-chunkButtons button[name="reject"] {
  background-color: #2196f3 !important; /* Blue (matches deleted/current) */
  border-color: #1976d2 !important;
}