@use '../variables' as v;
@use '../mixins' as m;

// Automation canvas wrapper
.canvas-wrapper {
  @include m.card-base;
  height: calc(100vh - 180px);
  min-height: 400px;
  overflow: hidden;
  position: relative;
  background: var(--bg-page);
  background-image:
    radial-gradient(circle, var(--border-color) 1px, transparent 1px);
  background-size: 24px 24px;

  @media (max-width: 768px) {
    height: calc(100vh - 220px);
    min-height: 300px;
  }

  @media (max-width: 480px) {
    height: calc(100vh - 240px);
    min-height: 260px;
  }
}

.canvas-placeholder {
  @include m.flex-center;
  flex-direction: column;
  height: 100%;
  gap: 16px;
  text-align: center;
  padding: 40px;

  @media (max-width: 480px) {
    padding: 24px 16px;
    gap: 12px;
  }

  &-icon {
    width: 64px;
    height: 64px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: v.$radius-xl;
    @include m.flex-center;
    box-shadow: v.$shadow;

    svg { width: 28px; height: 28px; color: var(--text-muted); }
  }

  h3 { font-size: v.$font-size-lg; font-weight: 600; color: var(--text-primary); }
  p  { font-size: v.$font-size-sm; color: var(--text-muted); max-width: 340px; line-height: 1.6; }
}

.canvas-toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  @include m.flex-start;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: v.$radius;
  padding: 5px;
  box-shadow: v.$shadow-sm;
  flex-wrap: wrap;
  max-width: calc(100% - 32px);
  z-index: 10;

  @media (max-width: 480px) {
    top: 8px;
    left: 8px;
    padding: 4px;
    gap: 4px;
  }
}

.canvas-minimap {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 160px;
  height: 100px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: v.$radius;
  box-shadow: v.$shadow-sm;
  overflow: hidden;

  @media (max-width: 640px) {
    display: none;
  }
}

// Workflow node (preview)
.workflow-node {
  @include m.card-base;
  padding: 12px 16px;
  min-width: 200px;
  max-width: 260px;
  display: inline-block;

  @media (max-width: 480px) {
    min-width: 160px;
    max-width: 100%;
    display: block;
  }

  &-type {
    font-size: v.$font-size-2xs;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
    @include m.flex-start;
    gap: 5px;

    svg { width: 12px; height: 12px; }
  }

  &-title { font-size: v.$font-size-sm; font-weight: 600; color: var(--text-primary); }
  &-sub   { font-size: v.$font-size-xs; color: var(--text-secondary); margin-top: 3px; }

  &--trigger {
    border-color: var(--info-border, #{v.$info-border});
    .workflow-node-type { color: var(--active-text, #{v.$primary}); }
  }

  &--action {
    border-color: var(--info-border, #{v.$info-border});
    .workflow-node-type { color: var(--info, #{v.$info}); }
  }

  &--condition {
    border-color: var(--warning-border, #{v.$warning-border});
    .workflow-node-type { color: var(--warning, #{v.$warning}); }
  }
}

// Automation list item
.automation-item {
  @include m.card-base;
  padding: 16px 20px;
  @include m.flex-between;
  gap: 16px;
  transition: box-shadow v.$transition-base;

  @media (max-width: 640px) {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
  }

  &:hover { box-shadow: v.$shadow; }

  &-info { flex: 1; min-width: 0; }
  &-name {
    font-size: v.$font-size-base;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    @include m.truncate;
  }

  &-meta {
    @include m.flex-start;
    gap: 10px;
    font-size: v.$font-size-xs;
    color: var(--text-muted);
    flex-wrap: wrap;

    svg { width: 13px; height: 13px; }
  }

  &-actions {
    @include m.flex-start;
    gap: 8px;
    flex-shrink: 0;

    @media (max-width: 640px) {
      align-self: flex-end;
    }
  }
}
