/* ==========================================================================
   AUTO COMBINE STUDIO (Dedicated Multi-Dataset Automated Combine)
   ========================================================================== */
.combine-studio-wrapper {
  padding: 20px 28px;
  max-width: 1440px;
  margin: 0 auto;
}

.combine-studio-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 20px;
  background: #FFFFFF;
  border: 1px solid var(--studio-border, #E2E8F0);
  border-radius: var(--studio-radius-lg, 8px);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  margin-bottom: 20px;
}

.combine-header-left {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.btn-combine-back {
  margin-top: 4px;
}

.combine-header-divider {
  width: 1px;
  height: 48px;
  background: var(--studio-border, #E2E8F0);
}

.combine-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.combine-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--studio-text-main, #0F172A);
  margin: 0;
  letter-spacing: -0.3px;
}

.combine-badge-ai {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2.5px 8px;
  background: linear-gradient(135deg, #DC2626 0%, #991B1B 100%);
  color: #FFFFFF;
  border-radius: 4px;
  text-transform: uppercase;
}

.combine-badge-sub {
  font-size: 10px;
  font-weight: 700;
  padding: 2.5px 7px;
  background: #F1F5F9;
  color: #475569;
  border-radius: 4px;
  letter-spacing: 0.3px;
}

.combine-subtitle {
  font-size: 12.5px;
  color: var(--studio-text-muted, #64748B);
  margin: 6px 0 0 0;
  line-height: 1.45;
  max-width: 780px;
}

.combine-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Upload & Inputs Card */
.combine-inputs-card {
  background: #FFFFFF;
  border: 1px solid var(--studio-border, #E2E8F0);
  border-radius: var(--studio-radius-lg, 8px);
  padding: 24px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  margin-bottom: 24px;
}

.combine-section-heading {
  margin-bottom: 18px;
}

.combine-section-heading .heading-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  color: #DC2626;
  background: #FEF2F2;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.combine-section-heading h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--studio-text-main, #0F172A);
  margin: 0 0 4px 0;
}

.combine-section-heading p {
  font-size: 12px;
  color: var(--studio-text-muted, #64748B);
  margin: 0;
}

.combine-dropzone {
  border: 2px dashed #CBD5E1;
  border-radius: var(--studio-radius-lg, 8px);
  background: #F8FAFC;
  padding: 28px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.combine-dropzone:hover,
.combine-dropzone.drag-over {
  border-color: #DC2626;
  background: #FEF2F2;
}

.dropzone-icon {
  color: #DC2626;
}

.dropzone-text strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--studio-text-main, #0F172A);
}

.dropzone-text span {
  font-size: 11.5px;
  color: var(--studio-text-muted, #64748B);
}

.dropzone-btn-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.combine-ws-select {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--studio-radius-sm, 4px);
  border: 1px solid var(--studio-border, #E2E8F0);
  background: #FFFFFF;
  color: var(--studio-text-main, #0F172A);
  cursor: pointer;
}

/* Staged Dataset Cards */
.combine-datasets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.combine-empty-datasets {
  grid-column: 1 / -1;
  text-align: center;
  padding: 18px;
  background: #F8FAFC;
  border: 1px solid var(--studio-border, #E2E8F0);
  border-radius: var(--studio-radius-md, 6px);
  color: var(--studio-text-muted, #64748B);
  font-size: 12px;
}

.combine-file-card {
  background: #FFFFFF;
  border: 1px solid var(--studio-border, #E2E8F0);
  border-left: 4px solid #DC2626;
  border-radius: var(--studio-radius-md, 6px);
  padding: 14px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.combine-file-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
}

.file-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.file-badge {
  font-size: 9.5px;
  font-weight: 800;
  padding: 2px 6px;
  background: #F1F5F9;
  color: var(--studio-text-main, #0F172A);
  border-radius: 3px;
  letter-spacing: 0.5px;
}

.file-remove-btn {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--studio-text-sub, #94A3B8);
  cursor: pointer;
  padding: 0 4px;
}
.file-remove-btn:hover {
  color: #DC2626;
}

.file-card-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--studio-text-main, #0F172A);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--studio-text-muted, #64748B);
  margin-top: 4px;
}

.file-card-type {
  font-weight: 700;
  color: #DC2626;
}

/* Action Bar */
.combine-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--studio-border, #E2E8F0);
}

.combine-dataset-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--studio-text-main, #0F172A);
  margin-right: 12px;
}

.combine-auto-notice {
  font-size: 11.5px;
  color: var(--studio-text-muted, #64748B);
}

.btn-run-auto-combine {
  padding: 10px 22px !important;
  font-size: 13.5px !important;
  gap: 8px !important;
}

.combine-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Hero Decision Card */
.combine-hero-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px;
  border-radius: var(--studio-radius-lg, 8px);
  margin-bottom: 20px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
  position: relative;
  overflow: hidden;
}

.combine-hero-card.hero-append {
  background: linear-gradient(135deg, #FFFFFF 0%, #F0FDF4 100%);
  border: 1.5px solid #BBF7D0;
}

.combine-hero-card.hero-join {
  background: linear-gradient(135deg, #FFFFFF 0%, #EEF2FF 100%);
  border: 1.5px solid #C7D2FE;
}

.hero-decision-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.hero-append .hero-decision-tag {
  background: #DCFCE7;
  color: #15803D;
}

.hero-join .hero-decision-tag {
  background: #E0E7FF;
  color: #4338CA;
}

.hero-tag-bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.hero-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--studio-text-main, #0F172A);
  margin: 0 0 8px 0;
  letter-spacing: -0.2px;
}

.hero-reason {
  font-size: 13px;
  color: var(--studio-text-main, #0F172A);
  line-height: 1.5;
  margin: 0 0 16px 0;
  max-width: 820px;
}

.hero-pill-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-stat-pill {
  background: #FFFFFF;
  border: 1px solid var(--studio-border, #E2E8F0);
  border-radius: 6px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.hero-stat-pill .pill-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--studio-text-muted, #64748B);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.hero-stat-pill .pill-value {
  font-size: 15px;
  font-weight: 800;
  color: var(--studio-text-main, #0F172A);
  margin-top: 1px;
}

.hero-confidence-gauge {
  padding-left: 20px;
}

.gauge-circle {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 4px solid #16A34A;
  background: #FFFFFF;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
}

.gauge-circle.medium {
  border-color: #EAB308;
}

.gauge-number {
  font-size: 20px;
  font-weight: 900;
  color: var(--studio-text-main, #0F172A);
}

.gauge-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--studio-text-muted, #64748B);
  text-transform: uppercase;
}

/* Result Nav Tabs */
.combine-result-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.combine-result-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  color: var(--studio-text-muted, #64748B);
  background: #FFFFFF;
  border: 1px solid var(--studio-border, #E2E8F0);
  border-radius: var(--studio-radius-md, 6px);
  cursor: pointer;
  transition: all 0.15s ease;
}

.combine-result-tab:hover {
  background: var(--studio-surface, #F8FAFC);
  color: var(--studio-text-main, #0F172A);
}

.combine-result-tab.active {
  background: var(--studio-text-main, #0F172A);
  color: #FFFFFF;
  border-color: var(--studio-text-main, #0F172A);
}

/* Table Preview Card */
.combine-preview-card {
  padding: 20px;
  background: #FFFFFF;
  border: 1px solid var(--studio-border, #E2E8F0);
  border-radius: var(--studio-radius-lg, 8px);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.preview-card-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}

.preview-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.combine-search-input {
  max-width: 320px;
  width: 100%;
  padding: 8px 12px;
  font-size: 12.5px;
  border: 1px solid var(--studio-border, #E2E8F0);
  border-radius: var(--studio-radius-sm, 4px);
  outline: none;
}
.combine-search-input:focus {
  border-color: #DC2626;
}

.preview-rows-badge {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--studio-text-muted, #64748B);
  background: #F1F5F9;
  padding: 4px 10px;
  border-radius: 4px;
}

.preview-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.combine-table-scroll {
  max-height: 480px;
  overflow: auto;
  border: 1px solid var(--studio-border, #E2E8F0);
  border-radius: var(--studio-radius-sm, 4px);
}

.combine-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.combine-data-table thead th {
  position: sticky;
  top: 0;
  background: #F8FAFC;
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--studio-text-main, #0F172A);
  border-bottom: 2px solid var(--studio-border, #E2E8F0);
  white-space: nowrap;
  z-index: 2;
}

.combine-data-table tbody td {
  padding: 8px 14px;
  border-bottom: 1px solid #F1F5F9;
  color: var(--studio-text-main, #0F172A);
  white-space: nowrap;
}

.combine-data-table tbody tr:hover td {
  background: #F8FAFC;
}

.cell-null {
  color: #94A3B8;
  font-style: italic;
  font-size: 11px;
}

.combine-pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--studio-border, #E2E8F0);
}

.pagination-info {
  font-size: 11.5px;
  color: var(--studio-text-muted, #64748B);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-current-page {
  font-size: 12px;
  font-weight: 700;
  color: var(--studio-text-main, #0F172A);
  padding: 0 4px;
}

/* Process Details & Reasoning Layout */
.combine-details-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}

@media (max-width: 1000px) {
  .combine-details-layout {
    grid-template-columns: 1fr;
  }
}

.combine-timeline-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.timeline-step-card {
  background: #FFFFFF;
  border: 1px solid var(--studio-border, #E2E8F0);
  border-radius: var(--studio-radius-lg, 8px);
  padding: 18px 20px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  position: relative;
}

.step-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.step-badge-num {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #FFFFFF;
  background: var(--studio-text-main, #0F172A);
  padding: 3px 8px;
  border-radius: 4px;
}

.step-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--studio-text-main, #0F172A);
  margin: 0;
  flex: 1;
}

.step-status-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 3px;
}

.step-status-tag.status-completed {
  background: #DCFCE7;
  color: #166534;
}

.step-description {
  font-size: 12.5px;
  color: var(--studio-text-main, #0F172A);
  line-height: 1.5;
  margin: 0;
}

/* Metrics Sidebar */
.combine-metrics-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.metric-breakdown-card {
  background: #FFFFFF;
  border: 1px solid var(--studio-border, #E2E8F0);
  border-radius: var(--studio-radius-lg, 8px);
  padding: 18px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.breakdown-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--studio-text-main, #0F172A);
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--studio-border, #E2E8F0);
  letter-spacing: -0.2px;
}

.source-ds-item {
  margin-bottom: 14px;
}

.source-ds-name {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  margin-bottom: 6px;
}

.source-ds-name strong {
  color: var(--studio-text-main, #0F172A);
}

.source-ds-name span {
  font-size: 10.5px;
  color: var(--studio-text-muted, #64748B);
}

.source-cols-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.col-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  border-radius: 3px;
  padding: 2px 6px;
}

.col-chip-name {
  font-weight: 600;
  color: var(--studio-text-main, #0F172A);
}

.col-chip-type {
  font-size: 9px;
  color: #DC2626;
  font-weight: 700;
}

.best-key-highlight {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
}

.best-key-label {
  font-size: 10px;
  font-weight: 700;
  color: #166534;
  text-transform: uppercase;
}

.best-key-cols {
  font-size: 13px;
  font-weight: 800;
  color: var(--studio-text-main, #0F172A);
  margin: 4px 0;
}

.best-key-meta {
  font-size: 11px;
  color: #15803D;
}

.candidate-key-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 4px 0;
  border-bottom: 1px dashed #E2E8F0;
}

.cand-cols {
  color: var(--studio-text-main, #0F172A);
  font-weight: 600;
}

.cand-overlap {
  color: #16A34A;
  font-weight: 700;
}

.adjustments-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 11.5px;
  color: var(--studio-text-main, #0F172A);
}

.adjustments-list li {
  padding: 4px 0;
  line-height: 1.4;
  border-bottom: 1px solid #F1F5F9;
}

.integrity-metric-row {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  padding: 6px 0;
  border-bottom: 1px solid #F1F5F9;
  color: var(--studio-text-muted, #64748B);
}

.integrity-metric-row strong,
.integrity-metric-row span:last-child {
  color: var(--studio-text-main, #0F172A);
  font-weight: 700;
}

/* Slide-over Combine History Drawer */
.combine-history-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 420px;
  height: 100vh;
  background: #FFFFFF;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  z-index: 1001;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.combine-history-drawer.open {
  right: 0;
}

.history-drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: none;
}

.history-drawer-backdrop.open {
  display: block;
}

.history-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--studio-border, #E2E8F0);
}

.history-drawer-header h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--studio-text-main, #0F172A);
  margin: 0;
}

.drawer-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--studio-text-sub, #94A3B8);
  cursor: pointer;
  line-height: 1;
}

.history-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.history-item-card {
  background: #F8FAFC;
  border: 1px solid var(--studio-border, #E2E8F0);
  border-radius: var(--studio-radius-md, 6px);
  padding: 14px;
  margin-bottom: 12px;
  transition: all 0.15s ease;
}

.history-item-card:hover {
  background: #FFFFFF;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
  border-color: var(--studio-border-strong, #CBD5E1);
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.history-badge {
  font-size: 9.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

.history-badge.badge-append {
  background: #DCFCE7;
  color: #15803D;
}

.history-badge.badge-join {
  background: #E0E7FF;
  color: #4338CA;
}

.history-date {
  font-size: 10.5px;
  color: var(--studio-text-muted, #64748B);
}

.history-ds-names {
  font-size: 13px;
  font-weight: 700;
  color: var(--studio-text-main, #0F172A);
  margin-bottom: 4px;
}

.history-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--studio-text-muted, #64748B);
  margin-bottom: 8px;
}

.history-conf {
  font-weight: 700;
  color: #16A34A;
}

.history-reason-preview {
  font-size: 11.5px;
  color: var(--studio-text-main, #0F172A);
  line-height: 1.4;
  margin: 0 0 10px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-card-actions {
  display: flex;
  gap: 8px;
}

.history-card-actions button {
  font-size: 11px !important;
  padding: 4px 10px !important;
}
