/* =====================================================
 * CI3-Admin-Bootstrap: Metronic Design System Theme
 * Modern, Enterprise-Grade Bootstrap 5.3 Theme
 * ===================================================== */

:root, [data-bs-theme="light"] {
  --bs-primary: #3B82F6;
  --bs-primary-rgb: 59, 130, 246;
  --bs-secondary: #6B7280;
  --bs-secondary-rgb: 107, 114, 128;
  --bs-success: #10B981;
  --bs-success-rgb: 16, 185, 129;
  --bs-danger: #EF4444;
  --bs-danger-rgb: 239, 68, 68;
  --bs-warning: #F59E0B;
  --bs-warning-rgb: 245, 158, 11;
  --bs-info: #06B6D4;
  --bs-info-rgb: 6, 182, 212;
  
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --primary-active: #1D4ED8;
  --body-bg: #F9FAFB;
  --body-color: #374151;
  --card-bg: #FFFFFF;
  --card-border: rgba(229, 231, 235, 0.8);
  --border-color: #E5E7EB;
  --sidebar-bg: #FAFBFC;
  --sidebar-border: #E5E7EB;
  --sidebar-text: #4B5563;
  --sidebar-text-active: #2563EB;
  --sidebar-bg-active: #EFF6FF;
  --header-bg: rgba(255, 255, 255, 0.8);
  --header-border: #E5E7EB;
}

[data-bs-theme="dark"], html.dark {
  --bs-primary: #3B82F6;
  --bs-primary-rgb: 59, 130, 246;
  --bs-body-bg: #0F1014;
  --bs-body-color: #D1D5DB;
  
  --primary: #3B82F6;
  --primary-hover: #60A5FA;
  --primary-active: #93C5FD;
  --body-bg: #0F1014;
  --body-color: #D1D5DB;
  --card-bg: #1E1F26;
  --card-border: #282A31;
  --border-color: #282A31;
  --sidebar-bg: #111318;
  --sidebar-border: #23242B;
  --sidebar-text: #9CA3AF;
  --sidebar-text-active: #60A5FA;
  --sidebar-bg-active: rgba(12, 27, 64, 0.6);
  --header-bg: rgba(30, 31, 38, 0.8);
  --header-border: #282A31;
}

/* Base resets & typography */
html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--body-bg) !important;
  color: var(--body-color) !important;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.875rem;
  line-height: 1.625;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Neutralize Bootstrap Reboot margins & default styles to match Tailwind design system */
h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  margin-bottom: 0;
  font-weight: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

p, ol, ul, dl {
  margin-top: 0;
  margin-bottom: 0;
}

ol, ul {
  padding-left: 0;
  list-style: none;
}

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

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 9999px; }
.dark ::-webkit-scrollbar-thumb, [data-bs-theme="dark"] ::-webkit-scrollbar-thumb { background: #2D2F37; }
::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.5rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}
.btn:focus, .btn:active { outline: none; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3); }

.btn-primary {
  background-color: #3B82F6 !important;
  border-color: #3B82F6 !important;
  color: #FFFFFF !important;
}
.btn-primary:hover {
  background-color: #2563EB !important;
  border-color: #2563EB !important;
}
.btn-primary:active {
  background-color: #1D4ED8 !important;
}

.btn-secondary {
  background-color: #F3F4F6 !important;
  border-color: transparent !important;
  color: #374151 !important;
}
.dark .btn-secondary, [data-bs-theme="dark"] .btn-secondary {
  background-color: #282A31 !important;
  color: #E5E7EB !important;
}
.btn-secondary:hover {
  background-color: #E5E7EB !important;
}
.dark .btn-secondary:hover, [data-bs-theme="dark"] .btn-secondary:hover {
  background-color: #2D2F37 !important;
}

.btn-success {
  background-color: #10B981 !important;
  border-color: #10B981 !important;
  color: #FFFFFF !important;
}
.btn-success:hover {
  background-color: #059669 !important;
  border-color: #059669 !important;
}

.btn-danger {
  background-color: #EF4444 !important;
  border-color: #EF4444 !important;
  color: #FFFFFF !important;
}
.btn-danger:hover {
  background-color: #DC2626 !important;
  border-color: #DC2626 !important;
}

