﻿/* Sankey Dashboard Styles */
/* Customer Segments Dashboard Styles */

/* ============================================
   Modern Dropdown Styles
   ============================================ */

/* Configure Button */
.btn-secondary {
  background-color: var(--myceo-surface-1);
  border: 1px solid #d1d5db;
  color: var(--myceo-text-secondary);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
  background-color: var(--myceo-surface-1);
  border-color: #9ca3af;
}

.btn-secondary:active {
  background-color: var(--myceo-surface-1);
}

/* Primary Button (Generate) */
.btn-primary {
  background-color: var(--myceo-surface-2);
  border: 1px solid var(--myceo-accent-blue);
  color: var(--myceo-text-primary);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
  background-color: var(--myceo-surface-2);
  border-color: var(--myceo-accent-blue);
}

.btn-primary:active {
  background-color: var(--myceo-surface-2);
}

/* Custom Dropdown Container */
.custom-dropdown {
  position: relative;
  display: inline-block;
}

/* Dropdown Button - Modern Style */
.dropdown-button {
  background-color: var(--myceo-surface-1);
  border: 1px solid #d1d5db;
  color: var(--myceo-text-secondary);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
  justify-content: space-between;
}

.dropdown-button:hover {
  background-color: var(--myceo-surface-1);
  border-color: #9ca3af;
}

.dropdown-button:active,
.dropdown-button.active {
  background-color: var(--myceo-surface-1);
  border-color: #6b7280;
}

/* Dropdown arrow */
.dropdown-button span:last-child {
  font-size: 12px;
  color: #6b7280;
  transition: transform 0.2s ease;
}

.dropdown-button.active span:last-child {
  transform: rotate(180deg);
}

/* Dropdown Content */
.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background-color: var(--myceo-surface-1);
  border: 1px solid var(--myceo-border-mid);
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 
              0 2px 4px -1px rgba(0, 0, 0, 0.06);
  min-width: 200px;
  z-index: 1000;
  padding: 4px;
  max-height: 300px;
  overflow-y: auto;
}

.dropdown-content.show {
  display: block;
}

/* Dropdown Items */
.dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.15s ease;
}

.dropdown-item:hover {
  background-color: var(--myceo-surface-1);
}

.dropdown-item label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--myceo-text-secondary);
  user-select: none;
}

/* Custom Checkbox Styling */
.dropdown-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--myceo-accent-blue);
  border-radius: 3px;
}

.dropdown-item input[type="checkbox"]:checked + span {
  font-weight: 500;
  color: var(--myceo-text-primary);
}

/* Scrollbar styling for dropdown */
.dropdown-content::-webkit-scrollbar {
  width: 6px;
}

.dropdown-content::-webkit-scrollbar-track {
  background: var(--myceo-surface-1);
  border-radius: 4px;
}

.dropdown-content::-webkit-scrollbar-thumb {
  background: var(--myceo-border-mid);
  border-radius: 4px;
}

.dropdown-content::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Chart Controls Container */
.chart-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Configuration Panel Styles */
.config-panel {
  display: none;
  background-color: var(--myceo-surface-1);
  border: 1px solid var(--myceo-border-mid);
  border-radius: 8px;
  padding: 20px;
  margin-top: 16px;
  margin-bottom: 16px;
}

.config-panel.show {
  display: block;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.config-section h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--myceo-text-primary);
  margin-bottom: 12px;
}

.config-field {
  margin-bottom: 12px;
}

.config-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--myceo-text-secondary);
  margin-bottom: 4px;
}

.config-field input[type="number"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  color: var(--myceo-text-primary);
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.config-field input[type="number"]:focus {
  outline: none;
  border-color: var(--myceo-accent-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.config-field input[type="number"]:hover {
  border-color: #9ca3af;
}

.config-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.error-message {
  color: var(--myceo-status-critical);
  font-size: 13px;
  padding: 8px 12px;
  background-color: rgba(225, 29, 72, 0.16);
  border: 1px solid #fecaca;
  border-radius: 6px;
  display: none;
}

.error-message.show {
  display: block;
}

/* Sankey Chart Container */
.sankey-chart-container {
  width: 100%;
  min-height: 600px;
  background-color: var(--myceo-surface-1);
  border-radius: 8px;
  padding: 20px;
}

/* Legend Styles */
.legend-section {
  margin-top: 24px;
  padding: 20px;
  background-color: var(--myceo-surface-1);
  border-radius: 8px;
  border: 1px solid var(--myceo-border-mid);
}

.legend-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--myceo-text-primary);
  margin-bottom: 16px;
}

.legend-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--myceo-text-secondary);
}

