/* ============================================================
   ANTISILO — MODERN UI OVERRIDES
   A CSS-only modernization layer over the AppStack admin theme
   ============================================================ */

/* ─── 1. DESIGN TOKENS ─────────────────────────────────── */

:root,
[data-bs-theme="light"] {
  /* Primary palette — vivid indigo instead of flat blue */
  --bs-primary: #4f46e5;
  --bs-primary-rgb: 79, 70, 229;
  --bs-primary-subtle: #a5b4fc;
  --bs-primary-bg-subtle: #ede9fe;
  --bs-primary-border-subtle: #c4b5fd;
  --bs-primary-text-emphasis: #3730a3;

  /* Softer, cleaner background */
  --bs-body-bg: #f8fafc;
  --bs-body-color: #334155;

  /* Border radius scale */
  --bs-border-radius: 0.5rem; /* 8px  – inputs, badges */
  --bs-border-radius-sm: 0.375rem; /* 6px  – small elements */
  --bs-border-radius-lg: 0.75rem; /* 12px – cards */
  --bs-border-radius-xl: 1rem; /* 16px – modals */
  --bs-border-radius-pill: 50rem;

  /* Shadow elevation system */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm:
    0 2px 6px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md:
    0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.05);
  --shadow-lg:
    0 8px 24px rgba(15, 23, 42, 0.10), 0 4px 8px rgba(15, 23, 42, 0.06);

  /* Sidebar accent tokens */
  --sidebar-bg: #1e1b33;
  --sidebar-active-bg: rgba(99, 102, 241, 0.20);
  --sidebar-active-color: #a5b4fc;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.07);
}

[data-bs-theme="dark"] {
  /* Shift primary to lighter indigo in dark mode */
  --bs-primary: #818cf8;
  --bs-primary-rgb: 129, 140, 248;
  --bs-primary-subtle: #4f46e5;
  --bs-primary-bg-subtle: #1e1b4b;
  --bs-primary-border-subtle: #3730a3;
  --bs-primary-text-emphasis: #c7d2fe;

  /* Darker, richer surface */
  --bs-body-bg: #0f172a;
  --bs-body-color: #cbd5e1;
  --bs-secondary-bg: #1e293b;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.30), 0 2px 4px rgba(0, 0, 0, 0.20);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35), 0 4px 8px rgba(0, 0, 0, 0.22);

  --sidebar-active-bg: rgba(129, 140, 248, 0.18);
  --sidebar-active-color: #818cf8;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.05);
}

/* ─── 2. TYPOGRAPHY ─────────────────────────────────────── */

body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  letter-spacing: -0.01em;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

/* ─── 3. SIDEBAR ────────────────────────────────────────── */

.sidebar,
.sidebar-content {
  background: var(--sidebar-bg, #1e1b33);
}

/* Give nav items room so the pill has inset space */
.sidebar-nav {
  padding-left: 0.625rem;
  padding-right: 0.625rem;
}

/* Base link: prep for pill shape */
.sidebar-link,
a.sidebar-link {
  border-radius: 0.5rem;
  padding: 0.625rem 1rem;
  transition: color 0.18s ease, background-color 0.18s ease;
}

/* Hover state */
.sidebar-link:hover,
a.sidebar-link:hover {
  color: rgba(226, 232, 238, 0.9) !important;
  background-color: var(--sidebar-hover-bg);
}

.sidebar-link:hover i,
.sidebar-link:hover svg,
a.sidebar-link:hover i,
a.sidebar-link:hover svg {
  color: rgba(226, 232, 238, 0.9) !important;
}

/* Active item — accent pill */
.sidebar-item.active > .sidebar-link,
.sidebar-item.active .sidebar-link:hover {
  color: var(--sidebar-active-color) !important;
  background-color: var(--sidebar-active-bg) !important;
}

.sidebar-item.active > .sidebar-link i,
.sidebar-item.active > .sidebar-link svg,
.sidebar-item.active .sidebar-link:hover i,
.sidebar-item.active .sidebar-link:hover svg {
  color: var(--sidebar-active-color) !important;
}

/* Sidebar section header labels */
.sidebar-header {
  color: #6366f1;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding-left: 1rem;
}

/* Nested dropdown links */
.sidebar-dropdown .sidebar-link,
.sidebar-dropdown a.sidebar-link {
  border-radius: 0.5rem;
}

/* ─── 4. NAVBAR ─────────────────────────────────────────── */

.navbar-bg {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.85) !important;
  border-bottom: 1px solid rgba(226, 232, 238, 0.6) !important;
  box-shadow: var(--shadow-sm) !important;
  z-index: 1030;
  position: relative;
}

