@import "tailwindcss";
@import "tw-animate-css";
@import "shadcn/tailwind.css";

@custom-variant dark (&:is(.dark *));

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --font-sans: var(--font-geist-sans);
  --font-mono: var(--font-geist-mono);
  --font-heading: var(--font-sans);
  --color-sidebar-ring: var(--sidebar-ring);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar: var(--sidebar);
  --color-chart-5: var(--chart-5);
  --color-chart-4: var(--chart-4);
  --color-chart-3: var(--chart-3);
  --color-chart-2: var(--chart-2);
  --color-chart-1: var(--chart-1);
  --color-ring: var(--ring);
  --color-input: var(--input);
  --color-border: var(--border);
  --color-destructive: var(--destructive);
  --color-accent-foreground: var(--accent-foreground);
  --color-accent: var(--accent);
  --color-muted-foreground: var(--muted-foreground);
  --color-muted: var(--muted);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-secondary: var(--secondary);
  --color-primary-foreground: var(--primary-foreground);
  --color-primary: var(--primary);
  --color-popover-foreground: var(--popover-foreground);
  --color-popover: var(--popover);
  --color-card-foreground: var(--card-foreground);
  --color-card: var(--card);
  --radius-sm: calc(var(--radius) * 0.6);
  --radius-md: calc(var(--radius) * 0.8);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) * 1.4);
  --radius-2xl: calc(var(--radius) * 1.8);
  --radius-3xl: calc(var(--radius) * 2.2);
  --radius-4xl: calc(var(--radius) * 2.6);
  --animate-loading-dot-bounce: loading-dot-bounce 0.9s ease-in-out infinite;
}

:root {
  --background: #f7fbff;
  --foreground: #0f1f3d;
  --card: oklch(1 0 0);
  --card-foreground: #0f1f3d;
  --popover: oklch(1 0 0);
  --popover-foreground: #0f1f3d;
  --primary: #0b55c4;
  --primary-foreground: #ffffff;
  --secondary: #eef5ff;
  --secondary-foreground: #10336e;
  --muted: #f2f7ff;
  --muted-foreground: #64748b;
  --accent: #e8f1ff;
  --accent-foreground: #0b55c4;
  --destructive: oklch(0.577 0.245 27.325);
  --border: #d8e6fb;
  --input: #d8e6fb;
  --ring: #7aa7ee;
  /* 仪表盘 / 图表：彩色序列（勿用 chroma=0 灰阶） */
  --chart-1: oklch(0.52 0.19 264);
  --chart-2: oklch(0.62 0.17 162);
  --chart-3: oklch(0.72 0.16 75);
  --chart-4: oklch(0.56 0.22 303);
  --chart-5: oklch(0.58 0.2 25);
  --radius: 0.625rem;
  --sidebar: #01266c;
  --sidebar-foreground: #f8fbff;
  --sidebar-primary: #e60012;
  --sidebar-primary-foreground: #ffffff;
  --sidebar-accent: rgb(255 255 255 / 12%);
  --sidebar-accent-foreground: #ffffff;
  --sidebar-border: rgb(255 255 255 / 14%);
  --sidebar-ring: rgb(255 255 255 / 36%);
}

.dark {
  --background: #081426;
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.205 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: #77a7ff;
  --primary-foreground: #061328;
  --secondary: #10233f;
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: #102a50;
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: rgb(148 180 220 / 24%);
  --input: rgb(148 180 220 / 28%);
  --ring: #77a7ff;
  --chart-1: oklch(0.7 0.14 264);
  --chart-2: oklch(0.72 0.13 162);
  --chart-3: oklch(0.78 0.13 75);
  --chart-4: oklch(0.68 0.17 303);
  --chart-5: oklch(0.7 0.16 25);
  --sidebar: #01266c;
  --sidebar-foreground: #f8fbff;
  --sidebar-primary: #e60012;
  --sidebar-primary-foreground: #ffffff;
  --sidebar-accent: rgb(255 255 255 / 12%);
  --sidebar-accent-foreground: #ffffff;
  --sidebar-border: rgb(255 255 255 / 14%);
  --sidebar-ring: rgb(255 255 255 / 36%);
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }
  body {
    @apply bg-background text-foreground;
  }
  html {
    @apply font-sans;
  }
}

