/*
 * djust_theming - Base Component CSS
 * Generic design system for Django apps using djust theming tokens.
 *
 * Include via: {% static 'djust_theming/css/base.css' %}
 *
 * Requires djust_theming CSS custom properties (--primary, --background, etc.)
 * to be loaded first via {{ theme_head }} or {% theme_head %}.
 */

/* ============================================
   1. Design Tokens (Extensions)
   ============================================ */

:root {
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;

  /* Type Scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 2.75rem;

  /* Font Weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Line Heights */
  --leading-tight: 1.15;
  --leading-normal: 1.5;
  --leading-relaxed: 1.7;

  /* Spacing (4px grid) */
  --space-0: 0;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-14: 3.5rem;
  --space-16: 4rem;

  /* Border Radius */
  --radius-base: var(--radius, 0.75rem);
  --radius-sm: calc(var(--radius-base) - 0.25rem);
  --radius-md: var(--radius-base);
  --radius-lg: calc(var(--radius-base) + 0.25rem);
  --radius-xl: calc(var(--radius-base) + 0.5rem);
  --radius-2xl: calc(var(--radius-base) + 1rem);
  --radius-3xl: calc(var(--radius-base) + 1.5rem);
  --radius-full: 9999px;

  /* Transitions */
  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --duration-slow: 320ms;
  --ease-default: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --navbar-height: 52px;
  --sidebar-width: 300px;
  --content-max-width: 1400px;
}


/* ============================================
   2. Color System (Bridge to theme tokens)
   ============================================ */

:root,
[data-theme="light"] {
  --color-bg: hsl(var(--background, 0 0% 100%));
  --color-bg-subtle: hsl(var(--muted, 240 5% 96%));
  --color-bg-card: hsl(var(--card, 0 0% 100%));
  --color-bg-elevated: hsl(var(--card, 0 0% 100%) / 0.9);

  --color-surface: hsl(var(--secondary, 240 5% 96%));
  --color-surface-hover: hsl(var(--accent, 240 5% 96%));
  --color-surface-active: hsl(var(--muted, 240 5% 96%));

  --color-border: hsl(var(--border, 240 6% 90%));
  --color-border-subtle: hsl(var(--border, 240 6% 90%) / 0.5);
  --color-border-strong: hsl(var(--border, 240 6% 90%));

  --color-text: hsl(var(--foreground, 240 10% 4%));
  --color-text-secondary: hsl(var(--muted-foreground, 240 4% 46%));
  --color-text-muted: hsl(var(--muted-foreground, 240 4% 46%));
  --color-text-inverted: hsl(var(--primary-foreground, 0 0% 98%));

  --color-primary: hsl(var(--primary, 240 6% 10%));
  --color-primary-hover: hsl(var(--primary, 240 6% 10%) / 0.9);
  --color-primary-subtle: hsl(var(--primary, 240 6% 10%) / 0.1);
  --color-primary-text: hsl(var(--primary-foreground, 0 0% 98%));
  --color-primary-glow: hsl(var(--primary, 240 6% 10%) / 0.25);

  --color-success: hsl(var(--success, 142 76% 36%));
  --color-success-subtle: hsl(var(--success, 142 76% 36%) / 0.1);
  --color-warning: hsl(var(--warning, 38 92% 50%));
  --color-warning-subtle: hsl(var(--warning, 38 92% 50%) / 0.1);
  --color-danger: hsl(var(--destructive, 0 84% 60%));
  --color-danger-subtle: hsl(var(--destructive, 0 84% 60%) / 0.1);

  --color-ring: hsl(var(--ring, 240 6% 10%) / 0.4);

  --shadow-sm: 0 1px 2px 0 rgb(15 23 42 / 0.08);
  --shadow-md: 0 10px 24px -12px rgb(15 23 42 / 0.25);
  --shadow-lg: 0 24px 50px -28px rgb(15 23 42 / 0.35);
  --shadow-xl: 0 40px 80px -40px rgb(15 23 42 / 0.4);
}

[data-theme="dark"] {
  --shadow-sm: 0 2px 10px -6px rgb(0 0 0 / 0.6);
  --shadow-md: 0 18px 40px -24px rgb(0 0 0 / 0.7);
  --shadow-lg: 0 30px 60px -36px rgb(0 0 0 / 0.8);
  --shadow-xl: 0 50px 90px -50px rgb(0 0 0 / 0.85);
}


/* ============================================
   3. Base Reset & Typography
   ============================================ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: var(--leading-normal);
  transition: background-color var(--duration-normal), color var(--duration-normal);
}

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

a:hover {
  color: var(--color-text);
}


/* ============================================
   4. Layout
   ============================================ */

