/* QueryRenderer Component Styles */

.query-renderer {
  margin-bottom: 2px;
}

.query-renderer-main {
  display: flex;
  align-items: flex-start;
}

.query-renderer-content {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 4px;
  min-height: 20px;
  padding: 1px 0;
}

.query-renderer-label {
  color: #5c7080;
  font-size: 12px;
  white-space: nowrap;
  font-weight: 500;
}

.query-renderer-toggle {
  margin-left: 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.query-renderer-toggle:hover {
  opacity: 1;
}

.query-renderer-details {
  margin-top: 4px;
  padding: 4px 8px;
  background-color: #f5f8fa;
  border-left: 2px solid #e1e8ed;
  border-radius: 2px;
  font-size: 11px;
}

.query-renderer-formal {
  margin-bottom: 8px;
  color: #5c7080;
}

.query-renderer-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.query-metadata-item {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #738694;
  font-size: 11px;
}

/* Two-Section Composition UI */
.composition-mode {
  border: 1px solid #e1e8ed;
  border-radius: 4px;
  background-color: #fafbfc;
  padding: 6px;
  margin-bottom: 8px;
}

.active-query-section,
.loaded-query-section {
  margin-bottom: 8px;
  padding: 6px;
  border-radius: 3px;
}

.active-query-section {
  background-color: #ebf1f5;
  border-left: 4px solid #2965cc;
}

.loaded-query-section {
  background-color: #f5f8fa;
  border-left: 4px solid #8a9ba8;
}

.section-header {
  margin: 0 0 4px 0;
  font-size: 12px;
  font-weight: 600;
  color: #182026;
  display: flex;
  align-items: center;
  gap: 3px;
}

.section-header small {
  font-weight: 400;
  color: #5c7080;
  font-size: 10px;
}

.composition-actions {
  margin-top: 4px;
  padding: 4px 6px;
  background-color: #ffffff;
  border-radius: 2px;
  border: 1px dashed #d3d8de;
}

.composition-hint {
  color: #5c7080;
  font-style: italic;
  font-size: 11px;
}

/* Composed Query Display */
.composed-query-display,
.simple-query-display {
  margin-bottom: 6px;
}

.composed-steps {
  margin-left: 8px;
}

.composed-series {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.query-with-plus {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.query-plus {
  font-size: 12px;
  font-weight: bold;
  color: #5c7080;
  margin-top: 2px;
  flex-shrink: 0;
}

.query-plus-content {
  flex: 1;
}

.query-step {
  margin-bottom: 4px;
  padding: 4px 6px;
  background-color: #f5f8fa;
  border-radius: 2px;
  border-left: 2px solid #d3d8de;
}

.page-selection {
  margin-bottom: 4px;
  padding: 4px 6px;
  background-color: #fef5e7;
  border-radius: 2px;
  border-left: 2px solid #ffb366;
}

.page-selection-header {
  margin-bottom: 2px;
  color: #a66321;
  font-size: 11px;
}

.page-selection-content {
  font-size: 11px;
  color: #5c7080;
}

/* User query styling */
.query-manager-query-content.user-query {
  border-left: 4px solid #137cbd;
  background: rgba(19, 124, 189, 0.1);
  padding: 6px 8px;
  margin-bottom: 4px;
}

/* Dark theme support */
.bp3-dark .query-renderer-details {
  background-color: #30404d;
  border-left-color: #5c7080;
}

.bp3-dark .query-renderer-label {
  color: #a7b6c2;
}

.bp3-dark .query-renderer-formal {
  color: #a7b6c2;
}

.bp3-dark .query-metadata-item {
  color: #8a9ba8;
}

.bp3-dark .composition-mode {
  background-color: #30404d;
  border-color: #5c7080;
}

.bp3-dark .active-query-section {
  background-color: #394b59;
  border-left-color: #48aff0;
}

.bp3-dark .loaded-query-section {
  background-color: #30404d;
  border-left-color: #a7b6c2;
}

.bp3-dark .section-header {
  color: #f5f8fa;
}

.bp3-dark .composition-actions {
  background-color: #394b59;
  border-color: #5c7080;
}

.bp3-dark .query-step {
  background-color: #394b59;
  border-left-color: #5c7080;
}

.bp3-dark .page-selection {
  background-color: #3d3613;
  border-left-color: #d69e2e;
}

.bp3-dark .query-plus {
  color: #a7b6c2;
}

.bp3-dark .query-manager-query-content.user-query {
  border-left: 4px solid #48aff0;
  background: rgba(72, 175, 240, 0.15);
}

/* Query preview in save dialog */
.current-query-preview {
  margin: 10px 0;
  padding: 8px;
  background: rgba(19, 124, 189, 0.05);
  border-radius: 3px;
}

.bp3-dark .current-query-preview {
  background: rgba(72, 175, 240, 0.08);
}

/* Unified Query Progress Tracker */
.query-progress-tracker {
  padding: 12px 14px;
  margin: 8px 12px;
  background: linear-gradient(135deg, #fef5e7 0%, #fdebd0 100%);
  border-left: 4px solid #d9822b;
  border-radius: 4px;
  font-size: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  animation: fadeInSlide 0.3s ease-out;
}

.query-progress-message {
  font-size: 13px;
  font-weight: 500;
  color: #a66321;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(217, 130, 43, 0.2);
}

.query-progress-message:only-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.query-progress-title {
  font-weight: 600;
  margin-bottom: 8px;
  margin-top: 4px;
  color: #bf7326;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.query-progress-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  align-items: center;
}

.query-progress-status {
  flex: 1;
  color: #5c4525;
  font-family: "SF Mono", "Monaco", "Inconsolata", "Roboto Mono", monospace;
}

.query-progress-status strong {
  color: #a66321;
  font-weight: 600;
  min-width: 50px;
  display: inline-block;
}

.query-progress-count {
  margin-left: 12px;
  padding: 2px 8px;
  background-color: rgba(217, 130, 43, 0.15);
  border-radius: 3px;
  color: #a66321;
  font-weight: 600;
  font-size: 11px;
}

.bp3-dark .query-progress-tracker {
  background: linear-gradient(135deg, #3d3325 0%, #332a1f 100%);
  border-left-color: #d9822b;
}

.bp3-dark .query-progress-message {
  color: #ffa940;
  border-bottom-color: rgba(217, 130, 43, 0.3);
}

.bp3-dark .query-progress-title {
  color: #ffa940;
}

.bp3-dark .query-progress-status {
  color: #d0b694;
}

.bp3-dark .query-progress-status strong {
  color: #ffa940;
}

.bp3-dark .query-progress-count {
  background-color: rgba(217, 130, 43, 0.25);
  color: #ffa940;
}

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

/* Query Composer Collapsible Header */
.query-composer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 8px;
  border-bottom: 1px solid #e1e8ed;
  user-select: none;
  transition: background-color 0.2s;
}

/* .query-composer-header:hover {
  background: #ebf1f5;
} */

.query-composer-header h6 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #394b59;
}

.bp3-dark .query-composer-header {
  background: #30404d;
  border-bottom-color: #5c7080;
}

.bp3-dark .query-composer-header:hover {
  background: #394b59;
}

.bp3-dark .query-composer-header h6 {
  color: #d8e1e8;
}

/* Editable Query Text */
.editable-query-view {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.editable-query-text {
  flex: 1;
  color: #182026;
  font-size: 13px;
}

.editable-query-edit-btn {
  opacity: 0;
  transition: opacity 0.2s;
}

.editable-query-view:hover .editable-query-edit-btn {
  opacity: 1;
}

.editable-query-editing {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.editable-query-input {
  flex: 1;
}

.editable-query-actions {
  display: flex;
  gap: 2px;
  margin-right: 4px;
}

.bp3-dark .editable-query-text {
  color: #f5f8fa;
}
