/* ==========================================================================
   SHADCNDASHBOARD.DEV — Pure HTML/CSS/JS Design System
   Zero-dependency implementation of shadcndashboard.dev tokens, slots & UI blocks
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');

:root {
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --popover: #ffffff;
  --popover-foreground: #09090b;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --secondary: #f4f4f5;
  --secondary-foreground: #18181b;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --accent: #f4f4f5;
  --accent-foreground: #18181b;
  --destructive: #ef4444;
  --destructive-foreground: #fafafa;
  --emerald: #10b981;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --ring: #18181b;
  --sidebar: #fafafa;
  --sidebar-foreground: #09090b;
  --sidebar-border: #e4e4e7;
  --sidebar-width: 16.5rem;
  --radius: 0.5rem;
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Geist Mono', monospace;
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.07), 0 1px 2px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
}

html.dark {
  --background: #09090b;
  --foreground: #fafafa;
  --card: #121215;
  --card-foreground: #fafafa;
  --popover: #121215;
  --popover-foreground: #fafafa;
  --primary: #fafafa;
  --primary-foreground: #18181b;
  --secondary: #27272a;
  --secondary-foreground: #fafafa;
  --muted: #1c1c20;
  --muted-foreground: #a1a1aa;
  --accent: #27272a;
  --accent-foreground: #fafafa;
  --destructive: #dc2626;
  --destructive-foreground: #fafafa;
  --border: #27272a;
  --input: #27272a;
  --ring: #d4d4d8;
  --sidebar: #0d0d10;
  --sidebar-foreground: #fafafa;
  --sidebar-border: #222226;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* shadcndashboard.dev NProgress Bar */
#nprogress { pointer-events: none; }
#nprogress .bar {
  background: var(--primary);
  position: fixed;
  z-index: 1600;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Layout & Sidebar Wrapper (data-slot="sidebar-wrapper") */
[data-slot="sidebar-wrapper"] {
  display: flex;
  min-height: 100svh;
  width: 100%;
  background: var(--background);
}

.sd-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: transform 0.2s ease, width 0.2s ease;
}

.sd-sidebar-header {
  height: 60px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--sidebar-border);
}

.sd-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sd-brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--primary);
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.sd-brand-text strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.15;
}

.sd-brand-text span {
  font-size: 11px;
  color: var(--muted-foreground);
}

.sd-sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
}

.sd-nav-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  padding: 8px 10px 6px;
}

.sd-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 16px;
}

.sd-nav-item a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: calc(var(--radius) - 2px);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted-foreground);
  transition: all 0.15s ease;
}

.sd-nav-item a .sd-nav-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sd-nav-item a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sd-nav-item a:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.sd-nav-item a.active {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-xs);
}

.sd-sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Main Content Area */
.sd-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.2s ease;
}

.sd-topbar {
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--background) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sd-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sd-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sd-content {
  padding: 24px 28px 48px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* Shadcn Card (data-slot="card") */
[data-slot="card"] {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}

.sd-card-header {
  padding: 18px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sd-card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sd-card-desc {
  font-size: 12.5px;
  color: var(--muted-foreground);
  margin-top: 2px;
}

.sd-card-body {
  padding: 20px;
}

/* Shadcn Button (data-slot="button") */
[data-slot="button"], .sd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.2;
}

.sd-btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-xs);
}

.sd-btn-primary:hover {
  opacity: 0.9;
}

.sd-btn-outline {
  background: var(--background);
  color: var(--foreground);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}

.sd-btn-outline:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.sd-btn-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.sd-btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
}

.sd-btn-ghost:hover {
  background: var(--accent);
  color: var(--foreground);
}

.sd-btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.sd-btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
}

/* Shadcn Badge (data-slot="badge") */
[data-slot="badge"], .sd-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 9999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-success {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.3);
}

.badge-info, .badge-primary {
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.3);
}

.badge-destructive {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.badge-outline {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
}

.sd-ping-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* KPI Grid */
.sd-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.sd-kpi-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.sd-kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 500;
}

.sd-kpi-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.sd-kpi-sub {
  font-size: 12px;
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Shadcn Data Table (data-slot="table") */
.sd-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.sd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.sd-table th {
  text-align: left;
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-foreground);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 45%, transparent);
  white-space: nowrap;
}

.sd-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.sd-table tbody tr {
  transition: background 0.12s ease;
}

.sd-table tbody tr:hover {
  background: color-mix(in srgb, var(--muted) 40%, transparent);
}

.sd-table tbody tr:last-child td {
  border-bottom: none;
}

/* Shadcn Inputs & Forms */
.sd-label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--foreground);
}

.sd-input, .sd-select, .sd-textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 13.5px;
  background: var(--background);
  color: var(--foreground);
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}

.sd-input:focus, .sd-select:focus, .sd-textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 20%, transparent);
}

.sd-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.sd-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* Modal / Dialog (data-slot="dialog") */
.sd-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.sd-dialog-backdrop.open {
  display: flex;
}

.sd-dialog {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  animation: sdZoomIn 0.18s ease;
}

@keyframes sdZoomIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.sd-dialog-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sd-dialog-body {
  padding: 22px;
}

.sd-dialog-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: color-mix(in srgb, var(--muted) 30%, transparent);
}

/* Responsive */
@media (max-width: 1024px) {
  .sd-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .sd-sidebar { transform: translateX(-100%); }
  .sd-sidebar.mobile-open { transform: translateX(0); }
  .sd-main { margin-left: 0; }
}

@media (max-width: 640px) {
  .sd-kpi-grid, .sd-grid-2, .sd-grid-3 { grid-template-columns: 1fr; }
  .sd-content { padding: 16px; }
}
