/* Card modules: base card, stat card, kpi card */

/* Base card */
.card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card h3 {
  margin-bottom: 16px;
  color: #1f2937;
  font-size: 18px;
  font-weight: 700;
}

/* Shared styles for metric cards */
.stat-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease;
}

.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-label {
  margin-bottom: 4px;
  color: #000;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.stat-trend.up {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.stat-trend.down {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

.stat-trend.flat {
  background: rgba(107, 114, 128, 0.12);
  color: #4b5563;
}

/* Stat card */
.stat-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 10px 20px;
  border: none;
  border-top: 4px solid var(--app-primary, #6b92ff);
}

.stat-card-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(107, 146, 255, 0.15), rgba(236, 72, 153, 0.08));
  font-size: 20px;
  line-height: 1;
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  margin-top: 2px;
}

.stat-value {
  color: var(--app-primary, #6b92ff);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.stat-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: #9ca3af;
  font-size: 12px;
}

.stat-sub {
  display: block;
}

.stat-card.c-blue {
  border-top-color: #3b82f6;
}

.stat-card.c-blue .stat-value {
  color: #3b82f6;
}

.stat-card.c-teal {
  border-top-color: #14b8a6;
}

.stat-card.c-teal .stat-value {
  color: #14b8a6;
}

.stat-card.c-purple {
  border-top-color: #a855f7;
}

.stat-card.c-purple .stat-value {
  color: #a855f7;
}

.stat-card.c-amber {
  border-top-color: #f59e0b;
}

.stat-card.c-amber .stat-value {
  color: #f59e0b;
}

.stat-card.c-green {
  border-top-color: #22c55e;
}

.stat-card.c-green .stat-value {
  color: #22c55e;
}

.stat-card.c-orange {
  border-top-color: #f97316;
}

.stat-card.c-orange .stat-value {
  color: #f97316;
}

.stat-card.c-red {
  border-top-color: #ef4444;
}

.stat-card.c-red .stat-value {
  color: #ef4444;
}

.stat-card.c-indigo {
  border-top-color: #6366f1;
}

.stat-card.c-indigo .stat-value {
  color: #6366f1;
}



/* Detail info grid - lưới thông tin meta trong section card */
.detail-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 8px 16px;
}

.detail-grid>div {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex: 1 1 180px;
  min-width: 140px;
}

.detail-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  flex-shrink: 0;
}

.detail-value {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: #111827;
  white-space: nowrap;
}

.detail-value::before {
  content: ':';
  margin-right: 2px;
  color: #9ca3af;
  font-weight: 400;
}

.detail-value--lg {
  font-size: 16px;
  font-weight: 700;
  color: var(--app-primary, #4f46e5);
}

/* Card notes - ghi chú trong card */
.card-notes {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
}

.card-notes-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 6px;
  color: #111827;
}

.card-notes-content {
  font-size: 13px;
  color: #4b5563;
  margin: 0;
  white-space: pre-wrap;
}

/* Stat section label - tiêu đề cho nhóm stat card */
.stat-section-label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Stat grid - lưới chứa stat-card với responsive */
.stat-grid {
  display: grid;
  gap: 12px;
}

.stat-grid--six {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.stat-grid--four {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 768px) {
  .stat-grid--six {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-grid--four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .stat-grid--six {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stat-grid--four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1400px) {
  .stat-grid--six {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {

  .stat-card {
    padding: 16px;
    gap: 10px;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .stat-value {
    font-size: 28px;
  }

  .stat-label {
    font-size: 11px;
  }
}

/* 2x2 Card Grid Layout - Cấu trúc card dùng chung 2 hàng 2 cột */
.card-grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
  width: 100%;
}

/* Các vị trí trong grid - mỗi vị trí dính vào góc tương ứng */
.card-grid-item-1 {
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  justify-self: start;
}

.card-grid-item-2 {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  justify-self: end;
}

.card-grid-item-3 {
  grid-column: 1;
  grid-row: 2;
  align-self: end;
  justify-self: start;
}

.card-grid-item-4 {
  grid-column: 2;
  grid-row: 2;
  align-self: end;
  justify-self: end;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .card-grid-2x2 {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 12px;
  }

  .card-grid-item-1,
  .card-grid-item-2,
  .card-grid-item-3,
  .card-grid-item-4 {
    grid-column: 1;
    grid-row: auto;
  }
}

/* Stat KPI card — card-grid-2x2 dùng làm thẻ KPI với 4 ô: label+icon (hàng 1), value+sub (hàng 2) */
.stat-kpi-card {
  background: #fff;
  border-radius: 12px;
  padding: 12px 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border-top: 4px solid var(--app-primary, #6b92ff);
  gap: 2px 12px;
  transition: all 0.2s ease;
}

.stat-kpi-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-kpi-card .stat-label {
  color: #000;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.stat-kpi-card .stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(107, 146, 255, 0.15), rgba(236, 72, 153, 0.08));
  font-size: 18px;
  line-height: 1;
}

.stat-kpi-card .stat-value {
  color: var(--app-primary, #6b92ff);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.stat-kpi-card .stat-sub {
  font-size: 12px;
  color: #9ca3af;
  white-space: nowrap;
}

/* Empty state handling - Xử lý khi không có nội dung */
.card-grid-empty {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #9ca3af;
  font-size: 14px;
  text-align: center;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px dashed #e5e7eb;
}

/* Card grid container with spacing - Container với khoảng cách */
.card-grid-container {
  margin-top: 24px;
  margin-bottom: 24px;
}

/* Card grid with section styling - Card grid với style section */
.section-card .card-grid-2x2 {
  padding: 16px;
}

/* Compact variant cho activity panel dashboard — đặt sau .section-card .card-grid-2x2 để thắng specificity */
.stat-kpi-card.stat-kpi-card--sm {
  padding: 6px 10px;
  grid-template-columns: auto auto;
  row-gap: 6px;
  column-gap: 0;
}

.stat-kpi-card--sm .stat-label {
  font-size: 10px;
}

.stat-kpi-card--sm .stat-icon {
  width: 24px;
  height: 24px;
  font-size: 12px;
  border-radius: 6px;
}

.stat-kpi-card--sm .stat-value {
  font-size: 17px;
}

.stat-kpi-card--sm .stat-sub {
  font-size: 11px;
  color: var(--gray-800);
}

.stat-kpi-card--sm .stat-trend {
  font-size: 10px;
}