@layer components {
  .admin-list-card {
    @apply border-border/80 bg-card shadow-sm;
  }

  .admin-list-header {
    @apply border-b border-border/70 bg-gradient-to-b from-muted/25 to-transparent pb-5;
  }

  .admin-list-title {
    @apply text-[1.05rem] font-semibold tracking-tight text-foreground;
  }

  .admin-list-content {
    @apply space-y-5;
  }

  .admin-list-toolbar {
    @apply flex w-full flex-row flex-wrap items-center gap-3;
  }

  .admin-list-field {
    @apply flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center sm:gap-2;
  }

  .admin-list-field > label {
    @apply w-auto min-w-0 shrink-0 whitespace-nowrap;
  }

  .admin-list-actions {
    @apply ml-auto flex shrink-0 flex-wrap items-center justify-end gap-2;
  }

  .admin-table-shell {
    @apply overflow-x-auto rounded-2xl border border-border/80 bg-card shadow-sm;
  }

  /* Flat table inside an existing card — same white surface, no nested panel or blue header tint */
  .admin-table-inset {
    @apply overflow-x-auto rounded-xl border border-border/80;
  }

  .admin-table-inset [data-slot="table-header"] {
    @apply bg-card;
  }

  .admin-table-inset [data-slot="table-head"][class*="sticky"],
  .admin-table-inset [data-slot="table-cell"][class*="sticky"] {
    background-color: var(--card);
  }

  .admin-table-inset [data-slot="table-row"]:hover > [data-slot="table-cell"][class*="sticky"] {
    @apply bg-muted/20;
  }

  /* Sticky columns need an opaque background so scrolled cells/headers do not show through */
  [data-slot="table-head"][class*="sticky"] {
    @apply bg-muted;
  }

  /* Match table body (white card), not page background (#f7fbff) or header muted tint */
  [data-slot="table-cell"][class*="sticky"] {
    background-color: var(--card);
  }

  [data-slot="table-row"]:hover > [data-slot="table-cell"][class*="sticky"] {
    @apply bg-muted/35;
  }

  .admin-table-toolbar {
    @apply flex items-center justify-end border-b border-border/70 bg-muted/20 px-4 py-2.5;
  }

  .admin-inline-note {
    @apply text-sm text-muted-foreground;
  }

  /* 金额列：允许换行/缩小，避免大额 truncate 或溢出裁切 */
  .admin-money-value {
    @apply min-w-0 whitespace-normal break-words [overflow-wrap:anywhere] tabular-nums leading-tight tracking-tight;
  }

  .admin-table-shell [data-slot="table-cell"].admin-money-cell {
    @apply min-w-[4.5rem] max-w-[11rem] whitespace-normal align-top leading-snug;
  }

  [data-slot="table-head"],
  [data-slot="table-cell"] {
    text-align: center;
  }

  [data-slot="table-cell"] > .flex,
  [data-slot="table-head"] > .flex {
    justify-content: center !important;
  }

  [data-slot="table-cell"] > .flex.flex-col {
    align-items: center !important;
  }

  [data-slot="table-cell"] > .flex.flex-wrap {
    justify-content: center !important;
  }

  [data-slot="table-cell"] [data-slot="badge"],
  [data-slot="table-cell"] [data-slot="switch"],
  [data-slot="table-cell"] [role="checkbox"],
  [data-slot="table-cell"] [data-slot="button"],
  [data-slot="table-cell"] > a {
    margin-inline: auto;
  }

  [data-slot="table-cell"]:has(> [data-slot="button"]),
  [data-slot="table-cell"]:has(> a),
  [data-slot="table-cell"]:has(> [role="checkbox"]),
  [data-slot="table-cell"]:has(> [data-slot="switch"]) {
    text-align: center;
  }
}

@keyframes loading-dot-bounce {
  0%,
  70%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  35% {
    transform: translateY(-48%);
    opacity: 1;
  }
}

/* 公开文档站：正文链接与强调，避免继承后台 muted 色 */
.docs-site .doc-content a:not([class]) {
  color: #0f172a;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: #cbd5e1;
  text-underline-offset: 2px;
}

.docs-site .doc-content a:not([class]):hover {
  text-decoration-color: #64748b;
}

.docs-site .doc-content strong {
  color: #0f172a;
  font-weight: 600;
}

