/* ThreatAtlas-inspired theme tokens for judolnorekcrawler */

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

:root {
  --background: 48 33.3333% 97.0588%;
  --foreground: 48 19.6078% 20%;
  --card: 0 0% 100%;
  --card-foreground: 60 2.5641% 7.6471%;
  --muted: 44 29.4118% 90%;
  --muted-foreground: 50 2.3622% 50.1961%;
  --primary: 15.1111 55.5556% 52.3529%;
  --primary-foreground: 0 0% 100%;
  --secondary: 46.1538 22.8070% 88.8235%;
  --secondary-foreground: 50.7692 8.4967% 30%;
  --accent: 46.1538 22.8070% 88.8235%;
  --accent-foreground: 50.7692 19.4030% 13.1373%;
  --destructive: 0 84.2% 58%;
  --destructive-foreground: 0 0% 100%;
  --border: 50 7.5% 84.3137%;
  --input: 50.7692 7.9755% 88%;
  --ring: 15.1111 55.5556% 52.3529%;
  --sidebar: 51.4286 25.9259% 94.7059%;
  --sidebar-foreground: 60 2.521% 23.3333%;
  --sidebar-border: 0 0% 90%;
  --radius: 0.5rem;
}

.dark {
  --background: 60 2.7027% 14.5098%;
  --foreground: 46.1538 9.7744% 73.9216%;
  --card: 60 2.1277% 18.4314%;
  --card-foreground: 48 33.3333% 97.0588%;
  --muted: 60 3.8462% 10.1961%;
  --muted-foreground: 51.4286 8.8608% 69.0196%;
  --primary: 14.7692 63.1068% 59.6078%;
  --primary-foreground: 0 0% 100%;
  --secondary: 60 2.1277% 18.4314%;
  --secondary-foreground: 48 33.3333% 97.0588%;
  --accent: 48 10.6383% 9.2157%;
  --accent-foreground: 51.4286 25.9259% 94.7059%;
  --destructive: 0 84.2% 60%;
  --destructive-foreground: 0 0% 100%;
  --border: 60 5.0847% 23.1373%;
  --input: 52.5 5.1282% 30%;
  --ring: 14.7692 63.1068% 59.6078%;
  --sidebar: 30 3.3333% 11.7647%;
  --sidebar-foreground: 46.1538 9.7744% 73.9216%;
  --sidebar-border: 60 5.0847% 23.1373%;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Roboto Flex', 'Roboto', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}

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

/* Layout primitives */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  width: 16rem;
  flex-shrink: 0;
  background: hsl(var(--sidebar));
  border-right: 1px solid hsl(var(--sidebar-border));
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
  transition: width 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.app-sidebar.collapsed { width: 4.25rem; }
.app-sidebar.collapsed .nav-label,
.app-sidebar.collapsed .brand-text,
.app-sidebar.collapsed .group-label,
.app-sidebar.collapsed .footer-text { display: none; }
.app-sidebar.collapsed .nav-link,
.app-sidebar.collapsed .brand-link { justify-content: center; }
.app-sidebar.collapsed .nav-link .indicator { display: none; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 4rem;
  padding: 0 1.5rem;
  border-bottom: 1px solid hsl(var(--border) / 0.6);
  background: hsl(var(--background) / 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 hsl(var(--border) / 0.4);
}
.app-content {
  flex: 1;
  background-image:
    linear-gradient(135deg, hsl(var(--background)) 0%, hsl(var(--muted) / 0.35) 50%, hsl(var(--background)) 100%);
  padding: 1.5rem;
}

/* Sidebar items */
.brand-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0.75rem;
  border-radius: 0.75rem;
  text-decoration: none;
  color: hsl(var(--sidebar-foreground));
}
.brand-chip {
  width: 2.5rem; height: 2.5rem;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(var(--primary) / 0.8) 100%);
  color: hsl(var(--primary-foreground));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px hsl(var(--primary) / 0.25);
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text .title { font-weight: 700; font-size: 0.875rem; line-height: 1.1; letter-spacing: -0.01em; }
.brand-text .subtitle { font-size: 0.6875rem; color: hsl(var(--sidebar-foreground) / 0.55); font-weight: 500; }

.group-label {
  padding: 0 0.5rem;
  margin: 0.75rem 0 0.25rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: hsl(var(--sidebar-foreground) / 0.45);
  text-transform: uppercase;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--sidebar-foreground) / 0.75);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}
.nav-link .lucide { width: 1rem; height: 1rem; flex-shrink: 0; color: hsl(var(--sidebar-foreground) / 0.55); transition: color 0.15s ease; }
.nav-link:hover .lucide { color: hsl(var(--sidebar-foreground)); }
.nav-link.active {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  font-weight: 600;
}
.nav-link.active .lucide { color: hsl(var(--primary)); }
.nav-link.active .indicator {
  position: absolute;
  right: 0; top: 50%; transform: translateY(-50%);
  width: 2px; height: 60%;
  border-radius: 9999px 0 0 9999px;
  background: hsl(var(--primary));
}