[data-bs-theme="dark"] .navbar-bg {
  background: rgba(15, 23, 42, 0.85) !important;
  border-bottom: 1px solid rgba(30, 41, 59, 0.8) !important;
}

/* Search box: pill shape */
.input-group-navbar .form-control {
  border-radius: var(--bs-border-radius-pill) !important;
  background: rgba(100, 116, 139, 0.08);
  border: 1px solid transparent;
}

.input-group-navbar .btn {
  border-radius: var(--bs-border-radius-pill) !important;
  border: none;
  background: transparent;
}

.input-group-navbar .form-control:focus {
  background: var(--bs-secondary-bg);
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* Icon buttons in navbar */
.navbar .btn-light {
  background: transparent;
  border: none;
  border-radius: var(--bs-border-radius-pill);
  transition: background 0.18s ease;
}

.navbar .btn-light:hover {
  background: rgba(100, 116, 139, 0.1);
  border: none;
}

/* ─── 5. CARDS ──────────────────────────────────────────── */

.card {
  border: 1px solid rgba(226, 232, 238, 0.8);
  border-radius: var(--bs-border-radius-lg) !important;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

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

.card-header {
  background: transparent;
  border-bottom: 1px solid rgba(226, 232, 238, 0.6);
  padding: 1rem 1.25rem 0.875rem;
}

.card-title {
  font-weight: 600;
  letter-spacing: -0.01em;
}

[data-bs-theme="dark"] .card {
  border-color: rgba(30, 41, 59, 0.8);
}

[data-bs-theme="dark"] .card-header {
  border-bottom-color: rgba(30, 41, 59, 0.8);
}

/* ─── 6. BUTTONS ────────────────────────────────────────── */

.btn {
  border-radius: var(--bs-border-radius);
  font-weight: 500;
  letter-spacing: -0.01em;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.12s ease;
}

.btn-primary {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: #4338ca;
  border-color: #4338ca;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.25);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
}

.btn-sm {
  border-radius: var(--bs-border-radius-sm);
}

.btn-lg {
  border-radius: var(--bs-border-radius-lg);
}

/* ─── 7. FORM CONTROLS ──────────────────────────────────── */

.form-control,
.form-select {
  border-radius: var(--bs-border-radius);
  border-color: #e2e8f0;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  border-color: #334155;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.18);
}

/* ─── 8. TABLES ─────────────────────────────────────────── */

.table thead th {
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.table-hover > tbody > tr:hover > * {
  background-color: rgba(79, 70, 229, 0.04);
}

[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * {
  background-color: rgba(129, 140, 248, 0.06);
}

/* ─── 9. BADGES ─────────────────────────────────────────── */

.badge {
  border-radius: var(--bs-border-radius-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ─── 10. DROPDOWNS ─────────────────────────────────────── */

.dropdown-menu {
  border-radius: var(--bs-border-radius-lg);
  border-color: rgba(226, 232, 238, 0.9);
  box-shadow: var(--shadow-lg);
  padding: 0.375rem;
}

.dropdown-item {
  border-radius: var(--bs-border-radius-sm);
  font-size: 0.875rem;
  padding: 0.45rem 0.875rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: rgba(79, 70, 229, 0.07);
  color: var(--bs-primary);
}

[data-bs-theme="dark"] .dropdown-menu {
  border-color: rgba(30, 41, 59, 0.9);
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
  background: rgba(129, 140, 248, 0.10);
  color: var(--bs-primary);
}

/* ─── 11. ALERTS ────────────────────────────────────────── */

.alert {
  border-radius: var(--bs-border-radius-lg);
  border-left-width: 4px;
}

/* ─── 12. NAV TABS ──────────────────────────────────────── */

.nav-tabs .nav-link {
  border-radius: var(--bs-border-radius) var(--bs-border-radius) 0 0;
  font-weight: 500;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-tabs .nav-link.active {
  font-weight: 600;
}

/* ─── 13. MODALS ────────────────────────────────────────── */

.modal-content {
  border-radius: var(--bs-border-radius-xl);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  border-bottom: 1px solid rgba(226, 232, 238, 0.6);
  padding: 1.25rem 1.5rem;
}

.modal-footer {
  border-top: 1px solid rgba(226, 232, 238, 0.6);
  padding: 1rem 1.5rem;
}

[data-bs-theme="dark"] .modal-header {
  border-bottom-color: rgba(30, 41, 59, 0.8);
}

[data-bs-theme="dark"] .modal-footer {
  border-top-color: rgba(30, 41, 59, 0.8);
}

/* ─── 14. CUSTOM SCROLLBAR ──────────────────────────────── */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.35);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.55);
}

/* ─── 15. MISC REFINEMENTS ──────────────────────────────── */

/* Subtle transition on the main layout wrapper */
.wrapper {
  transition: background-color 0.3s ease;
}

/* Slightly lift page content area with a subtle bg */
.main {
  background: var(--bs-body-bg);
}

/* Page content padding */
.content {
  background: var(--bs-body-bg);
}

/* Breadcrumb refinement */
.breadcrumb-item + .breadcrumb-item::before {
  opacity: 0.5;
}

/* Input group — unified radius */
.input-group > .form-control:not(:last-child),
.input-group > .form-select:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group > .form-control:not(:first-child),
.input-group > .form-select:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* List group */
.list-group-item {
  transition: background-color 0.15s ease;
}

/* Smoother page transitions via main content area */
.container-fluid {
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ─── 16. MARKDOWN BODY ─────────────────────────────────── */

.markdown-body {
  color: var(--bs-body-color);
  font-size: 0.9375rem;
  line-height: 1.7;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-top: 1.25em;
  margin-bottom: 0.5em;
  color: var(--bs-body-color);
}

.markdown-body h1 {
  font-size: 1.5rem;
}
.markdown-body h2 {
  font-size: 1.25rem;
}
.markdown-body h3 {
  font-size: 1.1rem;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol {
  margin-bottom: 0.75em;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.5em;
}

.markdown-body a {
  color: var(--bs-primary);
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body a.anchor {
  display: none;
}

.markdown-body code {
  font-size: 0.85em;
  padding: 0.15em 0.4em;
  border-radius: var(--bs-border-radius-sm);
  background: var(--bs-secondary-bg, rgba(100, 116, 139, 0.08));
  color: var(--bs-body-color);
}

.markdown-body pre {
  padding: 1rem;
  border-radius: var(--bs-border-radius);
  background: var(--bs-secondary-bg, rgba(100, 116, 139, 0.08));
  overflow-x: auto;
  margin-bottom: 1em;
}

.markdown-body pre code {
  padding: 0;
  background: none;
  font-size: 0.85em;
}

.markdown-body blockquote {
  margin: 0 0 1em;
  padding: 0.5em 1em;
  border-left: 4px solid var(--bs-primary);
  color: var(--bs-secondary-color, #64748b);
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--bs-border-color, rgba(226, 232, 238, 0.8));
  margin: 1.5em 0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1em;
  font-size: 0.9em;
}

.markdown-body th,
.markdown-body td {
  padding: 0.5em 0.75em;
  border: 1px solid var(--bs-border-color, rgba(226, 232, 238, 0.8));
  text-align: left;
}

.markdown-body th {
  font-weight: 600;
  background: var(--bs-secondary-bg, rgba(100, 116, 139, 0.06));
}

.markdown-body > :first-child {
  margin-top: 0;
}
.markdown-body > :last-child {
  margin-bottom: 0;
}
