/* Ported 1:1 from the React app's CSS files. */
:root {
  color-scheme: dark;

  --surface-1: #121212;
  --surface-2: #181818;
  --surface-3: #232323;
  --surface-4: #2e2e2e;
  --border: #2f2f2f;

  --text: #ffffff;
  --text-muted: #b3b3b3;
  --text-faint: #7a7a7a;

  --accent: #1ed760;
  --accent-hover: #22e065;
  --danger: #e64c4c;

  font-family: 'Helvetica Neue', Arial, system-ui, sans-serif;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  height: 100%;
}

body {
  margin: 0;
  background: var(--surface-1);
  color: var(--text);
}

a {
  color: inherit;
}

input,
select,
textarea,
button {
  font-family: inherit;
}

.page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 4rem 1rem;
  color: var(--text-muted);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--surface-4);
  border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}

/* --- components/auth/LoginButton.css --- */
.login-panel {
  max-width: 28rem;
  margin: 4rem auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-start;
  padding: 2rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.login-panel__title {
  margin: 0;
  font-size: 1.6rem;
}

.login-panel__subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0;
  line-height: 1.5;
}

.login-panel__warning {
  background: rgba(230, 180, 60, 0.12);
  color: #e6b43c;
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  font-size: 0.8rem;
  line-height: 1.4;
}

/* --- components/common/Button.css --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--sm {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}

.btn--md {
  font-size: 0.9rem;
  padding: 0.55rem 1rem;
}

.btn--primary {
  background: var(--accent);
  color: #06210f;
}
.btn--primary:not(:disabled):hover {
  background: var(--accent-hover);
}

.btn--secondary {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border);
}
.btn--secondary:not(:disabled):hover {
  background: var(--surface-4);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn--ghost:not(:disabled):hover {
  background: var(--surface-3);
  color: var(--text);
}

.btn--danger {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}
.btn--danger:not(:disabled):hover {
  background: rgba(230, 60, 60, 0.12);
}

/* --- components/execution/ExecutionModal.css --- */
.execution-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.execution-modal {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  max-width: 28rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.execution-modal__title {
  margin: 0;
  font-size: 1.05rem;
}

.execution-modal__steps {
  display: flex;
  gap: 0.3rem;
}

.execution-modal__step {
  flex: 1;
  height: 4px;
  border-radius: 4px;
  background: var(--surface-4);
}

.execution-modal__step--done {
  background: var(--accent);
}

.execution-modal__step--active {
  background: var(--accent);
  opacity: 0.6;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.execution-modal__progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-4);
  overflow: hidden;
}

.execution-modal__progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.execution-modal__label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
  word-break: break-word;
}

.execution-modal__count {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.execution-modal__error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0;
}

.execution-modal__success {
  color: var(--accent);
  font-size: 0.85rem;
  margin: 0;
}

.execution-modal__hint {
  color: var(--text-faint);
  font-size: 0.85rem;
  margin: 0;
}

