$font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
$bg-color: #f8f9fa;
$card-bg: #ffffff;
$border-color: #e5e7eb;
$text-primary: #1f2937;
$text-secondary: #6b7280;
$text-muted: #9ca3af;
$link-color: #6b9ac4;

.upload-page {
  font-family: $font-family;
  background-color: $bg-color;
  min-height: 100vh;
  overflow-y: auto;

  padding: 24px 40px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  padding-bottom: 16px;
  overflow: scroll;

  border-bottom: 1px solid $border-color;
}

.header-left {
  .page-title {
    font-family: $font-family;
    font-size: 24px;
    font-weight: 700;
    color: $text-primary;
    margin: 0 0 4px 0;
  }

  .page-subtitle {
    font-family: $font-family;
    font-size: 14px;
    color: $text-secondary;
    margin: 0;
  }
}

.header-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn-ai-upload {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
  font-family: $font-family;
  font-size: 14px;
  transition: all 0.2s ease;

  mat-icon {
    font-size: 20px;
    width: 20px;
    height: 20px;
  }

  &:hover {
    opacity: 0.9;
    transform: translateY(-1px);
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
  }
}

.upload-card {
  background: $card-bg;
  border: 1px solid $border-color;
  border-radius: 12px;
  padding: 24px 32px 32px;
  margin-bottom: 24px;
}

.card-title {
  font-family: $font-family;
  font-size: 18px;
  font-weight: 700;
  color: $text-primary;
  margin: 0 0 20px 0;
}

