/* ============================================================
   PHASE 3: CONTENT DENSITY & INFORMATION HIERARCHY
   Adds visual weight tiers, skeleton states, empty states,
   smoother collapse, and tighter typography rhythm.
   ============================================================ */

/* ===== 1. CARD HIERARCHY TIERS ===== */

/* --- TIER 1: Hero card (welcome banner, primary CTA) --- */
.card-hero,
.welcome-banner {
  position: relative;
  z-index: 1;
}

/* --- TIER 2: Primary cards (Next Best Actions, KPI grid) --- */
.card-primary {
  border-left: 3px solid var(--color-primary);
  background: var(--color-surface-2);
}
.card-primary .card-header h2 {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.card-primary .card-header h2 i,
.card-primary .card-header h2 svg {
  color: var(--color-primary);
}

/* --- TIER 3: Standard cards (Policy Alerts, Getting Started) --- */
.card-standard {
  background: var(--color-surface-2);
}
.card-standard .card-header h2 {
  font-size: var(--text-base);
  font-weight: 600;
}

/* --- TIER 4: Compact cards (Recent Activity, lower-priority info) --- */
.card-compact {
  background: var(--color-surface-2);
  padding: var(--space-3) var(--space-4);
  border-color: transparent;
}
.card-compact .card-header {
  margin-bottom: var(--space-2);
}
.card-compact .card-header h2 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
}

/* ===== 2. TYPOGRAPHY HIERARCHY RHYTHM ===== */

/* Section page titles */
.section-title-row h1 {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.section-title-row .badge {
  vertical-align: middle;
}

/* Section subtitle / engine labels */
.section-subtitle {
  font-size: var(--text-sm);
  color: var(--color-primary);
  font-weight: 500;
  margin-top: calc(-1 * var(--space-2));
}

/* Card headers: tighter spacing */
.card-header {
  gap: var(--space-2);
  align-items: center;
}
.card-header h2 {
  margin: 0;
  line-height: 1.3;
}
.card-header .badge {
  margin-left: auto;
}
.card-header .card-toggle {
  margin-left: var(--space-1);
}

/* Body text: consistent line-height */
.card-body p,
.card-body span,
.card-body li {
  line-height: 1.55;
}

/* Meta / helper text */
.meta-text,
.action-meta,
.alert-time,
.activity-time,
.step-time-est,
.action-time-est {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.4;
}

/* ===== 3. SKELETON / LOADING STATES ===== */

/* Skeleton shimmer animation */
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-offset) 25%,
    oklch(from var(--color-text) l c h / 0.06) 50%,
    var(--color-surface-offset) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.8s ease-in-out infinite;
  border-radius: var(--radius-sm);
  color: transparent !important;
  pointer-events: none;
  user-select: none;
}

/* Skeleton text lines */
.skeleton-text {
  height: 0.875rem;
  margin-bottom: var(--space-1);
  border-radius: 4px;
}
.skeleton-text:last-child {
  width: 60%;
}
.skeleton-text-sm {
  height: 0.75rem;
}
.skeleton-text-lg {
  height: 1.25rem;
  margin-bottom: var(--space-2);
}

/* Skeleton circle (for avatars, icons) */
.skeleton-circle {
  border-radius: 50%;
}

/* Skeleton card: replaces content while loading */
.skeleton-card {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.skeleton-card .skeleton-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Skeleton KPI */
.skeleton-kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-5);
}

/* Loading indicator for AI-powered sections */
.loading-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: oklch(from var(--color-primary) l c h / 0.06);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-primary);
  font-weight: 500;
}
.loading-dots {
  display: inline-flex;
  gap: 3px;
}
.loading-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: loading-bounce 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.loading-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes loading-bounce {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ===== 4. EMPTY STATES ===== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-8) var(--space-6);
  gap: var(--space-3);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: oklch(from var(--color-primary) l c h / 0.08);
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}
.empty-state-icon i, .empty-state-icon svg {
  width: 28px;
  height: 28px;
}

.empty-state h3 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.empty-state p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 320px;
  line-height: 1.55;
  margin: 0;
}

.empty-state .btn {
  margin-top: var(--space-2);
}

/* Variant: muted (for collapsed sections or low-priority) */
.empty-state-muted {
  padding: var(--space-5) var(--space-4);
}
.empty-state-muted .empty-state-icon {
  width: 48px;
  height: 48px;
  background: var(--color-surface-offset);
  color: var(--color-text-faint);
}
.empty-state-muted .empty-state-icon i,
.empty-state-muted .empty-state-icon svg {
  width: 20px;
  height: 20px;
}
.empty-state-muted h3 {
  font-size: var(--text-sm);
}
.empty-state-muted p {
  font-size: var(--text-xs);
}

/* ===== 5. SMOOTHER CARD COLLAPSE ===== */

/* Override existing card-body transition for smoother feel */
.card-body {
  transition: 
    max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s ease,
    padding 0.3s ease;
  will-change: max-height, opacity;
}

.card.collapsed .card-body {
  overflow: hidden;
  max-height: 0 !important;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: 0;
}