/* Cards */
.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border) / 0.6);
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px hsl(0 0% 0% / 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.card.hoverable:hover {
  border-color: hsl(var(--primary) / 0.35);
  box-shadow: 0 8px 24px -8px hsl(0 0% 0% / 0.12);
}
.card-body { padding: 1.25rem; }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid hsl(var(--border) / 0.5); }
.card-title { font-size: 0.95rem; font-weight: 700; letter-spacing: -0.01em; }
.card-subtitle { font-size: 0.8125rem; color: hsl(var(--muted-foreground)); margin-top: 0.125rem; }

/* Stat cards */
.stat-card .stat-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; color: hsl(var(--muted-foreground)); text-transform: uppercase; }
.stat-card .stat-value { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.stat-card .stat-meta { font-size: 0.75rem; color: hsl(var(--muted-foreground)); margin-top: 0.25rem; font-weight: 500; }
.stat-icon {
  width: 2.5rem; height: 2.5rem; border-radius: 0.75rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}
.stat-card.hoverable:hover .stat-icon { transform: scale(1.08) rotate(4deg); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.5rem 0.95rem;
  font-size: 0.8125rem; font-weight: 600;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.75rem; gap: 0.35rem; }
.btn .lucide { width: 1rem; height: 1rem; }
.btn-sm .lucide { width: 0.875rem; height: 0.875rem; }

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  box-shadow: 0 1px 2px hsl(var(--primary) / 0.25), 0 4px 12px -4px hsl(var(--primary) / 0.35);
}
.btn-primary:hover:not(:disabled) { background: hsl(var(--primary) / 0.92); }

.btn-outline {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}
.btn-outline:hover:not(:disabled) {
  background: hsl(var(--accent));
  border-color: hsl(var(--primary) / 0.4);
  color: hsl(var(--accent-foreground));
}

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

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

.btn-success {
  background: hsl(142 60% 40%);
  color: white;
}
.btn-success:hover:not(:disabled) { background: hsl(142 60% 36%); }

/* Form elements */
.field-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: 0.375rem;
}
.field-help { font-size: 0.75rem; color: hsl(var(--muted-foreground)); margin-top: 0.375rem; }
.input, .select, .textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid hsl(var(--input));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border-radius: 0.5rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: hsl(var(--primary) / 0.6);
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.15);
}
.textarea { font-family: inherit; resize: vertical; min-height: 7rem; }
.checkbox {
  width: 1rem; height: 1rem;
  border: 1px solid hsl(var(--input));
  border-radius: 0.25rem;
  accent-color: hsl(var(--primary));
}

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  font-size: 0.7rem; font-weight: 600;
  border-radius: 9999px;
  border: 1px solid transparent;
  letter-spacing: 0.01em;
  text-transform: capitalize;
}
.badge-success { background: hsl(142 70% 96%); color: hsl(142 70% 28%); border-color: hsl(142 60% 75%); }
.dark .badge-success { background: hsl(142 60% 18% / 0.6); color: hsl(142 60% 78%); border-color: hsl(142 60% 35% / 0.5); }
.badge-failed, .badge-error, .badge-destructive { background: hsl(0 90% 96%); color: hsl(0 70% 36%); border-color: hsl(0 80% 80%); }
.dark .badge-failed, .dark .badge-error, .dark .badge-destructive { background: hsl(0 60% 25% / 0.5); color: hsl(0 80% 82%); border-color: hsl(0 70% 50% / 0.5); }
.badge-warning, .badge-captcha_required { background: hsl(45 96% 92%); color: hsl(35 80% 30%); border-color: hsl(45 90% 70%); }
.dark .badge-warning, .dark .badge-captcha_required { background: hsl(35 70% 22% / 0.55); color: hsl(45 90% 80%); border-color: hsl(35 70% 45% / 0.5); }
.badge-info, .badge-running, .badge-queued { background: hsl(212 100% 96%); color: hsl(220 60% 36%); border-color: hsl(212 90% 80%); }
.dark .badge-info, .dark .badge-running, .dark .badge-queued { background: hsl(220 50% 25% / 0.55); color: hsl(212 95% 85%); border-color: hsl(220 70% 50% / 0.5); }
.badge-muted, .badge-completed { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); border-color: hsl(var(--border)); }
.badge-admin { background: hsl(265 85% 96%); color: hsl(265 70% 35%); border-color: hsl(265 80% 80%); }
.dark .badge-admin { background: hsl(265 50% 25% / 0.55); color: hsl(265 80% 85%); border-color: hsl(265 70% 50% / 0.5); }

