/* ── shadcn-style CSS variables ── */
:root {
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --ring: #18181b;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --accent: #f4f4f5;
  --accent-foreground: #18181b;
  --destructive: #ef4444;
  --radius: 0.5rem;
  color-scheme: light;
}

.dark {
  --background: #09090b;
  --foreground: #fafafa;
  --card: #0a0a0c;
  --card-foreground: #fafafa;
  --muted: #27272a;
  --muted-foreground: #a1a1aa;
  --border: #27272a;
  --input: #27272a;
  --ring: #d4d4d8;
  --primary: #fafafa;
  --primary-foreground: #18181b;
  --accent: #27272a;
  --accent-foreground: #fafafa;
  --destructive: #7f1d1d;
  --radius: 0.5rem;
  color-scheme: dark;
}

/* ── Global focus-visible rings ── */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
  border-radius: calc(var(--radius) - 2px);
}
/* Inputs already have a border-radius — just apply ring */
input:focus-visible, textarea:focus-visible, select:focus-visible {
  border-color: var(--ring);
}

/* ── Button press effect ── */
button:active:not(:disabled),
[type="submit"]:active:not(:disabled),
[role="button"]:active:not(:disabled) {
  transform: scale(0.97);
  transition: transform 0.1s;
}

/* ── Card subtle shadows ── */
.bg-card {
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03), 0 1px 3px 0 rgba(0, 0, 0, 0.04);
}
.dark .bg-card {
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.15), 0 1px 3px 0 rgba(0, 0, 0, 0.2);
}

/* ── Smoother skeleton pulse ── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ── Dropdown menu animation ── */
.dropdown-menu {
  transform-origin: top left;
  transform: scale(0.95);
  opacity: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
  pointer-events: none;
}
.dropdown-menu.open {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* ── Insight section fade-in ── */
@keyframes section-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.section-fade-in {
  animation: section-fade-in 0.3s ease forwards;
}

/* ── Tooltip (data-tooltip attribute) ── */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--foreground);
  color: var(--background);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 9999;
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ── Filter select ── */
.filter-select {
  height: 36px;
  min-width: 110px;
  padding: 0 10px;
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  font-size: 13px;
  color: var(--foreground);
  cursor: pointer;
}
.filter-select:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
}

/* ── Checkbox ── */
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--background);
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── Table rows ── */
.tr-hover {
  transition: background-color 0.15s ease;
}
.tr-hover:hover {
  background-color: var(--muted);
}

/* ── Empty field badge with tooltip ── */
.empty-field-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  font-style: italic;
  cursor: help;
}
.empty-field-tooltip {
  display: none;
  position: fixed;
  z-index: 9999;
  max-width: 240px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--foreground);
  color: var(--background);
  font-size: 0.75rem;
  font-style: normal;
  line-height: 1.4;
  white-space: normal;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  pointer-events: none;
}
.empty-field-badge:hover .empty-field-tooltip {
  display: block;
}

/* ── Analysis modal ── */
@keyframes dialog-in {
  from { opacity: 0; transform: scale(0.95) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.analysis-modal {
  border: none;
  border-radius: 0.75rem;
  padding: 0;
  width: min(860px, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  background: var(--card);
  color: var(--foreground);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  overflow: hidden;
}
.analysis-modal[open] {
  display: flex;
  flex-direction: column;
  animation: dialog-in 0.2s ease;
}
.analysis-modal::backdrop {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  animation: backdrop-in 0.2s ease;
}
.analysis-modal-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 4rem);
  overflow: hidden;
}
.analysis-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.analysis-modal-body {
  overflow-y: auto;
  flex: 1;
}
.analysis-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.analysis-modal-close:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}
/* Clickable metric cards */
.metric-clickable {
  cursor: pointer;
  transition: background-color 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.metric-clickable:hover {
  border-color: var(--ring) !important;
  box-shadow: 0 0 0 1px var(--ring);
  background-color: var(--accent) !important;
}
.metric-clickable .metric-footer {
  color: var(--muted-foreground);
  transition: color 0.15s;
}
.metric-clickable:hover .metric-footer {
  color: var(--primary);
}

/* Clickable inline numbers / cells in tables */
.metric-link {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  border-radius: 3px;
  padding: 1px 4px;
  transition: background-color 0.12s, color 0.12s;
}
.metric-link:hover {
  background-color: var(--accent);
  color: var(--accent-foreground);
  text-decoration-style: solid;
}

/* ── Pagy pagination (dashboard fallback) ── */
.pagy {
  display: flex;
  gap: 4px;
  list-style: none;
}
.pagy a, .pagy .current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  font-size: 13px;
  color: var(--foreground);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.pagy a:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}
.pagy .current {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}
.pagy .gap {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  color: var(--muted-foreground);
  font-size: 13px;
}
