/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Two-Panel Layout Styles */

/* Details/Summary Elements - Collapsible Sections */
details summary {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
  border-radius: 0.375rem;
  padding: 0.5rem;
}

details summary:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

details[open] summary {
  margin-bottom: 0.5rem;
}

/* Scrollable Lists */
.golden-items-list {
  max-height: 600px;
  overflow-y: auto;
}

/* Nested Golden Item Expandable */
.golden-item-expandable {
  border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

.golden-item-expandable:last-child {
  border-bottom: none;
}

.golden-item-expandable summary {
  list-style: none;
  padding: 0.75rem 1rem;
}

.golden-item-expandable summary::-webkit-details-marker {
  display: none;
}

.golden-item-expandable summary::before {
  content: '▶';
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.golden-item-expandable[open] summary::before {
  transform: rotate(90deg);
}

.golden-item-expandable summary:hover {
  background-color: rgba(13, 110, 253, 0.05);
}

/* Assets List within Golden Items */
.assets-list {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.assets-list .list-group-item {
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-left: none;
  border-right: none;
}

.assets-list .list-group-item:first-child {
  border-top: none;
}

/* Code Content Areas */
.metadata-schema-content,
.prompt-content,
.expected-output-content {
  max-height: 600px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Asset Preview */
.asset-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  background-color: #f8f9fa;
  border-radius: 0.375rem;
  padding: 1rem;
}

.asset-preview img {
  max-height: 70vh;
  object-fit: contain;
}

.asset-preview embed {
  border: 1px solid rgba(0, 0, 0, 0.125);
}

/* Sticky Left Panel on Desktop */
@media (min-width: 992px) {
  .sticky-top {
    position: sticky;
    top: 20px;
    z-index: 1020;
  }
}

/* Mobile Responsive Adjustments */
@media (max-width: 991px) {
  /* Remove sticky behavior on mobile */
  .sticky-top {
    position: static;
  }

  /* Start with details closed on mobile for better UX */
  details.card {
    /* Let users open sections as needed */
  }

  /* Ensure detail panel is visible */
  turbo-frame#detail_panel {
    min-height: 300px;
  }

  /* Adjust scrollable list height on mobile */
  .golden-items-list {
    max-height: 300px;
  }
}

/* List Group Item Hover Effects */
.list-group-item-action:hover {
  background-color: rgba(13, 110, 253, 0.05);
  border-color: rgba(13, 110, 253, 0.2);
}

.list-group-item-action:active {
  background-color: rgba(13, 110, 253, 0.1);
}

/* Smooth Transitions */
.card {
  transition: box-shadow 0.2s ease;
}

.list-group-item {
  transition: all 0.2s ease;
}

/* Loading State for Turbo Frame */
turbo-frame[busy] {
  opacity: 0.6;
  pointer-events: none;
}

/* Accessibility Improvements */
summary:focus {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

.list-group-item-action:focus {
  outline: 2px solid #0d6efd;
  outline-offset: -2px;
}

/* Green Button with Hover Effect */
.btn-outline-green {
  background-color: transparent;
  color: rgb(135, 230, 75);
  border: 1px solid rgb(135, 230, 75);
  transition: all 0.2s ease;
}

.btn-outline-green:hover {
  background-color: rgb(135, 230, 75);
  color: rgb(26, 66, 0);
  border-color: rgb(135, 230, 75);
}

/* Prompt Diff Styles */

/* Selected prompt highlighting */
.list-group-item.active {
  background-color: rgba(13, 110, 253, 0.15) !important;
  border-color: rgba(13, 110, 253, 0.3) !important;
  color: inherit !important;
}

/* Diff output container - unified view */
.diff-output {
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: normal;
  overflow-x: auto;
  padding: 1rem;
  background-color: #f8f9fa;
  border-radius: 0.375rem;
  list-style: none;
  margin: 0;
}

/* Remove bullets from diff output */
.diff-output ul,
.diff-output li {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Diffy HTML output styling */
.diff-output ins,
.diff-output del,
.diff-output li {
  text-decoration: none;
  display: block;
  list-style: none;
  margin: 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.diff-output ins {
  background-color: #d4edda;
  color: #155724;
  padding: 0.125rem 0.5rem 0.125rem 0;
}

.diff-output del {
  background-color: #f8d7da;
  color: #721c24;
  padding: 0.125rem 0.5rem 0.125rem 0;
}

.diff-output .unchanged,
.diff-output li:not(ins):not(del) {
  padding: 0.125rem 0.5rem;
  color: #6c757d;
  background-color: transparent;
}

/* Side-by-side diff view */
.diff-side-by-side {
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  margin: 0;
  min-height: 400px;
  max-height: 600px;
  overflow-y: auto;
  overflow-x: auto;
}

.diff-line {
  padding: 0.25rem 1rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  min-height: 1.6em;
}

.diff-line.diff-unchanged {
  background-color: #ffffff;
  color: #212529;
}

.diff-line.diff-removed {
  background-color: #fdd;
  color: #721c24;
}

.diff-line.diff-added {
  background-color: #dfd;
  color: #155724;
}

.diff-line.diff-empty {
  background-color: #f8f9fa;
}

.diff-header {
  font-size: 0.875rem;
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Checkbox styling in prompt list */
.form-check-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Prompt list item with checkbox layout */
.list-group-item.d-flex.align-items-center {
  padding-left: 0.75rem;
}

.list-group-item .form-check {
  margin-bottom: 0;
}

/* Ensure link in prompt list item doesn't break layout */
.list-group-item a.text-decoration-none {
  color: inherit;
}

.list-group-item a.text-decoration-none:hover {
  color: inherit;
}