.execution-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* --- components/layout/AppShell.css --- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-shell__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-shell__brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.app-shell__user {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.app-shell__username {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.app-shell__logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.app-shell__logout:hover {
  color: var(--text);
  border-color: var(--text-faint);
}

.app-shell__main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

@media (max-width: 640px) {
  .app-shell__main {
    padding: 1rem;
  }
}

/* --- components/pipeline/DedupeConfigPanel.css --- */
.dedupe-config {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.dedupe-config__option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

/* --- components/pipeline/OutputConfigPanel.css --- */
.output-config {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.output-config__mode {
  display: flex;
  gap: 1.2rem;
  font-size: 0.85rem;
}

.output-config__mode label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.output-config__fields {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.output-config__field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.output-config__field input,
.output-config__field select {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  color: var(--text);
  font-size: 0.85rem;
}

.output-config__checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  cursor: pointer;
}

/* --- components/pipeline/PlaylistSelector.css --- */
.playlist-selector {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.playlist-selector__toolbar {
  display: flex;
  gap: 0.4rem;
}

.playlist-selector__search {
  flex: 1;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  color: var(--text);
  font-size: 0.85rem;
}

.playlist-selector__reload {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  width: 2.2rem;
}

.playlist-selector__error {
  color: var(--danger);
  font-size: 0.82rem;
}

.playlist-selector__hint {
  color: var(--text-faint);
  font-size: 0.82rem;
}

.playlist-selector__list {
  max-height: 16rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem;
  background: var(--surface-1);
}

.playlist-selector__item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.45rem;
  border-radius: 6px;
  cursor: pointer;
}

.playlist-selector__item:hover {
  background: var(--surface-2);
}

.playlist-selector__item--selected {
  background: rgba(30, 215, 96, 0.1);
}

.playlist-selector__thumb {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.playlist-selector__thumb--placeholder {
  background: var(--surface-4);
}

.playlist-selector__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.playlist-selector__name {
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-selector__count {
  font-size: 0.72rem;
  color: var(--text-faint);
}

.playlist-selector__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.playlist-selector__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
}

.playlist-selector__chip button {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

.playlist-selector__chip button:hover {
  color: var(--danger);
}

/* --- components/preview/TrackPreviewList.css --- */
.track-preview {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
}

.track-preview__summary {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.track-preview__loading {
  color: var(--text-faint);
}

.track-preview__list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-y: auto;
  max-height: 32rem;
  background: var(--surface-1);
}

.track-preview__row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.track-preview__row:last-child {
  border-bottom: none;
}

.track-preview__title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.track-preview__name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-preview__artists {
  color: var(--text-faint);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-preview__album {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-preview__duration {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.track-preview__empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
}

.track-preview__more {
  font-size: 0.76rem;
  color: var(--text-faint);
  text-align: center;
}

/* --- components/query-builder/ConditionRow.css --- */
.condition-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.6rem;
}

.condition-row__delete {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  line-height: 1;
}

.condition-row__delete:hover {
  color: var(--danger);
  background: rgba(230, 60, 60, 0.12);
}

/* --- components/query-builder/DraggableRow.css --- */
.draggable-row {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  border-radius: 8px;
  position: relative;
}

.draggable-row::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -5px;
  height: 2px;
  border-radius: 2px;
  background: transparent;
}

.draggable-row--over::after {
  background: var(--accent);
}

.draggable-row--dragging {
  opacity: 0.4;
}

.draggable-row__handle {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: grab;
  font-size: 1rem;
  line-height: 1;
  padding: 0.4rem 0.2rem;
  border-radius: 4px;
  touch-action: none;
}

.draggable-row__handle:hover {
  color: var(--text);
  background: var(--surface-3);
}

.draggable-row__handle:active {
  cursor: grabbing;
}

.draggable-row__content {
  flex: 1;
  min-width: 0;
}

/* --- components/query-builder/DropZone.css --- */
.drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-faint);
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.drop-zone--compact {
  padding: 0.3rem;
}

.drop-zone--over {
  border-color: var(--accent);
  background: rgba(30, 215, 96, 0.08);
  color: var(--accent);
}

/* --- components/query-builder/GroupNode.css --- */
.group-node {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem;
  background: var(--surface-1);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.group-node--root {
  background: transparent;
  border-style: solid;
}

.group-node__header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.group-node__operators {
  display: inline-flex;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.group-node__op {
  border: none;
  background: var(--surface-3);
  color: var(--text-muted);
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
}

.group-node__op:not(:last-child) {
  border-right: 1px solid var(--border);
}

.group-node__op--active.group-node__op--and {
  background: var(--accent);
  color: #06210f;
}
.group-node__op--active.group-node__op--or {
  background: #4fa3ff;
  color: #041a33;
}
.group-node__op--active.group-node__op--not {
  background: var(--danger);
  color: #2a0505;
}

.group-node__hint {
  font-size: 0.76rem;
  color: var(--text-faint);
}

.group-node__delete {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.group-node__delete:hover {
  color: var(--danger);
  background: rgba(230, 60, 60, 0.12);
}

.group-node__children {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--border);
}

.group-node__empty {
  font-size: 0.8rem;
  color: var(--text-faint);
  font-style: italic;
  margin: 0;
}

.group-node__actions {
  display: flex;
  gap: 0.4rem;
}

/* --- components/query-builder/Inputs.css --- */
.qb-select,
.qb-input {
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  font-size: 0.85rem;
  min-width: 0;
}

.qb-select:focus,
.qb-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.qb-input--sm {
  width: 5.5rem;
}

.qb-between {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.qb-between__and {
  color: var(--text-faint);
  font-size: 0.8rem;
}

.qb-value-with-hint {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.qb-hint {
  font-size: 0.72rem;
  color: var(--text-faint);
  white-space: nowrap;
}

.qb-taglist {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem;
  min-width: 12rem;
}

.qb-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--surface-4);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-size: 0.78rem;
}

.qb-tag button {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
}

.qb-tag button:hover {
  color: var(--danger);
}

.qb-taglist__input {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  flex: 1;
  min-width: 6rem;
  padding: 0.2rem;
}

.qb-taglist__input:focus {
  outline: none;
}

/* --- components/query-builder/QueryBuilder.css --- */
.query-builder {
  display: flex;
  flex-direction: column;
}

.query-builder__overlay {
  background: var(--surface-4);
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* --- pages/PipelineEditorPage.css --- */
.pipeline-editor {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.pipeline-editor__missing {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-start;
  padding: 2rem;
}

.pipeline-editor__topbar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.pipeline-editor__name {
  flex: 1;
  min-width: 10rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  padding: 0.2rem 0;
}

.pipeline-editor__name:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

.pipeline-editor__description {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  resize: vertical;
  font-family: inherit;
}

.pipeline-editor__grid {
  display: grid;
  grid-template-columns: 20rem minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

@media (max-width: 1100px) {
  .pipeline-editor__grid {
    grid-template-columns: 1fr;
  }
}

.pipeline-editor__panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.pipeline-editor__panel h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin: 0.4rem 0 0.1rem 0;
}

.pipeline-editor__panel h2:first-child {
  margin-top: 0;
}

.pipeline-editor__panel--builder,
.pipeline-editor__panel--preview {
  position: sticky;
  top: 5rem;
}

.pipeline-editor__error {
  color: var(--danger);
  font-size: 0.82rem;
}

.pipeline-editor__hint {
  color: var(--text-faint);
  font-size: 0.85rem;
}

.pipeline-editor__summary {
  font-size: 0.78rem;
  color: var(--text-faint);
  text-align: right;
}

/* --- pages/PipelinesPage.css --- */
.pipelines-page {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.pipelines-page__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.pipelines-page__header h1 {
  margin: 0;
  font-size: 1.4rem;
}

.pipelines-page__actions {
  display: flex;
  gap: 0.6rem;
}

.pipelines-page__empty {
  color: var(--text-faint);
  padding: 2rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.pipelines-page__list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pipeline-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  flex-wrap: wrap;
}

.pipeline-card__main {
  cursor: pointer;
  flex: 1;
  min-width: 14rem;
}

.pipeline-card__main h3 {
  margin: 0 0 0.25rem 0;
  font-size: 1.02rem;
}

.pipeline-card__meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pipeline-card__updated {
  margin: 0.2rem 0 0 0;
  font-size: 0.72rem;
  color: var(--text-faint);
}

.pipeline-card__actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* --- Blazor additions --- */
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: 0.75rem 1rem; background: var(--danger); color: var(--text); z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }
.pipeline-editor__status { color: var(--text-faint); font-size: 0.85rem; min-width: 5rem; }
.schedule-config, .sort-config { display: flex; flex-direction: column; gap: 0.5rem; }
.sort-config__row { display: flex; gap: 0.5rem; align-items: center; }
.pipeline-card__run { font-size: 0.8rem; color: var(--text-faint); }
.pipeline-card__run--failed { color: var(--danger); }
.track-preview__local { margin-left: 0.4rem; padding: 0 0.35rem; border: 1px solid var(--border); border-radius: 4px; font-size: 0.7rem; color: var(--text-faint); vertical-align: middle; }
