/* ============================================================================
   FrontBrowser — shadcn/ui design system
   Vanilla-CSS port of shadcn/ui (neutral zinc base + Blue accent). Works
   alongside Tailwind CDN. The accent lives entirely in the --primary/--ring
   tokens below — change those two lines to re-skin the whole app.
   Use the semantic component classes below (.btn, .card, .input, .badge, …)
   instead of ad-hoc utility soup so the whole app reads as one system.
   ========================================================================== */

/* ------------------------------------------------------------------ Tokens */
:root {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;

  --card: 240 10% 4.9%;
  --card-foreground: 0 0% 98%;

  --popover: 240 10% 4.9%;
  --popover-foreground: 0 0% 98%;

  --primary: 217.2 91.2% 59.8%;
  --primary-foreground: 222.2 47.4% 11.2%;

  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;

  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;

  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;

  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 98%;

  --success: 142 71% 45%;
  --success-foreground: 0 0% 98%;

  --warning: 38 92% 50%;
  --warning-foreground: 48 96% 5%;

  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --ring: 217.2 91.2% 59.8%;

  --radius: 0.5rem;
}

/* Optional light theme — activate with <html data-theme="light"> */
:root[data-theme="light"] {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 221.2 83.2% 53.3%;
  --primary-foreground: 210 40% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 221.2 83.2% 53.3%;
}

/* --------------------------------------------------------------- Base */
html { color-scheme: dark; }
body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Convenience token-mapped utilities (so existing markup can opt in fast) */
.bg-background { background-color: hsl(var(--background)); }
.bg-card       { background-color: hsl(var(--card)); }
.bg-muted      { background-color: hsl(var(--muted)); }
.bg-primary    { background-color: hsl(var(--primary)); }
.text-foreground { color: hsl(var(--foreground)); }
.text-muted-foreground { color: hsl(var(--muted-foreground)); }
.text-primary  { color: hsl(var(--primary)); }
.bg-primary-soft { background-color: hsl(var(--primary) / 0.1); }
.border-l-primary { border-left-color: hsl(var(--primary)); }
.border-border { border-color: hsl(var(--border)); }
.ring-ring     { --tw-ring-color: hsl(var(--ring)); }

/* ------------------------------------------------------------------ Focus */
.focus-ring:focus-visible,
.btn:focus-visible,
.input:focus-visible,
.textarea:focus-visible,
.select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring));
}

/* ------------------------------------------------------------------ Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  height: 2.25rem;
  padding: 0 1rem;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, opacity .15s ease, box-shadow .15s ease;
}
.btn:disabled, .btn[disabled], .btn.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}
.btn svg { width: 1rem; height: 1rem; flex-shrink: 0; }

.btn-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.btn-primary:hover { background-color: hsl(var(--primary) / 0.9); }

.btn-secondary {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}
.btn-secondary:hover { background-color: hsl(var(--secondary) / 0.8); }

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

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

.btn-destructive {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}
.btn-destructive:hover { background-color: hsl(var(--destructive) / 0.9); }

.btn-success {
  background-color: hsl(var(--success));
  color: hsl(var(--success-foreground));
}
.btn-success:hover { background-color: hsl(var(--success) / 0.9); }

.btn-link {
  background-color: transparent;
  color: hsl(var(--primary));
  height: auto;
  padding: 0;
  text-underline-offset: 4px;
}
.btn-link:hover { text-decoration: underline; }

/* Sizes */
.btn-sm { height: 2rem; padding: 0 0.75rem; font-size: 0.8125rem; border-radius: calc(var(--radius) - 3px); }
.btn-xs { height: 1.75rem; padding: 0 0.5rem; font-size: 0.75rem; gap: 0.375rem; border-radius: calc(var(--radius) - 3px); }
.btn-lg { height: 2.75rem; padding: 0 2rem; }
.btn-icon { height: 2.25rem; width: 2.25rem; padding: 0; }
.btn-icon.btn-sm { height: 2rem; width: 2rem; }
.btn-icon.btn-xs { height: 1.75rem; width: 1.75rem; }

/* ------------------------------------------------------------------ Inputs */
.input,
.textarea,
.select {
  display: flex;
  width: 100%;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--input));
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  line-height: 1.25rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input, .select { height: 2.25rem; padding: 0 0.75rem; }
.textarea { min-height: 4rem; padding: 0.5rem 0.75rem; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: hsl(var(--muted-foreground)); }
.input:disabled, .textarea:disabled, .select:disabled { opacity: 0.5; cursor: not-allowed; }

.select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
}

.label {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  color: hsl(var(--foreground));
}

