/* Close CRM Sync Dashboard Styles */

:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --danger-color: #dc2626;
  --danger-hover: #b91c1c;
  --success-color: #16a34a;
  --warning-color: #d97706;
  --bg-color: #f3f4f6;
  --card-bg: #ffffff;
  --text-color: #1f2937;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 600;
}

.health-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--card-bg);
  border-radius: 2rem;
  box-shadow: var(--shadow);
}

.health-indicator .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
}

.health-indicator.healthy .dot {
  background: var(--success-color);
}

.health-indicator.unhealthy .dot {
  background: var(--danger-color);
}

.health-indicator .text {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Main */
main {
  display: grid;
  gap: 1.5rem;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-color);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-secondary {
  background: var(--border-color);
  color: var(--text-color);
}

.btn-secondary:hover:not(:disabled) {
  background: #d1d5db;
}

.button-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Sync Controls */
.sync-status {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.sync-status.hidden {
  display: none;
}

.progress-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.progress-bar {
  flex: 1;
  height: 1rem;
  background: var(--border-color);
  border-radius: 0.5rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary-color);
  border-radius: 0.5rem;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  font-size: 0.875rem;
  font-weight: 600;
  min-width: 3rem;
  text-align: right;
}

.phase-message {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Last Sync */
.last-sync-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.last-sync-item {
  padding: 0.75rem;
  background: var(--bg-color);
  border-radius: 0.5rem;
}

.last-sync-item .label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.last-sync-item .value {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-item {
  text-align: center;
  padding: 1rem;
  background: var(--bg-color);
  border-radius: 0.5rem;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Sync History */
.sync-runs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.sync-runs-table th,
.sync-runs-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.sync-runs-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sync-runs-table tbody tr:hover {
  background: var(--bg-color);
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

.status-badge.running {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-badge.completed {
  background: #dcfce7;
  color: #16a34a;
}

.status-badge.failed {
  background: #fee2e2;
  color: #dc2626;
}

.status-badge.cancelled {
  background: #fef3c7;
  color: #d97706;
}

/* Loading */
.loading {
  color: var(--text-muted);
  font-style: italic;
}

/* Footer */
footer {
  margin-top: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Section Divider */
.section-divider {
  background: linear-gradient(135deg, #4267B2, #1877F2);
  color: white;
  text-align: center;
  margin-top: 2rem;
}

.section-divider h2 {
  color: white;
  margin: 0;
}

.section-title {
  font-size: 1.25rem;
}

/* Meta Sync Controls */
.meta-sync-controls {
  border-left: 4px solid #1877F2;
}

/* Config Status */
.config-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  margin-bottom: 1rem;
}

.config-status .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
}

.config-status.configured .dot {
  background: var(--success-color);
}

.config-status.not-configured .dot {
  background: var(--warning-color);
}

.config-status .text {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Date Range Inputs */
.date-range-inputs {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

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

.input-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-group input[type="date"] {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  background: white;
}

.input-group input[type="date"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* CopeCart Section */
.copecart-divider {
  background: linear-gradient(135deg, #7C3AED, #9333EA);
}

.copecart-import-controls {
  border-left: 4px solid #7C3AED;
}

/* Ablefy Section */
.ablefy-divider {
  background: linear-gradient(135deg, #059669, #10B981);
}

.ablefy-import-controls {
  border-left: 4px solid #059669;
}

#ablefy-drop-zone:hover,
#ablefy-drop-zone.drag-over {
  border-color: #059669;
  background: rgba(5, 150, 105, 0.05);
}

/* File Upload Zone */
.file-upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: 0.5rem;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 1rem;
  position: relative;
}

.file-upload-zone:hover,
.file-upload-zone.drag-over {
  border-color: #7C3AED;
  background: rgba(124, 58, 237, 0.05);
}

.file-upload-zone.has-file {
  border-style: solid;
  border-color: var(--success-color);
  background: rgba(22, 163, 74, 0.05);
}

.file-input-hidden {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-upload-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.file-upload-text {
  font-size: 0.9rem;
  color: var(--text-color);
  margin-bottom: 0.25rem;
}

.file-upload-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-selected {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-color);
  border-radius: 0.25rem;
  margin-top: 1rem;
}

.file-selected.hidden {
  display: none;
}

.file-name {
  font-weight: 500;
  color: var(--text-color);
}

.btn-clear-file {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

.btn-clear-file:hover {
  color: var(--danger-color);
}

.file-upload-content.hidden {
  display: none;
}

/* Import Stats */
.import-stats {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.import-stat strong {
  color: var(--text-color);
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .sync-runs-table {
    display: block;
    overflow-x: auto;
  }

  .date-range-inputs {
    flex-direction: column;
  }
}
