/* ── Core Variables ── */
:root {
  --bc-loading-color: var(--bc-primary, #0d6efd);
}

/* ── HTMX Loading Indicator ── */
.htmx-request .bc-loader,
.bc-loader.htmx-request {
  display: inline-block !important;
}
.htmx-request.bc-btn-loading {
  position: relative;
  pointer-events: none;
  color: transparent !important;
}
.htmx-request.bc-btn-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: bcSpin 0.6s linear infinite;
}
.bc-loader {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--bc-loading-color);
  border-top-color: transparent;
  border-radius: 50%;
  animation: bcSpin 0.6s linear infinite;
}
.bc-loader-sm { width: 14px; height: 14px; border-width: 1.5px; }
.bc-loader-lg { width: 32px; height: 32px; border-width: 3px; }

/* Full-page loading overlay */
.bc-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}
.bc-loading-overlay .bc-loader { width: 40px; height: 40px; border-width: 3px; }

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

/* ── HTMX Standard Indicator ── */
.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}
.htmx-request .htmx-indicator {
  opacity: 1;
}
.htmx-request.htmx-indicator {
  opacity: 1;
}
/* Spinner class for hx-indicator=".spinner" */
.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--bc-loading-color);
  border-top-color: transparent;
  border-radius: 50%;
  animation: bcSpin 0.6s linear infinite;
}
.spinner-sm {
  width: 0.75rem;
  height: 0.75rem;
  border-width: 1.5px;
}

