/**
 * Data Importer Styles
 * Modal-based bulk import from CSV/Excel
 */

/* ========================================
   MODAL OVERLAY & CONTAINER
   ======================================== */

.di-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: di-fade-in 0.2s ease;
}

.di-modal-overlay.di-closing {
  animation: di-fade-out 0.2s ease forwards;
}

@keyframes di-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes di-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

.di-modal {
  background: var(--content-bg, #fff);
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: di-slide-up 0.3s ease;
}

@keyframes di-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.di-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.di-modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--content-text, #1f2937);
}

.di-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted, #6b7280);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.di-close-btn:hover {
  background: var(--hover-bg, #f3f4f6);
  color: var(--content-text, #1f2937);
}

.di-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* ========================================
   STEP LAYOUT
   ======================================== */

.di-step-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.di-step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--primary-color, #667eea);
  color: white;
  border-radius: 50%;
  font-size: 0.875rem;
  font-weight: 600;
}

.di-step-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--content-text, #1f2937);
}

.di-step-info {
  margin-left: auto;
  font-size: 0.875rem;
  color: var(--text-muted, #6b7280);
}

/* ========================================
   BUTTONS
   ======================================== */

.di-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
}

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

.di-btn-primary {
  background: var(--primary-color, #667eea);
  color: white;
}

.di-btn-primary:hover:not(:disabled) {
  background: var(--primary-hover, #5a67d8);
}

.di-btn-secondary {
  background: var(--hover-bg, #f3f4f6);
  color: var(--content-text, #1f2937);
  border: 1px solid var(--border-color, #e5e7eb);
}

.di-btn-secondary:hover:not(:disabled) {
  background: var(--border-color, #e5e7eb);
}

/* ========================================
   UPLOAD STEP
   ======================================== */

.di-dropzone {
  border: 2px dashed var(--border-color, #e5e7eb);
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--hover-bg, #f9fafb);
}

.di-dropzone:hover,
.di-dropzone:focus {
  border-color: var(--primary-color, #667eea);
  background: rgba(102, 126, 234, 0.05);
}

.di-dropzone.di-dragover {
  border-color: var(--primary-color, #667eea);
  background: rgba(102, 126, 234, 0.1);
  transform: scale(1.01);
}

.di-dropzone-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.di-dropzone-text {
  color: var(--content-text, #1f2937);
  margin-bottom: 0.5rem;
}

.di-dropzone-text strong {
  color: var(--primary-color, #667eea);
}

.di-dropzone-hint {
  font-size: 0.875rem;
  color: var(--text-muted, #6b7280);
}

.di-file-input {
  display: none;
}

.di-template-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color, #e5e7eb);
}

.di-template-hint {
  font-size: 0.875rem;
  color: var(--text-muted, #6b7280);
}

.di-paste-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color, #e5e7eb);
}

.di-paste-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--content-text, #1f2937);
  margin-bottom: 0.5rem;
}

.di-paste-area {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.875rem;
  resize: vertical;
  background: var(--content-bg, #fff);
  color: var(--content-text, #1f2937);
}

.di-paste-area:focus {
  outline: none;
  border-color: var(--primary-color, #667eea);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.di-parse-paste {
  margin-top: 0.75rem;
}

/* ========================================
   MAPPING STEP
   ======================================== */

.di-mapping-instructions {
  font-size: 0.875rem;
  color: var(--text-muted, #6b7280);
  margin-bottom: 1.25rem;
}

.di-required-indicator {
  color: #ef4444;
  font-weight: 600;
}

.di-mapping-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.di-mapping-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--hover-bg, #f9fafb);
  border-radius: 8px;
  border: 1px solid transparent;
}

.di-mapping-row.di-required {
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.03);
}

.di-mapping-db-col {
  flex: 0 0 200px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.di-col-label {
  font-weight: 500;
  color: var(--content-text, #1f2937);
}

.di-col-type {
  font-size: 0.75rem;
  color: var(--text-muted, #6b7280);
  background: var(--border-color, #e5e7eb);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

.di-mapping-arrow {
  color: var(--text-muted, #6b7280);
  flex-shrink: 0;
}

.di-mapping-source {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.di-mapping-select {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
  font-size: 0.875rem;
  background: var(--content-bg, #fff);
  color: var(--content-text, #1f2937);
}

.di-mapping-select:focus {
  outline: none;
  border-color: var(--primary-color, #667eea);
}

.di-mapping-preview {
  font-size: 0.75rem;
  color: var(--text-muted, #6b7280);
  background: var(--content-bg, #fff);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border-color, #e5e7eb);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.di-unmapped-notice {
  font-size: 0.875rem;
  color: var(--text-muted, #6b7280);
  padding: 0.75rem;
  background: var(--hover-bg, #f9fafb);
  border-radius: 6px;
  margin-bottom: 1.5rem;
}

.di-mapping-actions {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color, #e5e7eb);
}

/* ========================================
   PREVIEW STEP
   ======================================== */

.di-preview-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.di-summary-card {
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  border: 1px solid var(--border-color, #e5e7eb);
}

.di-summary-valid {
  background: rgba(16, 185, 129, 0.05);
  border-color: rgba(16, 185, 129, 0.2);
}

.di-summary-errors {
  background: var(--hover-bg, #f9fafb);
}

.di-summary-errors.has-errors {
  background: rgba(239, 68, 68, 0.05);
  border-color: rgba(239, 68, 68, 0.2);
}

.di-summary-total {
  background: var(--hover-bg, #f9fafb);
}

.di-summary-count {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--content-text, #1f2937);
}

.di-summary-valid .di-summary-count {
  color: #10b981;
}

.di-summary-errors.has-errors .di-summary-count {
  color: #ef4444;
}

.di-summary-label {
  font-size: 0.875rem;
  color: var(--text-muted, #6b7280);
}

/* Error Section */
.di-error-section {
  margin-bottom: 1.5rem;
}

.di-error-section h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #ef4444;
  margin-bottom: 0.75rem;
}

.di-error-table-wrapper {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
}

.di-error-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.di-error-table th,
.di-error-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.di-error-table th {
  background: var(--hover-bg, #f9fafb);
  font-weight: 600;
  position: sticky;
  top: 0;
}

.di-error-messages {
  color: #ef4444;
}

.di-error-msg {
  font-size: 0.75rem;
}

.di-error-data {
  color: var(--text-muted, #6b7280);
  font-family: monospace;
  font-size: 0.75rem;
}

.di-more-errors {
  font-size: 0.8125rem;
  color: var(--text-muted, #6b7280);
  margin-top: 0.5rem;
}

/* Preview Table */
.di-preview-table-section h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--content-text, #1f2937);
  margin-bottom: 0.75rem;
}

.di-preview-table-wrapper {
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
}

.di-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.di-preview-table th,
.di-preview-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  white-space: nowrap;
}

.di-preview-table th {
  background: var(--hover-bg, #f9fafb);
  font-weight: 600;
  position: sticky;
  top: 0;
}

.di-preview-table tr:hover td {
  background: var(--hover-bg, #f9fafb);
}

.di-tag {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  background: var(--primary-color, #667eea);
  color: white;
  border-radius: 4px;
  font-size: 0.6875rem;
  margin-right: 0.25rem;
}

/* Import Options */
.di-import-options {
  margin: 1.25rem 0;
  padding: 1rem;
  background: var(--hover-bg, #f9fafb);
  border-radius: 6px;
}

.di-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--content-text, #1f2937);
}

.di-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.di-preview-actions {
  display: flex;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color, #e5e7eb);
}

.di-preview-actions .di-import-btn {
  margin-left: auto;
}

/* ========================================
   PROGRESS STEP
   ======================================== */

.di-step-progress .di-step-content {
  text-align: center;
  padding: 2rem 0;
}

.di-progress-bar {
  height: 8px;
  background: var(--border-color, #e5e7eb);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.di-progress-fill {
  height: 100%;
  background: var(--primary-color, #667eea);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.di-progress-text {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--content-text, #1f2937);
  margin-bottom: 0.5rem;
}

.di-progress-hint {
  font-size: 0.875rem;
  color: var(--text-muted, #6b7280);
}

/* ========================================
   RESULTS STEP
   ======================================== */

.di-results-summary {
  text-align: center;
  padding: 2rem 0;
}

.di-result-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.di-result-stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.di-result-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
}

.di-result-count {
  font-weight: 700;
}

.di-result-success .di-result-count {
  color: #10b981;
}

.di-result-failed .di-result-count {
  color: #ef4444;
}

.di-result-skipped .di-result-count {
  color: var(--text-muted, #6b7280);
}

.di-result-label {
  color: var(--text-muted, #6b7280);
}

.di-results-actions {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
}

/* ========================================
   DARK MODE
   ======================================== */

[data-theme="dark"] .di-modal {
  background: var(--content-bg, #1f2937);
}

[data-theme="dark"] .di-dropzone {
  background: rgba(255, 255, 255, 0.02);
}

[data-theme="dark"] .di-dropzone:hover,
[data-theme="dark"] .di-dropzone:focus {
  background: rgba(102, 126, 234, 0.1);
}

[data-theme="dark"] .di-mapping-row {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .di-col-type {
  background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .di-mapping-preview {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .di-error-table th {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .di-preview-table th {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .di-import-options {
  background: rgba(255, 255, 255, 0.03);
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 640px) {
  .di-modal {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .di-preview-summary {
    grid-template-columns: 1fr;
  }

  .di-mapping-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .di-mapping-db-col {
    flex: none;
    width: 100%;
  }

  .di-mapping-arrow {
    display: none;
  }

  .di-mapping-source {
    width: 100%;
  }

  .di-mapping-actions,
  .di-preview-actions {
    flex-direction: column;
  }

  .di-preview-actions .di-import-btn {
    margin-left: 0;
  }
}
