/*
 * FlowDocs - Dashboard Layout
 * Modern React-style dashboard with stats and charts
 */

/* ================================
 * DASHBOARD CONTAINER
 * ================================ */

.dashboard {
  background: var(--page-bg);
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: var(--space-7);
}

.dashboard-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-7);
}

.dashboard-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--pk-gray-900);
  letter-spacing: -0.3px;
}

/* ================================
 * STATS GRID
 * ================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  margin-bottom: var(--space-7);
}

.stat-card {
  background: var(--pk-white);
  border: 1px solid var(--pk-gray-200);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--pk-gray-300);
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-md);
  margin-bottom: var(--space-4);
}

.stat-icon.accent-orange,
.stat-icon-orange {
  background: var(--pk-orange-subtle);
  color: var(--pk-orange);
}

.stat-icon.accent-green,
.stat-icon-green {
  background: var(--pk-success-light);
  color: var(--pk-success);
}

.stat-icon.accent-amber,
.stat-icon-amber {
  background: var(--pk-warning-light);
  color: var(--pk-warning);
}

.stat-icon.accent-red,
.stat-icon-red {
  background: var(--pk-error-light);
  color: var(--pk-error);
}

.stat-icon.accent-blue,
.stat-icon-blue {
  background: var(--pk-info-light);
  color: var(--pk-info);
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.stat-label,
.summary-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--pk-gray-700);
}

.stat-trend {
  font-size: var(--text-micro);
  color: var(--pk-slate);
  font-weight: var(--font-semibold);
}

.stat-value,
.summary-count {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--pk-gray-900);
  line-height: 1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.stat-sub,
.summary-breakdown {
  font-size: var(--text-caption);
  color: var(--pk-gray-400);
  margin-top: 2px;
}

.stat-link,
.summary-link {
  font-size: var(--text-caption);
  color: var(--pk-orange);
  text-decoration: none;
  font-weight: var(--font-medium);
  margin-top: var(--space-3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stat-link:hover,
.summary-link:hover {
  text-decoration: underline;
}

.stat-meta {
  font-size: var(--text-micro);
  color: var(--pk-gray-500);
}

/* ================================
 * ROI SECTION
 * ================================ */

.roi-section {
  margin-bottom: var(--space-4);
}

.roi-card {
  background: linear-gradient(135deg, var(--pk-white) 0%, var(--pk-success-light) 100%);
  border: 2px solid var(--pk-slate);
}

.roi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

.roi-metric {
  text-align: center;
  padding: var(--space-3);
  background: var(--pk-white);
  border-radius: var(--radius-md);
  border: 1px solid var(--pk-gray-200);
}

.roi-label {
  font-size: var(--text-micro);
  font-weight: var(--font-semibold);
  color: var(--pk-gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.roi-value-large {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--pk-slate);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.roi-value-medium {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--pk-slate-dark);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.roi-detail {
  font-size: var(--text-micro);
  color: var(--pk-gray-400);
  line-height: 1.3;
}

/* ================================
 * CONTENT GRID
 * ================================ */

.content-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-7);
}

/* ================================
 * DASHBOARD CARDS
 * ================================ */

.dash-card {
  background: var(--pk-white);
  border: 1px solid var(--pk-gray-200);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-xs);
}

.dash-card .card-title,
.dash-card h3 {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--pk-gray-900);
  margin-bottom: var(--space-5);
}

/* ================================
 * CHARTS
 * ================================ */

.chart-wrapper {
  height: 160px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  position: relative;
}

.chart-wrapper canvas {
  max-width: 100%;
  max-height: 100%;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

/* ================================
 * ACTIVITY LIST
 * ================================ */

.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 200px;
  overflow-y: auto;
}

.activity-list::-webkit-scrollbar {
  width: 4px;
}

.activity-list::-webkit-scrollbar-track {
  background: transparent;
}

.activity-list::-webkit-scrollbar-thumb {
  background: var(--pk-gray-300);
  border-radius: var(--radius-sm);
}

.activity-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--pk-gray-100);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.activity-dot.completed { background: var(--pk-success); }
.activity-dot.pending { background: var(--pk-info); }
.activity-dot.failed { background: var(--pk-error); }
.activity-dot.needs_review { background: var(--pk-warning); }

.activity-dot.processing {
  background: var(--pk-info);
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-filename {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--pk-gray-700);
}

.activity-info {
  font-size: var(--text-caption);
  color: var(--pk-gray-400);
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* ================================
 * VENDOR ACTIVITY
 * ================================ */

.vendor-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.vendor-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.vendor-name {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--pk-slate-dark);
  min-width: 80px;
}

.vendor-bar-bg {
  flex: 1;
  height: 16px;
  background: var(--pk-gray-100);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.vendor-bar {
  height: 100%;
  background: var(--pk-slate);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 var(--space-2);
  color: var(--pk-white);
  font-size: var(--text-micro);
  font-weight: var(--font-semibold);
  transition: width 0.3s;
}

.vendor-count {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--pk-slate);
  min-width: 24px;
  text-align: right;
}

