/* ── Shadcn Design Tokens ── */
:root {
  --background: #fafafa;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --secondary: #f4f4f5;
  --secondary-foreground: #18181b;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --destructive: #ef4444;
  --destructive-foreground: #fafafa;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --ring: #18181b;
  --radius: 0.5rem;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --success-fg: #065f46;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --warning-fg: #92400e;
  --error: #ef4444;
  --error-bg: #fef2f2;
  --error-fg: #991b1b;
  --info: #3b82f6;
  --info-bg: #eff6ff;
  --info-fg: #1e40af;
}

/* ── Base ── */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--foreground);
}

/* ── DaisyUI Color Utilities (replaced) ── */
.bg-base-100 { background-color: var(--card); }
.bg-base-200 { background-color: var(--background); }
.border-base-300 { border-color: var(--border); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }

/* ── Page Visibility ── */
.page { display: none; }
.page:not(.hidden) { display: block; }

/* ── Mono Font ── */
.mono { font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace; font-size: 0.8rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 500;
  height: 2.5rem;
  padding: 0 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
  background: var(--secondary);
  color: var(--secondary-foreground);
  text-decoration: none;
}
.btn:hover { opacity: 0.9; }
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}
.btn-primary:hover { background: #27272a; }

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

.btn-error {
  background: var(--destructive);
  color: var(--destructive-foreground);
  border-color: var(--destructive);
}
.btn-error:hover { background: #dc2626; }

.btn-outline {
  background: transparent;
  border-color: var(--input);
  color: var(--foreground);
}
.btn-outline:hover { background: var(--muted); }
.btn-outline.btn-error {
  color: var(--destructive);
  border-color: #fca5a5;
  background: transparent;
}
.btn-outline.btn-error:hover {
  background: var(--error-bg);
  border-color: var(--destructive);
}

.btn-sm { height: 2rem; padding: 0 0.75rem; font-size: 0.8rem; }
.btn-xs { height: 1.625rem; padding: 0 0.5rem; font-size: 0.75rem; }
.btn-circle { border-radius: 9999px; width: 2rem; height: 2rem; padding: 0; }
.btn-sm.btn-circle { width: 1.75rem; height: 1.75rem; }
.btn-disabled, .btn[disabled] { opacity: 0.5; pointer-events: none; }

/* ── Inputs ── */
.input, .select, .textarea {
  display: flex;
  width: 100%;
  height: 2.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--input);
  background: var(--card);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--foreground);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px rgba(24, 24, 27, 0.1);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-foreground); }
.input-bordered, .select-bordered, .textarea-bordered { border-color: var(--input); }
.input-sm, .select-sm { height: 2rem; font-size: 0.8rem; padding: 0.25rem 0.625rem; }

.select { appearance: none; 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='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.5rem center; padding-right: 2rem; }

.textarea { height: auto; min-height: 5rem; resize: vertical; }

/* ── Form ── */
.form-control { display: flex; flex-direction: column; }
.label { padding: 0.25rem 0; }
.label-text { font-size: 0.75rem; font-weight: 500; color: var(--muted-foreground); }

.fieldset { margin: 0; padding: 0; border: none; }
.fieldset-label { display: block; font-size: 0.75rem; font-weight: 500; color: var(--muted-foreground); margin-bottom: 0.25rem; }

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  color: var(--card-foreground);
}
.card-body { padding: 1.5rem; }
.card-title { font-size: 1rem; font-weight: 600; }
.card-actions { display: flex; flex-wrap: wrap; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.25rem;
  background: var(--secondary);
  color: var(--secondary-foreground);
  border: none;
}
.badge-sm { padding: 0.0625rem 0.5rem; font-size: 0.7rem; }
.badge-success { background: var(--success-bg); color: var(--success-fg); }
.badge-warning { background: var(--warning-bg); color: var(--warning-fg); }
.badge-error { background: var(--error-bg); color: var(--error-fg); }
.badge-primary { background: #dbeafe; color: #1e40af; }
.badge-ghost { background: var(--muted); color: var(--muted-foreground); }

/* ── Tables ── */
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; text-align: left; }
.table th { padding: 0.75rem 1rem; font-weight: 500; color: var(--muted-foreground); border-bottom: 1px solid var(--border); background: var(--background); }
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr.hover:hover { background: var(--muted); }

.table-sm th, .table-sm td { padding: 0.5rem 0.75rem; }
.table-xs th, .table-xs td { padding: 0.375rem 0.5rem; font-size: 0.75rem; }

/* ── Tabs ── */
.tabs { display: flex; }
.tabs-bordered { border-bottom: 1px solid var(--border); }
.tab {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-foreground);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--foreground); }
.tab-active, .tab.tab-active {
  color: var(--foreground);
  border-bottom-color: var(--foreground);
  font-weight: 600;
}

/* ── Navbar ── */
.navbar {
  display: flex;
  align-items: center;
  min-height: 3.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

/* ── Modal / Dialog ── */
dialog.modal {
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 1rem;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border: none;
  background: transparent;
  z-index: 50;
}
dialog.modal[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}
dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}
.modal-box {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
  width: 100%;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
}
.modal-backdrop button {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: default;
  opacity: 0;
  border: none;
  background: transparent;
}

/* ── Divider ── */
.divider {
  height: 0;
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

/* ── Toast ── */
.toast {
  position: fixed;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  z-index: 100;
}
.toast-end { right: 1rem; }
.toast-top { top: 1rem; }
.toast > * { pointer-events: auto; }

.alert {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: var(--radius);
  border: 1px solid;
  background: var(--card);
  color: var(--foreground);
}
.alert-success { background: var(--success-bg); color: var(--success-fg); border-color: #a7f3d0; }
.alert-error { background: var(--error-bg); color: var(--error-fg); border-color: #fecaca; }
.alert-info { background: var(--info-bg); color: var(--info-fg); border-color: #bfdbfe; }
.alert-warning { background: var(--warning-bg); color: var(--warning-fg); border-color: #fde68a; }

/* Toast animation */
#toast-container .alert {
  animation: toast-slide 0.3s ease-out;
}
@keyframes toast-slide {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Loading Spinner ── */
.loading { display: inline-flex; align-items: center; }
.loading-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.loading-sm .loading-spinner,
.loading-spinner.loading-sm { width: 0.875rem; height: 0.875rem; }
@keyframes spin { to { transform: rotate(360deg); } }