.checkbox {
  appearance: none;
  width: 1rem; height: 1rem;
  border-radius: 4px;
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--background));
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
.checkbox:checked {
  background-color: hsl(var(--primary));
  border-color: hsl(var(--primary));
}
.checkbox:checked::after {
  content: '';
  position: absolute;
  left: 4px; top: 1px;
  width: 5px; height: 9px;
  border: solid hsl(var(--primary-foreground));
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ------------------------------------------------------------------ Card */
.card {
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
.card-header { display: flex; flex-direction: column; gap: 0.375rem; padding: 1.25rem; }
.card-title { font-size: 1rem; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.card-description { font-size: 0.875rem; color: hsl(var(--muted-foreground)); }
.card-content { padding: 1.25rem; padding-top: 0; }
.card-footer { display: flex; align-items: center; padding: 1.25rem; padding-top: 0; }

/* ------------------------------------------------------------------ Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 9999px;
  border: 1px solid transparent;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1rem;
  white-space: nowrap;
}
.badge-primary { background-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.badge-secondary { background-color: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge-outline { color: hsl(var(--foreground)); border-color: hsl(var(--border)); }
.badge-destructive { background-color: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.badge-success { background-color: hsl(var(--success) / 0.15); color: hsl(var(--success)); border-color: hsl(var(--success) / 0.3); }
.badge-warning { background-color: hsl(var(--warning) / 0.15); color: hsl(var(--warning)); border-color: hsl(var(--warning) / 0.3); }
.badge-muted { background-color: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }

/* Status dot */
.dot { display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 9999px; flex-shrink: 0; }
.dot-success { background-color: hsl(var(--success)); }
.dot-destructive { background-color: hsl(var(--destructive)); }
.dot-warning { background-color: hsl(var(--warning)); }
.dot-muted { background-color: hsl(var(--muted-foreground)); }
.dot-primary { background-color: hsl(var(--primary)); }

/* ------------------------------------------------------------------ Table */
.table { width: 100%; font-size: 0.875rem; border-collapse: collapse; }
.table thead tr { border-bottom: 1px solid hsl(var(--border)); }
.table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  height: 3rem;
}
.table td { padding: 0.75rem 1rem; vertical-align: middle; }
.table tbody tr { border-bottom: 1px solid hsl(var(--border)); transition: background-color .12s ease; }
.table tbody tr:hover { background-color: hsl(var(--muted) / 0.5); }
.table tbody tr:last-child { border-bottom: none; }

/* ------------------------------------------------------------------ Tabs */
.tabs-list {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: calc(var(--radius) - 2px);
  background-color: hsl(var(--muted));
  padding: 0.25rem;
}
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  border-radius: calc(var(--radius) - 4px);
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  background-color: transparent;
  border: none;
  cursor: pointer;
  transition: background-color .12s ease, color .12s ease;
}
.tab:hover { color: hsl(var(--foreground)); }
.tab.active {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.15);
}

/* --------------------------------------------------------------- Separator */
.separator { height: 1px; width: 100%; background-color: hsl(var(--border)); border: 0; }
.separator-v { width: 1px; align-self: stretch; background-color: hsl(var(--border)); }

/* ------------------------------------------------------------------ Dialog */
.dialog-overlay {
  position: fixed; inset: 0;
  background-color: rgb(0 0 0 / 0.6);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.dialog {
  width: 100%;
  max-width: 32rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  box-shadow: 0 10px 38px -10px rgb(0 0 0 / 0.6), 0 10px 20px -15px rgb(0 0 0 / 0.5);
}
.dialog-header { padding: 1.5rem 1.5rem 0; display: flex; flex-direction: column; gap: 0.375rem; }
.dialog-title { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }
.dialog-description { font-size: 0.875rem; color: hsl(var(--muted-foreground)); }
.dialog-body { padding: 1.5rem; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0 1.5rem 1.5rem; }

/* ------------------------------------------------------------------ Misc */
.muted { color: hsl(var(--muted-foreground)); }
.kbd {
  display: inline-flex; align-items: center;
  border-radius: 4px;
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--muted));
  padding: 0.0625rem 0.375rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
}
code, .code, pre {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
.link { color: hsl(var(--primary)); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* --------------------------------------------------------------- Scrollbar */
* { scrollbar-width: thin; scrollbar-color: hsl(var(--border)) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: hsl(var(--border));
  border-radius: 9999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: hsl(var(--muted-foreground) / 0.5); background-clip: content-box; }

/* ------------------------------------------------------------------ Anim */
@keyframes spin { to { transform: rotate(360deg); } }
.animate-spin { animation: spin 1s linear infinite; }
@keyframes ui-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.animate-pulse-dot { animation: ui-pulse 1.2s ease-in-out infinite; }