.btn-outline {
  background-color: #FFFFFF !important;
  border: 1px solid #D1D5DB !important;
  color: #374151 !important;
}
.dark .btn-outline, [data-bs-theme="dark"] .btn-outline {
  background-color: transparent !important;
  border-color: #2D2F37 !important;
  color: #D1D5DB !important;
}
.btn-outline:hover {
  background-color: #F9FAFB !important;
}
.dark .btn-outline:hover, [data-bs-theme="dark"] .btn-outline:hover {
  background-color: #282A31 !important;
}

.btn-sm {
  padding: 0.375rem 0.75rem !important;
  font-size: 0.75rem !important;
  line-height: 1rem !important;
}
.btn-lg {
  padding: 0.75rem 1.5rem !important;
  font-size: 1rem !important;
}
.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0 !important;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Cards */
.card {
  background-color: var(--card-bg) !important;
  border: 1px solid var(--card-border) !important;
  border-radius: 0.75rem !important;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.03);
  transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.card:hover {
  box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
}
.dark .card:hover, [data-bs-theme="dark"] .card:hover {
  box-shadow: none;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background-color: transparent;
}
.card-body {
  padding: 1.25rem;
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  background-color: transparent;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: inherit;
  margin: 0;
}

/* Stat Cards */
.stat-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.3s ease;
}
.stat-card:hover {
  box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.06);
}
.stat-card-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-card-value {
  font-size: 1.5rem;
  line-height: 2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.stat-card-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6B7280;
}
.dark .stat-card-label, [data-bs-theme="dark"] .stat-card-label {
  color: #9CA3AF;
}

/* Progress bar fix against Bootstrap defaults */
.progress-bar {
  display: block !important;
  width: 100% !important;
  height: 0.5rem !important;
  background-color: #F3F4F6 !important;
  border-radius: 9999px !important;
  overflow: hidden !important;
}
.dark .progress-bar, [data-bs-theme="dark"] .progress-bar {
  background-color: #282A31 !important;
}
.progress-bar-fill {
  display: block !important;
  height: 100% !important;
  border-radius: 9999px !important;
  transition: all 0.5s ease-out !important;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.125rem 0.5rem;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge-primary {
  background-color: #EFF6FF !important;
  color: #2563EB !important;
}
.dark .badge-primary, [data-bs-theme="dark"] .badge-primary {
  background-color: rgba(12, 27, 64, 0.6) !important;
  border-color: rgba(30, 64, 175, 0.4) !important;
  color: #60A5FA !important;
}
.badge-success {
  background-color: #ECFDF5 !important;
  color: #059669 !important;
}
.dark .badge-success, [data-bs-theme="dark"] .badge-success {
  background-color: rgba(2, 44, 34, 0.6) !important;
  border-color: rgba(6, 95, 70, 0.4) !important;
  color: #34D399 !important;
}
.badge-danger {
  background-color: #FEF2F2 !important;
  color: #DC2626 !important;
}
.dark .badge-danger, [data-bs-theme="dark"] .badge-danger {
  background-color: rgba(69, 10, 10, 0.6) !important;
  border-color: rgba(153, 27, 27, 0.4) !important;
  color: #F87171 !important;
}
.badge-warning {
  background-color: #FFFBEB !important;
  color: #D97706 !important;
}
.dark .badge-warning, [data-bs-theme="dark"] .badge-warning {
  background-color: rgba(69, 26, 3, 0.6) !important;
  border-color: rgba(146, 64, 14, 0.4) !important;
  color: #FBBF24 !important;
}
.badge-info {
  background-color: #ECFEFF !important;
  color: #0891B2 !important;
}
.dark .badge-info, [data-bs-theme="dark"] .badge-info {
  background-color: rgba(8, 51, 68, 0.6) !important;
  border-color: rgba(21, 94, 117, 0.4) !important;
  color: #22D3EE !important;
}
.badge-gray {
  background-color: #F3F4F6 !important;
  color: #6B7280 !important;
}
.dark .badge-gray, [data-bs-theme="dark"] .badge-gray {
  background-color: #282A31 !important;
  color: #D1D5DB !important;
}

/* Forms */
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: inherit;
}
.form-input, .form-control {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  border-radius: 0.5rem;
  border: 1px solid #D1D5DB;
  background-color: #FFFFFF;
  color: #111827;
  transition: all 0.2s ease;
}
.dark .form-input, .dark .form-control, [data-bs-theme="dark"] .form-input, [data-bs-theme="dark"] .form-control {
  background-color: #1B1C22 !important;
  border-color: #2D2F37 !important;
  color: #F9FAFB !important;
}
.form-input:focus, .form-control:focus {
  outline: none;
  border-color: #60A5FA;
  box-shadow: 0 0 0 2px rgba(147, 197, 253, 0.5);
}
.form-select {
  display: block;
  width: 100%;
  padding: 0.625rem 2.5rem 0.625rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  border-radius: 0.5rem;
  border: 1px solid #D1D5DB;
  background-color: #FFFFFF;
  color: #111827;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  appearance: none;
}
.dark .form-select, [data-bs-theme="dark"] .form-select {
  background-color: #1B1C22 !important;
  border-color: #2D2F37 !important;
  color: #F9FAFB !important;
}