/* Toggle icon rotation */
.card-toggle i,
.card-toggle svg {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
.card.collapsed .card-toggle i,
.card.collapsed .card-toggle svg {
  transform: rotate(0deg);
}

/* Collapsed header: subtle indicator */
.card.collapsed {
  border-color: transparent;
}
.card.collapsed .card-header {
  margin-bottom: 0;
  padding-bottom: 0;
}
.card.collapsed .card-header h2 {
  color: var(--color-text-muted);
}

/* Hover on collapsed card to hint expandability */
.card.collapsed:hover {
  border-color: oklch(from var(--color-primary) l c h / 0.15);
}
.card.collapsed:hover .card-header h2 {
  color: var(--color-text);
}

/* ===== 6. DATA DENSITY BALANCE ===== */

/* Getting Started checklist: tighter layout */
.getting-started-list,
.checklist-items {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.getting-started-list > div,
.checklist-items > div {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) 0;
}
.getting-started-list > div:last-child,
.checklist-items > div:last-child {
  border-bottom: none;
}

/* Activity list: tighter spacing */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.activity-item {
  padding: var(--space-2) 0;
  border-bottom: 1px solid oklch(from var(--color-text) l c h / 0.04);
}
.activity-item:last-child {
  border-bottom: none;
}

/* Alert list: clear separation */
.alert-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Action list: clear item boundaries */
.action-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.action-item {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
}
.action-item:first-child {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.action-item:last-child {
  border-bottom: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.action-item:only-child {
  border-radius: var(--radius-md);
}

/* Show 2 more actions: cleaner expand trigger */
.show-more-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 0.2s;
  border-top: 1px solid var(--color-border);
}
.show-more-actions:hover {
  color: var(--color-primary);
}
.show-more-actions i, .show-more-actions svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s;
}
.show-more-actions.expanded i,
.show-more-actions.expanded svg {
  transform: rotate(180deg);
}

/* ===== 7. SECTION SPACING RHYTHM ===== */

/* Dashboard section: graduated spacing between card tiers */
#section-dashboard .section-inner {
  gap: var(--space-4);
}
#section-dashboard .section-inner > .welcome-banner {
  margin-bottom: var(--space-1);
}
#section-dashboard .section-inner > .kpi-grid {
  margin-bottom: var(--space-1);
}

/* Getting Started card: visually prominent */
.card-getting-started {
  border: 1px dashed oklch(from var(--color-primary) l c h / 0.3);
  background: oklch(from var(--color-primary) l c h / 0.02);
}
.card-getting-started .card-header h2 i,
.card-getting-started .card-header h2 svg {
  color: var(--color-primary);
}

/* ===== 8. KPI CARD ENHANCEMENT ===== */

/* CRS card: emphasized as most important KPI */
.kpi-card-crs {
  grid-column: span 1;
}
.kpi-card-crs .kpi-value {
  font-size: var(--text-xl);
  font-weight: 700;
}

/* ===== 9. VISUAL SEPARATORS ===== */

/* Section divider between card groups */
.section-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-2) 0;
  opacity: 0.5;
}

/* Subtle label for card groups */
.card-group-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-faint);
  padding: var(--space-1) 0;
}

/* ===== 10. DOCUMENT SECTION DENSITY ===== */

/* Document rows: consistent density */
.doc-item,
.doc-row {
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid oklch(from var(--color-text) l c h / 0.05);
  transition: background 0.15s;
}
.doc-item:hover,
.doc-row:hover {
  background: oklch(from var(--color-primary) l c h / 0.03);
}
.doc-item:last-child,
.doc-row:last-child {
  border-bottom: none;
}

/* Document status badges: consistent sizing */
.doc-status {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* ===== 11. NOTIFICATION ITEMS DENSITY ===== */

.notif-item,
.notification-item {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid oklch(from var(--color-text) l c h / 0.05);
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  transition: background 0.15s;
}
.notif-item:hover,
.notification-item:hover {
  background: oklch(from var(--color-primary) l c h / 0.03);
}

/* ===== 12. DARK MODE ADJUSTMENTS ===== */

[data-theme="dark"] .card-primary {
  border-left-color: var(--color-primary);
}

[data-theme="dark"] .card-compact {
  border-color: oklch(from var(--color-text) l c h / 0.06);
}

[data-theme="dark"] .card-getting-started {
  border-color: oklch(from var(--color-primary) l c h / 0.2);
  background: oklch(from var(--color-primary) l c h / 0.04);
}

[data-theme="dark"] .empty-state-icon {
  background: oklch(from var(--color-primary) l c h / 0.12);
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-offset) 25%,
    oklch(from var(--color-text) l c h / 0.08) 50%,
    var(--color-surface-offset) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.8s ease-in-out infinite;
}

[data-theme="dark"] .loading-indicator {
  background: oklch(from var(--color-primary) l c h / 0.1);
}

[data-theme="dark"] .card.collapsed {
  border-color: oklch(from var(--color-text) l c h / 0.04);
}

[data-theme="dark"] .card.collapsed:hover {
  border-color: oklch(from var(--color-primary) l c h / 0.2);
}

/* ===== 13. RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 768px) {
  .card-primary .card-header h2 {
    font-size: var(--text-base);
  }
  
  .empty-state {
    padding: var(--space-6) var(--space-4);
  }
  .empty-state-icon {
    width: 52px;
    height: 52px;
  }
  .empty-state-icon i, .empty-state-icon svg {
    width: 24px;
    height: 24px;
  }
  
  .skeleton-card {
    padding: var(--space-3);
  }
  
  .action-item {
    padding: var(--space-3);
  }
}

@media (max-width: 480px) {
  .section-title-row h1 {
    font-size: var(--text-lg);
  }
  
  .empty-state p {
    max-width: 100%;
  }
}
