/* Wrapper for fixed positioning with flexbox */
.sage-ai-state-display-container {
  position: fixed !important;
  bottom: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.sage-ai-llm-state-widget {
  order: 2;
  pointer-events: auto;
  margin: 0 17px;
  /* Remove transform since we're using flexbox layout */
}

.sage-ai-input-spacer {
  order: 3;
  flex-shrink: 0;
}

/* LLM State Display - positioned above the chat input */
.sage-ai-llm-state-display {
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  padding: 8px;
  padding-bottom: 18px;
  margin-bottom: 0;
  background-color: var(--jp-layout-color1);
  border-radius: 8px;
  font-size: 13px;
  color: var(--jp-ui-font-color1);
  box-shadow: 0 2px 4px rgb(0 0 0 / 5%);
  transition: all 0.2s ease-in-out;
  /*transform: translateY(-10px);*/
  border: 1px solid var(--jp-border-color2);
  position: relative;
  z-index: 0; /* Ensure it stays above other content */
}

.sage-ai-generating,
.sage-ai-using-tool {
  justify-content: space-between !important;
}

.sage-ai-llm-state-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sage-ai-waiting-for-user {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: transparent;
  border: 1px dashed #d3a500;
}

.sage-ai-llm-state-text {
  color: var(--jp-ui-font-color2);
  font-style: normal;
  font-weight: 500;
  font-size: var(--jp-ui-font-size1);
}

/* Ensure the blob loader works in this context */
.sage-ai-llm-state-display .sage-ai-blob-loader {
  flex-shrink: 0;
}

/* Diff State Styles */
.sage-ai-diff-state {
  display: flex !important;
  flex-direction: column;
  align-items: stretch !important;
  justify-content: flex-start !important;
}

.sage-ai-diff-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--jp-border-color2);
}

.sage-ai-diff-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--jp-ui-font-color1);
}

.sage-ai-diff-icon {
  font-size: 16px;
}

.sage-ai-diff-text {
  font-size: 14px;
}

.sage-ai-diff-bulk-actions {
  display: flex;
  gap: 6px;
}

.sage-ai-diff-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  margin-top: 6px;
}

.sage-ai-diff-decision {
  margin-left: 4px;
  font-size: 9px;
}

.sage-ai-llm-state-stop-button {
  background-color: var(--jp-layout-color2);
  color: var(--jp-ui-font-color1);
  font-size: var(--jp-ui-font-size1);
  font-style: normal;
  font-weight: 500;
  line-height: 160%; /* 19.2px */
  padding: 2px 6px;
  box-shadow: none;
  border: none;
  cursor: pointer;
}

.sage-ai-llm-state-stop-button:hover {
  background-color: var(--jp-layout-color1);
  color: var(--jp-ui-font-color0);
}

.sage-ai-diff-decision-approved {
  color: #28a745;
}

.sage-ai-diff-decision-rejected {
  color: #dc3545;
}

.sage-ai-diff-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  border: 1px solid var(--jp-border-color2);
  border-radius: 6px;
  font-size: 12px;
  transition: all 0.2s ease;
  position: relative;
  z-index: 0;
}

.sage-ai-diff-item::before {
  content: '';
  position: absolute;
  inset: 0; /* shorthand for top/right/bottom/left: 0 */
  background: var(--jp-layout-color1);
  opacity: 1; /* initial opacity */
  transition: opacity 0.25s ease;
  z-index: -1; /* behind the box's content */
  border-radius: 6px;
}

.sage-ai-diff-item:hover {
  cursor: pointer;
}

.sage-ai-diff-item:hover::before {
  opacity: 0.8; /* hover opacity */
}

.sage-ai-diff-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sage-ai-diff-operation {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  flex-shrink: 0;
}

.sage-ai-diff-changes {
  display: flex;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  align-items: center;
}

.fix_run_cell_size {
  height: 16px;
}

.sage-ai-diff-summary {
  width: fit-content;
}

.sage-ai-diff-added {
  color: #28a745;
}

.sage-ai-diff-removed {
  color: #dc3545;
}

.sage-ai-diff-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.sage-ai-diff-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  transition: all 0.2s ease;
  background-color: var(--jp-layout-color2);
  color: var(--jp-ui-font-color2);
}