/* ================================
 * BOTTOM ROW
 * ================================ */

.bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

/* ================================
 * INTEGRATION STATS
 * ================================ */

.integration-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.integration-stat {
  text-align: center;
  padding: var(--space-3);
  background: var(--pk-gray-50);
  border-radius: var(--radius-md);
}

.integration-value {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--pk-slate-dark);
  margin-bottom: 0;
}

.integration-value.success {
  color: var(--pk-slate);
}

.integration-value.error {
  color: var(--pk-error);
}

.integration-label {
  font-size: var(--text-micro);
  font-weight: var(--font-medium);
  color: var(--pk-gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ================================
 * ALERT CARDS
 * ================================ */

.alerts-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.alert-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border-left: 3px solid;
  margin-bottom: var(--space-3);
}

.alert-card.alert-error {
  background: var(--pk-error-light);
  border-color: var(--pk-error);
}

.alert-card.alert-warning {
  background: var(--pk-warning-light);
  border-color: var(--pk-warning);
}

.alert-card.alert-info {
  background: var(--pk-info-light);
  border-color: var(--pk-info);
}

.alert-icon {
  font-size: var(--text-xl);
  line-height: 1;
}

.alert-content {
  flex: 1;
}

.alert-message {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--pk-slate-dark);
  margin-bottom: 0;
}

.alert-action {
  font-size: var(--text-micro);
  color: var(--pk-blue);
  text-decoration: none;
  font-weight: var(--font-medium);
}

.alert-action:hover {
  text-decoration: underline;
}

/* ================================
 * UPLOAD SOURCE (COMPACT)
 * ================================ */

.upload-source-compact {
  margin-bottom: var(--space-3);
}

.source-compact-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--pk-gray-100);
}

.source-compact-item:last-child {
  border-bottom: none;
}

.source-compact-label {
  font-size: var(--text-xs);
  color: var(--pk-gray-500);
  font-weight: var(--font-medium);
}

.source-compact-value {
  font-size: var(--text-base);
  font-weight: var(--font-bold);
  color: var(--pk-slate-dark);
}

.source-compact-value small {
  font-size: var(--text-micro);
  color: var(--pk-slate);
  font-weight: var(--font-semibold);
  margin-left: var(--space-1);
}

.source-bar-container {
  display: flex;
  height: 6px;
  background: var(--pk-gray-100);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.source-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xs);
  font-weight: 600;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.source-bar.source-ui {
  background: var(--pk-blue);
}

.source-bar.source-api {
  background: var(--pk-slate);
}

/* ================================
 * FAILED INTEGRATIONS
 * ================================ */

.failed-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-2) 0;
}

.failed-item {
  padding: var(--space-2);
  border-bottom: 1px solid var(--pk-gray-100);
}

.failed-item:last-child {
  border-bottom: none;
}

.failed-info {
  display: flex;
  gap: var(--space-2);
  margin-bottom: 0;
}

.failed-vendor {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--pk-slate-dark);
}

.failed-shipment {
  font-size: var(--text-xs);
  color: var(--pk-gray-500);
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

.failed-error {
  font-size: var(--text-micro);
  color: var(--pk-error);
  margin-bottom: 0;
}

.failed-time {
  font-size: var(--text-micro);
  color: var(--pk-gray-400);
}

.view-all-link {
  display: inline-block;
  font-size: var(--text-micro);
  color: var(--pk-blue);
  text-decoration: none;
  font-weight: var(--font-medium);
}

.view-all-link:hover {
  text-decoration: underline;
}

/* ================================
 * ACTIVITY ENHANCEMENTS
 * ================================ */

.activity-vendor {
  color: var(--pk-gray-500);
}

.activity-source {
  font-size: var(--text-2xs);
  padding: 1px 4px;
  border-radius: 2px;
  font-weight: 600;
  text-transform: uppercase;
}

.activity-source.source-ui {
  background: var(--pk-info-light);
  color: var(--pk-info-dark);
}

.activity-source.source-api {
  background: var(--pk-success-light);
  color: var(--pk-success-dark);
}

.activity-time {
  color: var(--pk-gray-400);
}

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

@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .roi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .charts-row {
    grid-template-columns: 1fr;
  }

  .bottom-row {
    grid-template-columns: 1fr;
  }

  .chart-wrapper {
    height: 200px;
  }
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .dashboard {
    padding: var(--space-5);
  }

  .roi-grid {
    grid-template-columns: 1fr;
  }

  .charts-row {
    grid-template-columns: 1fr;
  }

  .bottom-row {
    grid-template-columns: 1fr;
  }

  .roi-value-large {
    font-size: var(--text-2xl);
  }

  .chart-wrapper {
    height: 140px;
  }

  .dash-card {
    padding: var(--space-2);
  }

  .stat-card {
    padding: var(--space-2);
  }
}