.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Navbar */
.navbar {
  height: var(--navbar-height);
  padding: 0 var(--space-8);
  background: hsl(var(--background, 0 0% 100%) / 0.85);
  border-bottom: 1px solid hsl(var(--border) / 0.6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 50;
  position: sticky;
  top: 0;
  box-shadow: var(--shadow-sm);
}

.navbar-inner {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}

[data-theme="dark"] .navbar {
  background: rgba(3, 7, 18, 0.85);
}

[data-theme="light"] .navbar {
  background: rgba(255, 255, 255, 0.85);
}

.navbar-brand {
  font-weight: var(--font-bold);
  font-size: var(--text-lg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  letter-spacing: -0.01em;
}

.navbar-brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--color-primary), hsl(var(--accent)));
  border-radius: var(--radius-lg);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px -16px var(--color-primary-glow);
}

.navbar-nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.nav-link {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
}

.nav-link:hover {
  color: var(--color-text);
  background: hsl(var(--accent) / 0.6);
}

.nav-link.active {
  color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.12);
  box-shadow: inset 0 0 0 1px hsl(var(--primary) / 0.25);
}

/* Main Content Area */
.main-area {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: hsl(var(--background));
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: hsl(var(--popover));
  border-right: 1px solid hsl(var(--border) / 0.6);
  padding: var(--space-6) var(--space-5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-sm);
}

.sidebar-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  font-weight: var(--font-bold);
  margin: var(--space-4) 0 var(--space-2) var(--space-2);
}

.sidebar-title:first-child {
  margin-top: 0;
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  transition: all var(--duration-fast) var(--ease-out);
  cursor: pointer;
  position: relative;
}

.sidebar-item:hover {
  background: hsl(var(--accent) / 0.6);
  color: var(--color-text);
}

.sidebar-item.active {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
  font-weight: var(--font-semibold);
  box-shadow: inset 0 0 0 1px hsl(var(--primary) / 0.25);
}

.sidebar-item-count {
  margin-left: auto;
  font-size: 0.75rem;
  background: hsl(var(--background));
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  border: 1px solid hsl(var(--border));
}

/* Content Pane */
.content-pane {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-8);
  background: var(--color-bg);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-sm);
}

/* Page Headers */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.page-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--color-text);
  margin: 0;
}

.page-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Container */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}


/* ============================================
   5. Components
   ============================================ */

/* --- Buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-lg);
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast),
    background var(--duration-fast),
    color var(--duration-fast),
    border-color var(--duration-fast);
  border: 1px solid transparent;
  line-height: 1.25;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-sm {
  padding: 0.35rem 0.6rem;
  font-size: var(--text-xs);
}

.btn-lg {
  padding: 0.85rem 1.6rem;
  font-size: var(--text-base);
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-text);
  box-shadow: 0 10px 24px -16px var(--color-primary-glow);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 12px 28px -18px var(--color-primary-glow);
}

.btn-secondary {
  background: var(--color-bg-card);
  border-color: var(--color-border-subtle);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

.btn-success {
  background: var(--color-success);
  border-color: var(--color-success);
  color: white;
}

.btn-success:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: white;
}

.btn-danger:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
}

.btn-icon-sm {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-md);
}


/* --- Cards --- */

.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border-subtle);
  background: var(--color-bg-subtle);
  font-weight: var(--font-semibold);
}

.card-header-primary {
  background: var(--color-primary);
  color: var(--color-primary-text);
}

.card-header-success {
  background: var(--color-success);
  color: white;
}

.card-body {
  padding: var(--space-5);
}

.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border-subtle);
  background: var(--color-bg-subtle);
}


/* --- Forms --- */

.form-input,
.form-select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-subtle);
  background: var(--color-bg-card);
  color: var(--color-text);
  font-size: var(--text-sm);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast), background var(--duration-fast);
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-ring);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.form-section {
  margin-bottom: var(--space-6);
}

.form-section-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-6);
}

.form-check-input {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  appearance: none;
  display: inline-grid;
  place-content: center;
  cursor: pointer;
}

.form-check-input:checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.form-check-input:checked::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--color-primary-text);
}

/* Search Input */
.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
}

.search-input {
  width: 100%;
  padding: 0.65rem 0.9rem 0.65rem 2.4rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-subtle);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--text-sm);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-ring);
}


/* --- Tables --- */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th,
.table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-border-subtle);
  text-align: left;
}

.table thead th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.table-hover tbody tr:hover {
  background: var(--color-surface);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}