.form-check, input.form-check {
  display: inline-block !important;
  width: 1rem !important;
  height: 1rem !important;
  min-height: 1rem !important;
  padding: 0 !important;
  margin: 0 !important;
  vertical-align: middle !important;
}

/* Tables */
.table-auto-styled {
  width: 100%;
  text-align: left;
  font-size: 0.875rem;
}
.table-auto-styled thead {
  border-bottom: 1px solid var(--border-color);
}
.table-auto-styled thead th {
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6B7280;
  border-bottom: none !important;
  white-space: nowrap;
}
.dark .table-auto-styled thead th, [data-bs-theme="dark"] .table-auto-styled thead th {
  color: #9CA3AF;
}
.table-auto-styled tbody td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  vertical-align: middle;
}
.table-auto-styled tbody tr:hover {
  background-color: rgba(249, 250, 251, 0.6);
}
.dark .table-auto-styled tbody tr:hover, [data-bs-theme="dark"] .table-auto-styled tbody tr:hover {
  background-color: rgba(40, 42, 49, 0.4);
}

/* Pagination Styling */
.pagination {
  display: flex !important;
  align-items: center !important;
  gap: 0.25rem !important;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}
.pagination-item {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 2rem !important;
  height: 2rem !important;
  padding: 0 0.5rem !important;
  font-size: 0.75rem !important;
  font-weight: 500 !important;
  border-radius: 0.5rem !important;
  color: #4B5563 !important;
  background-color: transparent !important;
  border: 1px solid transparent !important;
  cursor: pointer !important;
  transition: all 0.15s ease-in-out !important;
  user-select: none !important;
}
.dark .pagination-item, [data-bs-theme="dark"] .pagination-item {
  color: #D1D5DB !important;
}
.pagination-item:hover:not(.active):not(.disabled):not(:disabled) {
  background-color: #F3F4F6 !important;
  color: #111827 !important;
}
.dark .pagination-item:hover:not(.active):not(.disabled):not(:disabled),
[data-bs-theme="dark"] .pagination-item:hover:not(.active):not(.disabled):not(:disabled) {
  background-color: #282A31 !important;
  color: #FFFFFF !important;
}
.pagination-item.active {
  background-color: #3B82F6 !important;
  color: #FFFFFF !important;
  font-weight: 600 !important;
}
.pagination-item:disabled,
.pagination-item.disabled {
  opacity: 0.35 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  color: #9CA3AF !important;
}
.pagination-ellipsis {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 2rem !important;
  height: 2rem !important;
  font-size: 0.75rem !important;
  color: #9CA3AF !important;
  user-select: none !important;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.modal-content {
  background-color: var(--card-bg) !important;
  border-radius: 1rem !important;
  border: 1px solid var(--card-border) !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
  width: 100%;
  max-width: 32rem;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-overlay.open .modal-content {
  transform: scale(1);
}

/* Sidebar Links */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-text);
  border-radius: 0.5rem;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}
.sidebar-link:hover {
  background-color: #F3F4F6;
  color: #111827;
}
.dark .sidebar-link:hover, [data-bs-theme="dark"] .sidebar-link:hover {
  background-color: #23242B;
  color: #FFFFFF;
}
.sidebar-link.active {
  background-color: var(--sidebar-bg-active) !important;
  color: var(--sidebar-text-active) !important;
  font-weight: 600;
}
.sidebar-section-title {
  padding: 1.25rem 0.75rem 0.5rem;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #9CA3AF;
}
.dark .sidebar-section-title, [data-bs-theme="dark"] .sidebar-section-title {
  color: #6B7280;
}

/* Dropdown Display Fix */
.dropdown-menu.show { display: block; }