/* ── Breadcrumbs ── */
.bc-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0 0.75rem;
  font-size: 0.8rem;
  color: var(--bc-text-muted, #6c757d);
  flex-wrap: wrap;
}
.bc-breadcrumb a {
  color: var(--bc-text-muted, #6c757d);
  text-decoration: none;
  transition: color 0.15s;
}
.bc-breadcrumb a:hover { color: var(--bc-primary, #0d6efd); }
.bc-breadcrumb .separator { color: var(--bc-border, #dee2e6); }
.bc-breadcrumb .current { color: var(--bc-text, #212529); font-weight: 500; }
[data-bs-theme="dark"] .bc-breadcrumb .current { color: var(--bc-text, #f8f9fa); }

/* ── Confirm Modal ── */
.bc-confirm-modal .modal-header {
  border-bottom: none;
  padding-bottom: 0;
}
.bc-confirm-modal .modal-footer {
  border-top: none;
  padding-top: 0;
}
.bc-confirm-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}
.bc-confirm-icon.warning { color: var(--bc-warning, #ffc107); }
.bc-confirm-icon.danger { color: var(--bc-danger, #dc3545); }
.bc-confirm-icon.info { color: var(--bc-primary, #0d6efd); }

/* ── Empty State with CTA ── */
.bc-empty-state {
  text-align: center;
  padding: 3rem 1rem;
  animation: bcFadeUp 0.4s ease;
}
.bc-empty-state .empty-icon {
  font-size: 3rem;
  color: var(--bc-text-muted, #6c757d);
  opacity: 0.5;
  margin-bottom: 1rem;
  display: block;
}
.bc-empty-state h5 {
  color: var(--bc-text-muted, #6c757d);
  margin-bottom: 0.5rem;
}
.bc-empty-state p {
  color: var(--bc-text-muted, #6c757d);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ── Form Dirty Indicator ── */
.bc-dirty-indicator {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--bc-warning, #ffc107);
  margin-left: 0.5rem;
  vertical-align: middle;
  animation: bcPulse 1.5s infinite;
}

/* ── Stat card sparkline ── */
.bc-stat-card .trend-up { color: var(--bc-success, #198754); }
.bc-stat-card .trend-down { color: var(--bc-danger, #dc3545); }

/* ── Premium Enhancements ── */

/* Glass reflection shine on cards */
.bc-stat-card, .card {
  position: relative;
  isolation: isolate;
}
.bc-stat-card::before, .card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.06) 45%, transparent 50%);
  pointer-events: none;
  z-index: 1;
  transition: transform 0.6s ease;
  transform: translateX(-100%);
}
.bc-stat-card:hover::before, .card:hover::before {
  transform: translateX(100%);
}
[data-bs-theme="dark"] .bc-stat-card::before,
[data-bs-theme="dark"] .card::before {
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.03) 45%, transparent 50%);
}

/* Premium button pulse */
.btn-primary, .btn-success, .btn-danger, .btn-warning {
  position: relative;
  overflow: hidden;
}
.btn-primary::after, .btn-success::after, .btn-danger::after, .btn-warning::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255,255,255,0.15) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.btn-primary:hover::after, .btn-success:hover::after,
.btn-danger:hover::after, .btn-warning:hover::after {
  opacity: 1;
}

/* Smooth table row animation */
.table-hover tbody tr {
  transition: all 0.15s ease;
}
.table-hover tbody tr:hover {
  transform: scale(1.002);
}

/* Badge animation */
.badge {
  transition: all 0.2s ease;
}
.badge:hover {
  transform: scale(1.05);
}

/* Modal entrance animation */
.modal.fade .modal-dialog {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
  transform: scale(0.95) translateY(20px);
  opacity: 0;
}
.modal.show .modal-dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.form-control {
  transition: all 0.2s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:focus {
  transform: translateY(-1px);
}

/* Toast slide-in */
.toast {
  animation: bcToastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes bcToastIn {
  from { opacity: 0; transform: translateX(100%) scale(0.9); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* Skeleton shimmer improvement */
.bc-skeleton {
  position: relative;
  overflow: hidden;
}
.bc-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
  animation: bcSkeletonShine 1.5s infinite;
}
@keyframes bcSkeletonShine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Page transition improvement */
.bc-page {
  animation: bcPageIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes bcPageIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bc-border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--bc-text-muted); }

/* Dropdown subtle improvement */
.dropdown-menu {
  animation: bcDropdownIn 0.15s ease;
}
@keyframes bcDropdownIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Notification dot pulse */
.bc-notif-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--bc-danger);
  animation: bcPulse 2s infinite;
}
@keyframes bcPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* Empty state illustration */
.bc-empty-state {
  animation: bcFadeUp 0.4s ease;
}
@keyframes bcFadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive table helper for mobile */
@media (max-width: 768px) {
  .table-responsive-stack td {
    display: block;
    padding: 0.4rem 0.75rem;
  }
  .table-responsive-stack td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bc-text-muted);
    display: block;
    margin-bottom: 2px;
  }
}

/* Stat card trend & link helpers */
.stat-trend-success {
  background: rgba(16, 185, 129, 0.15);
  color: #047857;
}
.stat-compare-amber { color: #b45309; }
.stat-compare-blue { color: #1e40af; }
.stat-link { text-decoration: none; font-weight: 600; }

/* Table header treatment */
.bc-table-head th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--bc-text-muted);
  border-bottom-width: 2px !important;
}

/* Soft form alert (auth pages) */
.bc-form-alert {
  border-radius: 14px;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* Print overrides */
@media print {
  .bc-topbar, .bc-sidebar, .bc-navbar, .bc-footer, .no-print {
    display: none !important;
  }
  .bc-main { margin-left: 0 !important; margin-top: 0 !important; padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
  body { background: #fff !important; }
}

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--bc-primary);
  outline-offset: 2px;
}

/* ── Notification Badge ── */
.bc-notif-badge {
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  padding: 0 4px;
}

/* ── Mobile Bottom Navigation ── */
.bc-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bc-surface, #fff);
  border-top: 1px solid var(--bc-border, #dee2e6);
  display: flex;
  justify-content: space-around;
  padding: 0.3rem 0;
  z-index: 1040;
  padding-bottom: env(safe-area-inset-bottom, 0.3rem);
}
.bc-bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.6rem;
  color: var(--bc-text-muted, #6c757d);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  transition: all 0.15s;
}
.bc-bottom-nav-item i { font-size: 1.2rem; }
.bc-bottom-nav-item.active { color: var(--bc-primary, #0d6efd); }
.bc-bottom-nav-item:hover { color: var(--bc-primary, #0d6efd); background: var(--bc-hover-bg, rgba(13,110,253,0.05)); }
@media (min-width: 992px) { .bc-bottom-nav { display: none !important; } }
[data-bs-theme="dark"] .bc-bottom-nav { background: var(--bc-surface, #1a1d23); border-top-color: var(--bc-border, #2d3039); }

@media (max-width: 991.98px) {
  .bc-main { padding-bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px)); }
}

/* ── RTL Support ── */
[dir="rtl"] .bc-sidebar { right: 0; left: auto; }
[dir="rtl"] .bc-main { margin-right: 250px; margin-left: 0; }
[dir="rtl"] .toast-container { right: auto; left: 1rem; }
[dir="rtl"] .dropdown-menu-end { right: auto; left: 0; }
[dir="rtl"] .me-auto { margin-left: auto !important; margin-right: 0 !important; }
[dir="rtl"] .ms-auto { margin-right: auto !important; margin-left: 0 !important; }
[dir="rtl"] .bc-breadcrumb .separator { transform: scaleX(-1); }
[dir="rtl"] .bc-bottom-nav { direction: ltr; }
@media (max-width: 991.98px) { [dir="rtl"] .bc-main { margin-right: 0; } }