/* --- Badges --- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: var(--font-medium);
  letter-spacing: 0.01em;
}

.badge-primary {
  background: var(--color-primary);
  color: white;
}

.badge-secondary {
  background: var(--color-bg-subtle);
  color: var(--color-text-secondary);
}

.badge-danger {
  background: var(--color-danger-subtle);
  color: var(--color-danger);
}

.badge-success {
  background: var(--color-success-subtle);
  color: var(--color-success);
}

.badge-warning {
  background: var(--color-warning-subtle);
  color: var(--color-warning);
}

.badge-info {
  background: hsl(var(--primary, 240 6% 10%) / 0.12);
  color: var(--color-text-secondary);
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
}

.status-active {
  background: var(--color-success-subtle);
  color: var(--color-success);
}

.status-inactive {
  background: var(--color-warning-subtle);
  color: var(--color-warning);
}


/* --- Alerts --- */

.alert {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  background: var(--color-bg-subtle);
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

.alert-success {
  border-color: var(--color-success);
  background: var(--color-success-subtle);
}

.alert-danger {
  border-color: var(--color-danger);
  background: var(--color-danger-subtle);
}

.alert-warning {
  border-color: var(--color-warning);
  background: var(--color-warning-subtle);
}

.alert-info {
  border-color: var(--color-border-strong);
  background: var(--color-bg-subtle);
}

.alert-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
}


/* --- Modals --- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: hsl(0 0% 0% / 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn var(--duration-fast) var(--ease-out);
}

.modal {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn var(--duration-normal) var(--ease-out);
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border-subtle);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: all var(--duration-fast);
  cursor: pointer;
  background: transparent;
  border: none;
}

.modal-close:hover {
  background: var(--color-bg-subtle);
  color: var(--color-text);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border-subtle);
  background: var(--color-bg-subtle);
}


/* --- Toasts --- */

.toast-container {
  position: fixed;
  bottom: var(--space-4);
  right: var(--space-4);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  animation: toastSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.hiding {
  animation: toastSlideOut 0.25s ease-in forwards;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(100%) scale(0.9); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to { opacity: 0; transform: translateX(100%) scale(0.9); }
}


/* --- Empty States --- */

.empty-state {
  padding: var(--space-10);
  text-align: center;
  background: var(--color-bg-card);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-4);
  border-radius: var(--radius-2xl);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xl);
  color: var(--color-text-secondary);
  animation: floatBounce 3s ease-in-out infinite;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-2);
}

.empty-state-message {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}


/* --- Stat Cards --- */

.stat-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: center;
  transition: all var(--duration-normal) var(--ease-out);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
}

.stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--color-text);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: var(--font-medium);
}

.stat-card.stat-success .stat-value { color: var(--color-success); }
.stat-card.stat-warning .stat-value { color: var(--color-warning); }
.stat-card.stat-danger .stat-value { color: var(--color-danger); }


/* --- List Groups --- */

.list-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.list-group-item {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
}

.list-group-flush .list-group-item {
  border-radius: 0;
  border-left: none;
  border-right: none;
}


/* --- Pagination --- */

.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4);
  border-top: 1px solid var(--color-border-subtle);
  background: var(--color-bg-subtle);
  margin-top: var(--space-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.pagination-info {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.pagination-current {
  padding: var(--space-1) var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  min-width: 2.5rem;
  text-align: center;
}

.pagination-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


/* --- Progress / Spinners --- */

.spinner-border {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 9999px;
  animation: spin 0.75s linear infinite;
}

.spinner-border-sm {
  width: 0.75rem;
  height: 0.75rem;
  border-width: 2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* --- Filter Bar --- */

.filter-bar {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-4);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-2xl);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.sort-pills {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sort-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border-subtle);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  transition: all var(--duration-fast) var(--ease-out);
}

.sort-pill:hover {
  color: var(--color-text);
  border-color: var(--color-border-strong);
}

.sort-pill.active {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  border-color: transparent;
}


/* ============================================
   6. Utility Classes
   ============================================ */

/* Text */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-center { text-align: center; }
.text-break { word-break: break-word; }

.text-muted { color: var(--color-text-muted); }
.text-foreground { color: hsl(var(--foreground)); }
.text-muted-foreground { color: hsl(var(--muted-foreground)); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }

.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }
.italic { font-style: italic; }
.small { font-size: var(--text-xs); }

.h2 { font-size: var(--text-2xl); font-weight: var(--font-semibold); margin: 0; }
.h5 { font-size: var(--text-lg); font-weight: var(--font-semibold); margin: 0; }
.h6 { font-size: var(--text-base); font-weight: var(--font-semibold); margin: 0; }