.sage-ai-diff-approve {
  color: #28a745;
}

.sage-ai-diff-approve:hover {
  background-color: #28a745;
  color: white;
}

.sage-ai-diff-reject {
  color: #dc3545;
}

.sage-ai-diff-reject:hover {
  color: white;
}

.sage-ai-diff-approve-all,
.sage-ai-diff-reject-all {
  padding: 2px 6px;
  width: auto;
  height: auto;
  border-radius: 5px !important;
  font-size: var(--jp-ui-font-size1);
  font-weight: 500;
  line-height: 160%;
}

.sage-ai-diff-approve-all {
  color: var(--jp-ui-inverse-font-color0);
  background-color: var(--jp-inverse-layout-color2);
}

.sage-ai-diff-approve-all:hover {
  color: var(--jp-ui-inverse-font-color1);
  background-color: var(--jp-inverse-layout-color3);
}

.sage-ai-diff-reject-all {
  background-color: var(--jp-layout-color0);
  color: var(--jp-ui-font-color1);
}

.sage-ai-diff-reject-all:hover {
  color: var(--jp-ui-font-color0);
  background-color: var(--jp-layout-color1);
}

/* Generating state specific styles */
.sage-ai-generating {
  display: flex !important;
}

/* Using tool state specific styles */
.sage-ai-using-tool {
  display: flex !important;
}

.sage-ai-tool-loader {
  width: 16px;
  height: 16px;
  border: 2px solid var(--jp-border-color2);
  border-top: 2px solid var(--jp-brand-color1);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  flex-shrink: 0;
}

.sage-ai-tool-icon-container {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sage-ai-tool-icon-container svg {
  width: 16px;
  height: 16px;
  fill: var(--jp-brand-color1);
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Ensure the tool state has the same styling as generating */
.sage-ai-using-tool .sage-ai-llm-state-text {
  color: var(--jp-ui-font-color2);
  font-style: italic;
  font-weight: 500;
}

/* Collapsible Diff Summary Bar */
.sage-ai-diff-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background-color 0.2s ease;
  user-select: none;
}

.sage-ai-diff-menu-icon {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.sage-ai-diff-summary-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.sage-ai-diff-cell-count {
  font-weight: 600;
  color: var(--jp-ui-font-color1);
  font-size: var(--jp-ui-font-size1);
}

.sage-ai-diff-cell-count-info {
  display: flex;
  gap: 4px;
  margin: 0;
}

.sage-ai-diff-added-count {
  color: #28a745;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
}

.sage-ai-diff-removed-count {
  color: #dc3545;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
}

.sage-ai-diff-expand-icon {
  color: var(--jp-ui-font-color2);
  font-size: 12px;
  margin-left: auto;
  margin-right: 8px;
  transition: transform 0.2s ease;
}

.sage-ai-diff-summary-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Hide actions on hover for diff items when showActionsOnHover is true */
.sage-ai-diff-item-hover-actions .sage-ai-diff-actions {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sage-ai-diff-item-hover-actions:hover .sage-ai-diff-actions {
  opacity: 1;
}

/* Button container for LLM state display */
.sage-ai-llm-state-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Run/Reject buttons for notebook-run_cell tool */
.sage-ai-llm-state-run-button,
.sage-ai-llm-state-reject-button {
  padding: 4px 8px;
  border: none;
  border-radius: 8px !important;
  cursor: pointer;
  font-size: var(--jp-ui-font-size1);
  font-weight: 500;
  line-height: 160%;
  transition: all 0.2s ease;
  box-shadow: none;
}

.sage-ai-llm-state-run-button {
  background-color: var(--jp-inverse-layout-color0);
  color: var(--jp-ui-inverse-font-color0);
}

.sage-ai-llm-state-run-button:hover {
  background-color: var(--jp-inverse-layout-color2);
  color: var(--jp-ui-inverse-font-color1);
}

.sage-ai-llm-state-reject-button {
  background-color: var(--jp-layout-color0);
  color: var(--jp-ui-font-color1);
}

.sage-ai-llm-state-reject-button:hover {
  background-color: var(--jp-layout-color1);
  color: var(--jp-ui-font-color0);
}