/* Severity dot */
.dot { width: 0.4rem; height: 0.4rem; border-radius: 9999px; display: inline-block; }
.dot-critical { background: hsl(0 84% 56%); }
.dot-high { background: hsl(25 90% 50%); }
.dot-medium { background: hsl(45 92% 44%); }
.dot-low { background: hsl(142 60% 40%); }

/* Status helpers (legacy class names from existing JS) */
.status-success, .status-completed { color: hsl(142 70% 30%); font-weight: 600; }
.status-failed, .status-error { color: hsl(0 70% 50%); font-weight: 600; }
.status-running, .status-queued { color: hsl(220 60% 50%); font-weight: 600; }
.status-captcha_required, .status-warning { color: hsl(35 80% 40%); font-weight: 600; }

/* Tables */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl thead th {
  position: sticky; top: 0; z-index: 1;
  background: hsl(var(--muted) / 0.6);
  text-align: left;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  font-weight: 700;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid hsl(var(--border) / 0.6);
}
.tbl tbody td {
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid hsl(var(--border) / 0.4);
  vertical-align: top;
}
.tbl tbody tr:hover { background: hsl(var(--muted) / 0.45); }
.tbl tbody tr:last-child td { border-bottom: 0; }

.code-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  padding: 0.18rem 0.5rem;
  border-radius: 0.35rem;
  border: 1px solid hsl(var(--border) / 0.6);
}

/* Avatar */
.avatar {
  width: 2.25rem; height: 2.25rem;
  border-radius: 9999px;
  background: hsl(var(--primary) / 0.15);
  color: hsl(var(--primary));
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.75rem;
  border: 1px solid hsl(var(--primary) / 0.25);
  flex-shrink: 0;
}
.avatar.sm { width: 1.75rem; height: 1.75rem; font-size: 0.7rem; }

/* Empty state */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 3rem 1.5rem; text-align: center;
  border: 2px dashed hsl(var(--border));
  border-radius: 0.875rem;
  background: hsl(var(--muted) / 0.25);
}
.empty .empty-icon {
  width: 4rem; height: 4rem; border-radius: 1rem;
  background: linear-gradient(135deg, hsl(var(--primary) / 0.18), hsl(var(--primary) / 0.05));
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0.85rem;
  color: hsl(var(--primary));
}
.empty h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.25rem; }
.empty p { font-size: 0.875rem; color: hsl(var(--muted-foreground)); max-width: 28rem; margin: 0 auto; }

/* Modals */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: hsl(0 0% 0% / 0.45);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.18s ease-out;
}
.modal-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 0.875rem;
  width: 100%;
  max-width: 42rem;
  max-height: 88vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px -16px hsl(0 0% 0% / 0.35);
  animation: scaleIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-card.lg { max-width: 56rem; }
.modal-card.xl { max-width: 72rem; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border) / 0.6);
}
.modal-body { padding: 1.25rem; overflow: auto; }

/* Notifications */
#toast-stack {
  position: fixed; top: 1.25rem; right: 1.25rem; z-index: 70;
  display: flex; flex-direction: column; gap: 0.5rem;
  max-width: 24rem;
}
.toast {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-left: 3px solid hsl(var(--primary));
  border-radius: 0.625rem;
  padding: 0.75rem 0.95rem;
  box-shadow: 0 16px 32px -12px hsl(0 0% 0% / 0.25);
  font-size: 0.875rem;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.success { border-left-color: hsl(142 60% 40%); }
.toast.error { border-left-color: hsl(0 80% 55%); }
.toast.warning { border-left-color: hsl(35 90% 50%); }

/* Breadcrumb */
.crumbs { display: flex; align-items: center; gap: 0.45rem; font-size: 0.875rem; color: hsl(var(--muted-foreground)); }
.crumbs a { color: inherit; text-decoration: none; transition: color 0.15s ease; }
.crumbs a:hover { color: hsl(var(--foreground)); }
.crumbs .sep { color: hsl(var(--muted-foreground) / 0.6); }
.crumbs .current { color: hsl(var(--foreground)); font-weight: 600; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(14px) scale(0.99); } to { opacity: 1; transform: none; } }
.animate-fadeIn { animation: fadeIn 0.4s ease-out both; }
.animate-fadeInUp { animation: fadeInUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) both; }
.animate-slideUp { animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }

/* Utility helpers used across pages */
.hidden { display: none !important; }
.text-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.divider { height: 1px; background: hsl(var(--border) / 0.6); margin: 1rem 0; }

.spinner {
  width: 1.05rem; height: 1.05rem; border-radius: 9999px;
  border: 2px solid hsl(var(--primary) / 0.2);
  border-top-color: hsl(var(--primary));
  animation: spin 0.85s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 768px) {
  .app-sidebar { position: fixed; transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); box-shadow: 0 8px 32px hsl(0 0% 0% / 0.25); }
}
