@use '../../../../shared/styles/panel-shared' as panel;

.bulk-isbn-import {
  display: flex;
  flex-direction: column;
  min-width: 600px;
  max-height: 90vh;

  @media (max-width: 768px) {
    min-width: auto;
    width: 100%;
  }
}

.panel-header {
  @include panel.panel-header;
}

.form-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-top: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  overflow-y: auto;
  max-height: calc(90vh - 200px);

  @media (max-width: 480px) {
    padding: 0.75rem;
    gap: 0.5rem;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;

  &.highlight-group {
    padding: 0.5rem;
  }
}

.form-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-color);

  .label-icon {
    color: var(--primary-color);
  }

  .required-indicator {
    color: var(--p-red-500);
    margin-left: 0.125rem;
  }
}

.input-full {
  width: 100%;
  box-sizing: border-box;
}

.gradient-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border-color), transparent);
  margin: 0.25rem 0;
}

// Upload section
.upload-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;

  .upload-hint {
    font-size: 0.8rem;
    color: var(--text-secondary-color);
    margin: 0;
    text-align: center;
  }
}

.paste-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem 0;

  p-button {
    align-self: flex-end;
  }
}

.parse-error {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 6px;
  color: var(--p-red-500);
  font-size: 0.875rem;
}

// Parse results
.parse-results {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.parse-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.summary-stat {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;

  &.success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--p-green-500);
    border: 1px solid rgba(34, 197, 94, 0.3);
  }

  &.warn {
    background: rgba(234, 179, 8, 0.1);
    color: var(--p-yellow-500);
    border: 1px solid rgba(234, 179, 8, 0.3);
    cursor: pointer;
  }

  &.info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--p-blue-500);
    border: 1px solid rgba(59, 130, 246, 0.3);
  }
}

.skipped-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem;
  background: rgba(234, 179, 8, 0.05);
  border: 1px solid rgba(234, 179, 8, 0.2);
  border-radius: 6px;
  max-height: 150px;
  overflow-y: auto;
}

.skipped-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;

  code {
    color: var(--text-color);
    background: var(--ground-background);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
  }

  .skipped-reason {
    color: var(--text-secondary-color);
    font-style: italic;
  }
}

.isbn-preview {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;

  .preview-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
  }
}

.preview-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 200px;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--ground-background);
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

.preview-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.375rem;
  font-size: 0.85rem;

  .preview-index {
    color: var(--text-secondary-color);
    min-width: 2rem;
    text-align: right;
  }

  .preview-isbn {
    color: var(--text-color);
  }
}

// Processing phase
.processing-container {
  max-height: calc(90vh - 180px);
}

.progress-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;

  .progress-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
  }

  .progress-percent {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
  }
}

.progress-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;

  .stat-created {
    color: var(--p-green-500);
  }

  .stat-no-metadata {
    color: var(--p-yellow-500);
  }

  .stat-failed {
    color: var(--p-red-500);
  }

  i {
    margin-right: 0.25rem;
  }
}

.isbn-progress-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.progress-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  transition: background-color 0.2s;

  &.status-pending {
    opacity: 0.5;
  }

  &.status-looking-up {
    background: rgba(59, 130, 246, 0.05);
  }

  &.status-created {
    background: rgba(34, 197, 94, 0.05);
  }

  &.status-created-no-metadata {
    background: rgba(234, 179, 8, 0.05);
  }

  &.status-failed {
    background: rgba(239, 68, 68, 0.05);
  }
}

.progress-item-icon {
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;

  .status-pending & { color: var(--text-secondary-color); }
  .status-looking-up & { color: var(--p-blue-500); }
  .status-created & { color: var(--p-green-500); }
  .status-created-no-metadata & { color: var(--p-yellow-500); }
  .status-failed & { color: var(--p-red-500); }
}

.progress-item-isbn {
  min-width: 8rem;
  flex-shrink: 0;
  color: var(--text-color);
}

.progress-item-detail {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary-color);
  font-size: 0.8rem;
}

// Summary phase
.summary-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;

  .summary-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
  }

  .summary-library {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.85rem;
    color: var(--text-secondary-color);

    i {
      color: var(--primary-color);
    }
  }
}

.summary-results {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.25rem 0;
}

.summary-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  flex: 1;
  min-width: 120px;

  > i {
    font-size: 1.25rem;
  }

  &.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    > i { color: var(--p-green-500); }
  }

  &.warn {
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.3);
    > i { color: var(--p-yellow-500); }
  }

  &.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    > i { color: var(--p-red-500); }
  }

  &.info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    > i { color: var(--p-blue-500); }
  }
}

.summary-card-content {
  display: flex;
  flex-direction: column;

  .summary-card-count {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
  }

  .summary-card-label {
    font-size: 0.75rem;
    color: var(--text-secondary-color);
  }
}

.summary-detail-list {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin-top: 0.25rem;
}

.summary-detail-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;

  &.status-created {
    background: rgba(34, 197, 94, 0.04);
  }

  &.status-created-no-metadata {
    background: rgba(234, 179, 8, 0.04);
  }

  &.status-failed {
    background: rgba(239, 68, 68, 0.04);
  }
}

.summary-detail-icon {
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;

  .status-created & { color: var(--p-green-500); }
  .status-created-no-metadata & { color: var(--p-yellow-500); }
  .status-failed & { color: var(--p-red-500); }
}

.summary-detail-isbn {
  min-width: 8rem;
  flex-shrink: 0;
  color: var(--text-color);
  font-size: 0.8rem;
}

.summary-detail-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;

  .status-created & { color: var(--text-color); }
  .status-created-no-metadata & { color: var(--p-yellow-500); font-style: italic; }
  .status-failed & { color: var(--p-red-500); font-style: italic; }
}

.validation-message {
  @include panel.validation-message;

  &.info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--p-blue-500);
    border: 1px solid rgba(59, 130, 246, 0.3);

    i {
      color: var(--p-blue-500);
    }
  }
}

.dialog-footer {
  @include panel.dialog-footer;
  border-top: none;
}