// ── Header Tabs (New subtle design) ─────────────────────────────────────────
.header-tabs {
  display: flex;
  gap: 2px;
  background: #f3f4f6;
  padding: 4px;
  border-radius: 8px;
  width: fit-content;
  margin-bottom: 24px;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;

  mat-icon {
    font-size: 18px;
    width: 18px;
    height: 18px;
  }

  &:hover {
    color: #374151;
    background: #e5e7eb;
  }

  &.active {
    background: #fff;
    color: #111827;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }
}

.document-type-section {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid $border-color;
}

.type-label {
  font-family: $font-family;
  font-size: 14px;
  font-weight: 500;
  color: $text-primary;
}

.type-select {
  font-family: $font-family;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid $border-color;
  border-radius: 6px;
  background: $card-bg;
  color: $text-primary;
  cursor: pointer;
  min-width: 200px;

  &:focus {
    outline: none;
    border-color: $link-color;
  }
}

.dropzone {
  border: 2px dashed $border-color;
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: $card-bg;

  &:hover,
  &.dropzone-active {
    border-color: $text-muted;
    background: #fafafa;
  }
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.upload-icon {
  color: $text-muted;
  opacity: 0.6;
  margin-bottom: 8px;
}

.dropzone-title {
  font-family: $font-family;
  font-size: 16px;
  font-weight: 600;
  color: $text-primary;
  margin: 0;
}

.dropzone-subtitle {
  font-family: $font-family;
  font-size: 14px;
  color: $link-color;
  margin: 0 0 16px 0;
}

.dropzone-hint {
  font-family: $font-family;
  font-size: 13px;
  color: $text-muted;
  margin: 16px 0 0 0;
}

.file-input-hidden {
  display: none;
}

.btn-outline {
  font-family: $font-family;
  background: $card-bg;
  color: $text-primary;
  border: 1px solid $border-color;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #d1d5db;
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

.btn-choose {
  font-family: $font-family;
  background: $card-bg;
  color: $text-primary;
  border: 1px solid $border-color;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
  }
}

.btn-primary {
  padding: 10px 24px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover:not(:disabled) {
    background: linear-gradient(135deg, #6d28d9, #5b21b6);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

.btn-secondary {
  padding: 10px 24px;
  background: #fff;
  color: #475569;
  border: 1px solid $border-color;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #d1d5db;
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

.btn-success {
  padding: 10px 24px;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover:not(:disabled) {
    background: #15803d;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.2);
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

// ── Examples ────────────────────────────────────────────────────────────
.examples-box {
  background: #f9fafb;
  border: 1px solid $border-color;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.examples-title {
  font-size: 13px;
  font-weight: 600;
  color: $text-secondary;
  margin-bottom: 12px;
}

.example-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.example-chip {
  padding: 6px 12px;
  background: #fff;
  border: 1px solid $border-color;
  border-radius: 999px;
  font-size: 12px;
  color: $text-primary;
  cursor: pointer;
  transition: all 0.2s;

  &:hover {
    background: #f3f4f6;
    border-color: #6b9ac4;
    color: #1a5673;
  }
}

// ── Text Area ─────────────────────────────────────────────────────────────
.text-area {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 16px;

  &:focus {
    outline: none;
    border-color: #6b9ac4;
    box-shadow: 0 0 0 3px rgba(107, 154, 196, 0.1);
  }
}

// ── Voice Area ────────────────────────────────────────────────────────────
.voice-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
}

.voice-btn-subtle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid $border-color;
  background: #fff;
  color: $text-secondary;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  mat-icon {
    font-size: 28px;
    width: 28px;
    height: 28px;
  }

  &:hover:not(:disabled) {
    border-color: #6b9ac4;
    color: #6b9ac4;
    background: #f8fafc;
  }

  &.recording {
    background: #fee2e2;
    border-color: #ef4444;
    color: #ef4444;
    animation: simple-pulse 2s infinite;
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

@keyframes simple-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.voice-status {
  margin-top: 12px;
  font-size: 13px;
  color: $text-secondary;

  &.active {
    color: #ef4444;
    font-weight: 700;
  }
}

.transcript-section {
  margin-top: 16px;
}

.transcript-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}

.transcript-text {
  margin-top: 6px;
  color: #1e293b;
}

// ── AI Badges & Extras ──────────────────────────────────────────────────
.ai-badge {
  background: #6b9ac4;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.files-list {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f9fafb;
  border: 1px solid $border-color;
  border-radius: 8px;
  padding: 12px 16px;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-icon {
  color: $text-muted;
  font-size: 24px;
  width: 24px;
  height: 24px;
}

.file-details {
  display: flex;
  flex-direction: column;
}

.file-name {
  font-family: $font-family;
  font-size: 14px;
  font-weight: 500;
  color: $text-primary;
}

.file-size {
  font-family: $font-family;
  font-size: 12px;
  color: $text-muted;
}

.btn-remove {
  background: none;
  border: none;
  font-size: 20px;
  color: $text-muted;
  cursor: pointer;
  padding: 0;
  line-height: 1;

  &:hover {
    color: #ef4444;
  }
}

.option-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.option-label {
  font-family: $font-family;
  font-size: 14px;
  color: $text-primary;
  cursor: pointer;
}

.option-hint {
  font-family: $font-family;
  font-size: 13px;
  color: $text-muted;
  margin: 8px 0 0 0;
}

.progress-container {
  text-align: center;
}

.progress-bar {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  width: 60%;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  border-radius: 2px;
  animation: progress-animation 1.5s ease-in-out infinite;
}

@keyframes progress-animation {
  0% {
    width: 0%;
  }

  50% {
    width: 70%;
  }

  100% {
    width: 100%;
  }
}

.progress-text {
  font-family: $font-family;
  font-size: 14px;
  color: $text-secondary;
  margin: 0;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-item {
  border: 1px solid $border-color;
  border-radius: 8px;
  padding: 16px;

  &.result-success {
    border-color: #86efac;
    background: #f0fdf4;
  }

  &.result-failed {
    border-color: #fca5a5;
    background: #fef2f2;
  }

  &.result-warning {
    border-color: #fcd34d;
    background: #fffbeb;
  }
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.result-icon {
  mat-icon {
    font-size: 24px;
    width: 24px;
    height: 24px;
  }

  &.icon-success mat-icon {
    color: #22c55e;
  }

  &.icon-failed mat-icon {
    color: #ef4444;
  }

  &.icon-warning mat-icon {
    color: #f59e0b;
  }
}

.result-text {
  .result-title {
    font-family: $font-family;
    font-size: 14px;
    font-weight: 500;
    color: $text-primary;
    margin: 0;
  }

  .result-message {
    font-family: $font-family;
    font-size: 13px;
    margin: 4px 0 0 0;

    &.message-success {
      color: #16a34a;
    }

    &.message-failed {
      color: #dc2626;
    }

    &.message-warning {
      color: #d97706;
    }
  }
}

.badge {
  font-family: $font-family;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 9999px;

  &.badge-success {
    background: #dcfce7;
    color: #16a34a;
  }

  &.badge-failed {
    background: #fee2e2;
    color: #dc2626;
  }

  &.badge-warning {
    background: #fef3c7;
    color: #d97706;
  }

  &.badge-pending {
    background: #e5e7eb;
    color: $text-secondary;
  }
}

.ai-error-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid $border-color;
}

.ai-error-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: $font-family;
  font-size: 14px;
  font-weight: 500;
  color: #d97706;
  margin-bottom: 8px;

  mat-icon {
    font-size: 18px;
    width: 18px;
    height: 18px;
  }
}

.ai-error-details,
.ai-json-preview {
  pre {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    background: #f9fafb;
    border: 1px solid $border-color;
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 0;
  }

  details {
    summary {
      font-family: $font-family;
      font-size: 13px;
      color: $text-secondary;
      cursor: pointer;
      margin-bottom: 8px;

      &:hover {
        color: $text-primary;
      }
    }
  }
}

.action-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}