/* Background */
.bg-muted { background-color: hsl(var(--muted)); }
.bg-popover { background-color: hsl(var(--popover)); }
.surface-subtle { background: var(--color-bg-subtle); border: 1px solid var(--color-border-subtle); border-radius: var(--radius-lg); }

/* Border */
.border-border { border-color: hsl(var(--border)); }
.border-input { border-color: hsl(var(--input)); }
.ring-ring { box-shadow: 0 0 0 3px hsl(var(--ring) / 0.2); }

/* Rounded */
.rounded-theme { border-radius: var(--radius-base); }
.rounded-theme-md { border-radius: var(--radius-lg); }
.rounded-theme-lg { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Shadow */
.shadow-sm { box-shadow: var(--shadow-sm); }

/* Display */
.d-none { display: none !important; }
.d-flex { display: flex; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.flex { display: flex; }
.grid { display: grid; }

/* Flex */
.flex-col { flex-direction: column; }
.flex-1 { flex: 1 1 0; }
.shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.align-items-start { align-items: flex-start; }
.align-items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }

/* Grid */
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.row {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--space-3);
}

.col-md-3 { grid-column: span 12; }
.col-lg-8 { grid-column: span 12; }

/* Gap */
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.g-3 { gap: var(--space-3); }

/* Position */
.relative { position: relative; }
.absolute { position: absolute; }
.position-fixed { position: fixed; }
.top-0 { top: 0; }
.bottom-0 { bottom: 0; }
.end-0 { right: 0; }
.start-0 { left: 0; }

/* Margin */
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mx-2 { margin-left: var(--space-2); margin-right: var(--space-2); }
.mx-3 { margin-left: var(--space-3); margin-right: var(--space-3); }
.mx-4 { margin-left: var(--space-4); margin-right: var(--space-4); }
.my-2 { margin-top: var(--space-2); margin-bottom: var(--space-2); }
.my-3 { margin-top: var(--space-3); margin-bottom: var(--space-3); }
.my-4 { margin-top: var(--space-4); margin-bottom: var(--space-4); }
.me-1 { margin-right: var(--space-1); }
.me-2 { margin-right: var(--space-2); }
.me-3 { margin-right: var(--space-3); }
.me-4 { margin-right: var(--space-4); }
.ms-1 { margin-left: var(--space-1); }
.ms-2 { margin-left: var(--space-2); }
.ms-3 { margin-left: var(--space-3); }
.ms-4 { margin-left: var(--space-4); }

/* Padding */
.p-0 { padding: 0; }
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }
.px-1 { padding-left: var(--space-1); padding-right: var(--space-1); }
.px-2 { padding-left: var(--space-2); padding-right: var(--space-2); }
.px-3 { padding-left: var(--space-3); padding-right: var(--space-3); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-1 { padding-top: var(--space-1); padding-bottom: var(--space-1); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.py-5 { padding-top: var(--space-5); padding-bottom: var(--space-5); }

/* Sizing */
.min-h-screen { min-height: 100vh; }
.w-100 { width: 100%; }
.h-100 { height: 100%; }
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }


/* ============================================
   7. Animations
   ============================================ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

@keyframes cardSlideIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes floatBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes badgePop {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes alertSlideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes emptyStateFade {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes scaleIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.main-content { animation: fadeIn 0.3s ease-out; }
.badge { animation: badgePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.alert { animation: alertSlideDown 0.3s ease-out; }

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--color-surface) 25%, var(--color-surface-hover) 50%, var(--color-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* Loading dots */
@keyframes loadingDots {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.loading-dots span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
  margin: 0 2px;
  animation: loadingDots 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Nav link underline effect */
.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--color-primary);
  transition: width 0.2s ease, left 0.2s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
  left: 0;
}

/* Sidebar active indicator */
.sidebar-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-primary);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

.sidebar-item.active::before,
.sidebar-item:hover::before {
  transform: translateX(0);
}

/* Focus ring */
*:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-ring);
}

/* Theme transition */
html {
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ============================================
   8. Responsive Breakpoints
   ============================================ */

@media (min-width: 576px) {
  .d-sm-flex { display: flex !important; }
  .d-sm-inline { display: inline !important; }
}

@media (min-width: 768px) {
  .col-md-3 { grid-column: span 3; }
  .md\:flex-row { flex-direction: row; }
}

@media (min-width: 992px) {
  .col-lg-8 { grid-column: 3 / span 8; }
}

@media (max-width: 768px) {
  .pagination-bar {
    flex-direction: column;
    gap: var(--space-3);
  }
}
