/* Seller Insights & Action Centre Stylesheet */

.seller-insights-section {
  margin-top: 1.5rem;
  margin-bottom: 2rem;
}

.seller-insights-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  font-family: inherit;
  color: #0f172a;
}

/* Header */
.seller-insights-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  background: #ffffff;
  color: #0f172a;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #f1f5f9;
}

.seller-insights-header-main {
  flex: 1 1 300px;
}

.seller-insights-header-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.seller-insights-kicker {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6366f1;
}

.seller-insights-tz-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  padding: 2px 8px;
  border-radius: 4px;
}

.seller-insights-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}

.seller-insights-date-range {
  font-size: 0.85rem;
  color: #475569;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.seller-insights-sep {
  color: #cbd5e1;
}

/* Period Selector Group */
.seller-insights-period-selector {
  display: inline-flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.seller-insights-period-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  min-height: 36px;
}

.seller-insights-period-btn:hover:not(:disabled) {
  color: #0f172a;
  background: #edf2f7;
}

.seller-insights-period-btn.active {
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.seller-insights-period-btn:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.seller-insights-period-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Blocks & Headings */
.seller-insights-section-block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.seller-insights-block-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.seller-insights-block-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
}

.seller-insights-block-desc {
  margin: 0.25rem 0 0 0;
  font-size: 0.82rem;
  color: #64748b;
}

/* KPI Cards Grid */
.seller-insights-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.seller-insights-kpi-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: border-color 0.15s;
}

.seller-insights-kpi-card:hover {
  border-color: #cbd5e1;
}

.seller-insights-kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.seller-insights-kpi-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
}

.seller-insights-kpi-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.seller-insights-kpi-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: #64748b;
}

/* Badges */
.seller-insights-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.seller-insights-badge.positive {
  background: #dcfce7;
  color: #15803d;
}

.seller-insights-badge.negative {
  background: #fee2e2;
  color: #b91c1c;
}

.seller-insights-badge.neutral {
  background: #f1f5f9;
  color: #64748b;
}

/* Action Centre Grid */
.seller-insights-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.seller-insights-action-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.85rem;
}

.seller-insights-action-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.seller-insights-action-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1e293b;
}

.seller-insights-action-tag {
  font-size: 0.7rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #64748b;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.seller-insights-action-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.seller-insights-action-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.action-count-item {
  display: flex;
  flex-direction: column;
}

.action-number {
  font-size: 1.4rem;
  font-weight: 700;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.action-number.warning {
  color: #d97706;
}

.action-number.danger {
  color: #dc2626;
}

.action-number.highlight {
  color: #4f46e5;
}

.action-caption {
  font-size: 0.75rem;
  color: #64748b;
}

.seller-insights-action-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: #4f46e5;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.seller-insights-action-link:hover {
  text-decoration: underline;
  color: #3730a3;
}

.action-restricted {
  font-size: 0.8rem;
  color: #94a3b8;
  font-style: italic;
  margin: 0;
}

/* Restricted State Card */
.seller-insights-restricted-card {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.seller-insights-restricted-card h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #92400e;
}

.seller-insights-restricted-card p {
  margin: 0;
  font-size: 0.85rem;
  color: #78350f;
  line-height: 1.4;
}

/* Chart Container & Bars */
.seller-insights-chart-container {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.25rem 1rem 0.75rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.seller-insights-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-height: 140px;
  min-width: min-content;
  padding-bottom: 4px;
}

.seller-insights-bar-column {
  flex: 1 1 20px;
  min-width: 18px;
  max-width: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  outline: none;
}

.seller-insights-bar-column:focus-visible .seller-insights-bar-track {
  outline: 2px solid #6366f1;
}

.seller-insights-bar-track {
  width: 100%;
  height: 110px;
  display: flex;
  align-items: flex-end;
  background: #edf2f7;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
}

.seller-insights-bar-fill {
  width: 100%;
  transition: height 0.3s ease-in-out;
  border-radius: 4px 4px 0 0;
}

.seller-insights-bar-fill.active-fill {
  background: linear-gradient(180deg, #6366f1 0%, #4338ca 100%);
}

.seller-insights-bar-fill.zero-fill {
  background: #cbd5e1;
}

.seller-insights-bar-column:hover .seller-insights-bar-fill.active-fill {
  background: #4f46e5;
}

.seller-insights-bar-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: #64748b;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Table styling & accordion */
.seller-insights-table-accordion {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
}

.seller-insights-table-accordion summary {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  user-select: none;
}

.seller-insights-table-accordion summary:hover {
  color: #0f172a;
}

.seller-insights-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.seller-insights-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.seller-insights-table th,
.seller-insights-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
}

.seller-insights-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.seller-insights-table tbody tr:hover {
  background: #f8fafc;
}

.seller-insights-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.seller-insights-table .rank-col {
  width: 60px;
  color: #64748b;
  font-weight: 600;
}

.seller-insights-table .title-col {
  min-width: 200px;
}

/* Empty State */
.seller-insights-empty {
  padding: 1.5rem;
  text-align: center;
  color: #64748b;
  font-size: 0.9rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px dashed #cbd5e1;
  margin: 0;
}

/* Skeleton Loading */
.seller-insights-skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.seller-insights-skeleton-card {
  height: 120px;
  background: #f1f5f9;
  border-radius: 10px;
  animation: seller-insights-pulse 1.5s ease-in-out infinite;
}

@keyframes seller-insights-pulse {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

/* Error Banner */
.seller-insights-error-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem;
  background: #fef2f2;
  border: 1px solid #fee2e2;
  border-radius: 10px;
  color: #991b1b;
}

.seller-insights-error-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.seller-insights-error-content h3 {
  margin: 0 0 0.25rem 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.seller-insights-error-content p {
  margin: 0 0 0.75rem 0;
  font-size: 0.85rem;
  color: #7f1d1d;
}

.seller-insights-error-actions {
  display: flex;
  gap: 0.5rem;
}

.seller-insights-btn {
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.seller-insights-btn-primary {
  background: #dc2626;
  color: #ffffff;
  border: none;
}

.seller-insights-btn-primary:hover {
  background: #b91c1c;
}

.seller-insights-btn-secondary {
  background: #ffffff;
  color: #374151;
  border: 1px solid #cbd5e1;
}

.seller-insights-btn-secondary:hover {
  background: #f8fafc;
}

/* Footer note */
.seller-insights-footer {
  padding-top: 1rem;
  border-top: 1px solid #f1f5f9;
}

.seller-insights-footer p {
  margin: 0;
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.5;
}

/* Mobile responsiveness down to 390px */
@media (max-width: 640px) {
  .seller-insights-container {
    padding: 1rem;
  }

  .seller-insights-header {
    flex-direction: column;
    align-items: stretch;
  }

  .seller-insights-period-selector {
    display: flex;
    width: 100%;
    justify-content: stretch;
  }

  .seller-insights-period-btn {
    flex: 1;
    text-align: center;
  }

  .seller-insights-kpi-grid,
  .seller-insights-action-grid {
    grid-template-columns: 1fr;
  }

  .seller-insights-chart-bars {
    min-height: 110px;
    gap: 4px;
  }

  .seller-insights-bar-track {
    height: 80px;
  }
}