.legend-color {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* Info Section */
.info-section {
  margin-top: 24px;
  padding: 20px;
  background-color: var(--myceo-surface-1);
  border-radius: 8px;
  border: 1px solid #bfdbfe;
}

.info-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--myceo-accent-blue);
  margin-bottom: 12px;
}

.info-section p {
  font-size: 14px;
  color: var(--myceo-accent-blue);
  line-height: 1.6;
  margin-bottom: 12px;
}

.info-section ul {
  margin: 12px 0;
  padding-left: 24px;
}

.info-section li {
  font-size: 14px;
  color: var(--myceo-accent-blue);
  line-height: 1.6;
  margin-bottom: 8px;
}

.info-section strong {
  font-weight: 600;
  color: var(--myceo-accent-blue);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .dropdown-button {
    min-width: 120px;
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .chart-controls {
    gap: 8px;
  }
  
  .config-grid {
    grid-template-columns: 1fr;
  }
  
  .legend-items {
    grid-template-columns: 1fr;
  }
}

/* Additional Dashboard Styles */
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.chart-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--myceo-text-primary);
  margin: 0;
}

/* Full width chart container */
.chart-container.full-width {
  grid-column: 1 / -1;
}
/* Initialisation error. Was two inline colours chosen for a white page. */
.segments-init-error {
  background-color: rgba(251, 113, 133, 0.10);
  border: 1px solid rgba(251, 113, 133, 0.35);
  color: var(--myceo-ink-critical);                 /* 7.14:1 on this ground */
  padding: 0.85rem 1rem;
  margin-bottom: 1.5rem;
  border-radius: 8px;
  text-align: center;
  font-size: 0.9rem;
}
.segments-init-error-reason { color: var(--myceo-text-secondary); font-size: 0.82rem; }

/* ── Sankey labels follow the theme (MYC-12) ────────────────────────────────
 *
 * These were set inline by D3 as fill:#000000 with a white halo - drawn for a
 * white page, and inline styles beat any stylesheet, so the only way the theme
 * could reach them was to stop setting them in JS.
 *
 * The halo stays, because a label crossing a saturated flow needs separating
 * from it - but it is the page GROUND rather than white, so it does the same
 * job in both themes. paint-order:stroke draws it behind the glyph instead of
 * through it.
 */
.sankey-label {
  fill: var(--myceo-text-primary);
  stroke: var(--myceo-bg-core);
  stroke-width: 3px;
  paint-order: stroke;
}

/* The Sankey scales to its container rather than overflowing it. Paired with
   the viewBox and preserveAspectRatio="xMinYMid" set when the SVG is built -
   width alone would still let a stale layout width push the drawing sideways. */
#chart svg {
  width: 100%;
  height: auto;
  max-width: 100%;
  display: block;
}

/* ── Loading overlay (MYC-12) ───────────────────────────────────────────────
 * Was inline CSS: a 90%-opaque WHITE sheet with #333 text and an #e0e0e0
 * progress track. Inline styles cannot be reached by the theme, so on dark
 * mode it dropped a near-white slab over the whole dashboard on every reload.
 */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 10, 0.82);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}


.seg-loading-inner { text-align: center; width: 400px; max-width: 80vw; }
.seg-loading-inner .loading-spinner { width: 50px; height: 50px; margin: 0 auto 20px; }

.seg-loading-label {
  font-size: 16px;
  margin-bottom: 15px;
  color: var(--myceo-text-primary);
}

.seg-loading-track {
  width: 100%;
  height: 20px;
  border-radius: 10px;
  overflow: hidden;
  background-color: var(--myceo-surface-2);
}

.seg-loading-bar {
  width: 0%;
  height: 100%;
  background: var(--myceo-accent-blue);
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--myceo-bg-core);
  font-size: 12px;
  font-weight: 700;
}

.seg-loading-status {
  margin-top: 10px;
  font-size: 14px;
  color: var(--myceo-text-secondary);
}
