@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary-color: #7008E7;       /* Violet / Purple */
  --secondary-color: #5955D1;     /* Slate Indigo */
  --accent-color: #5955D1;        /* Slate Indigo */
  --bg-gradient-start: #F5F5FC;   /* Soft Ice BG Start */
  --bg-gradient-end: #EEEEF3;     /* Light Gray BG End */
  --card-bg: rgba(250, 250, 254, 0.95); /* Near White Card BG */
  --card-border: rgba(242, 242, 246, 0.9);
  --text-main: #29294B;           /* Dark Navy text */
  --text-muted: #696981;          /* Cool Slate subtext */
  --sidebar-bg: #29294B;          /* Dark Navy sidebar */
  --sidebar-text: #A6ADBF;          /* Light Slate sidebar links */
  --sidebar-active-bg: rgba(112, 8, 231, 0.12);
  --sidebar-active-text: #FDFDFF;
  --border-color: #F2F2F6;        /* Light Gray Borders */
  --transition-speed: 0.3s;
  --glass-bg: rgba(253, 253, 255, 0.75); /* Pure Ice White glass */
  --danger-color: #ef4444;
  --success-color: #22c55e;
  --warning-color: #f59e0b;
}

[data-bs-theme="dark"] {
  --bg-gradient-start: #0C243C;   /* Midnight Blue */
  --bg-gradient-end: #090d16;
  --card-bg: rgba(41, 41, 75, 0.85); /* Dark Navy card */
  --card-border: rgba(105, 105, 129, 0.3);
  --text-main: #FDFDFF;           /* Ice White text */
  --text-muted: #97A1C0;          /* Muted Blue/Gray */
  --sidebar-bg: #090d16;
  --sidebar-text: #A6ADBF;
  --sidebar-active-bg: rgba(112, 8, 231, 0.2);
  --sidebar-active-text: #FDFDFF;
  --border-color: rgba(105, 105, 129, 0.35);
  --glass-bg: rgba(41, 41, 75, 0.5);
}

html, body {
  min-height: 100%;
  margin: 0;
  padding: 0;
  overflow: auto;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  transition: background-color var(--transition-speed), color var(--transition-speed);
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
}

/* CRM Layout */
.crm-layout {
  display: block;
  min-height: 100vh;
  overflow: visible;
  position: relative;
}

.crm-sidebar {
  width: 280px;
  min-width: 280px;
  max-width: 280px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  transition: transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  height: 100vh;
  transform: translateX(0);
}

.crm-sidebar.collapsed {
  transform: translateX(-280px);
}

.crm-sidebar ~ .crm-main-content {
  margin-left: 280px;
  width: calc(100% - 280px);
  transition: margin-left var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

.crm-sidebar.collapsed ~ .crm-main-content {
  margin-left: 0;
  width: 100%;
}

.crm-main-content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: all var(--transition-speed);
  position: relative;
}

.crm-main-content main {
  min-height: calc(100vh - 88px);
}

/* Glassmorphism Panel Cards */
.crm-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.02);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  position: relative;
}

.crm-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.2);
}

.crm-stats-card {
  position: relative;
  overflow: hidden;
}

.crm-stats-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, var(--primary-color), var(--secondary-color));
}

/* Topbar glassmorphism */
.crm-topbar {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 1020;
  position: sticky;
  top: 0;
  flex-shrink: 0;
}

/* Buttons Styling */
.btn {
  border-radius: 12px;
  padding: 0.65rem 1.25rem;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border: none;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
  color: #fff;
}

.btn-primary:hover, .btn-primary:focus {
  background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
  color: #fff;
}

.btn-secondary {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

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

/* Forms styling */
.form-floating > label {
  padding-left: 1.25rem;
  color: var(--text-muted);
}

.form-control, .form-select {
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 0.85rem 1.25rem;
  background-color: var(--card-bg);
  color: var(--text-main);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  background-color: var(--card-bg);
  color: var(--text-main);
}

.required-asterisk {
  color: var(--danger-color);
  margin-left: 2px;
}

/* Advanced Data Grid Tables */
.crm-table-container {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
}

.crm-table {
  width: 100%;
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.crm-table th {
  background-color: rgba(37, 99, 235, 0.04);
  color: var(--text-main);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  padding: 1.15rem 1.25rem;
  border-bottom: 2px solid var(--border-color);
}

.crm-table td {
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  background-color: transparent;
  color: var(--text-main);
}

.crm-table tbody tr {
  transition: background-color 0.2s ease;
}

.crm-table tbody tr:hover {
  background-color: rgba(37, 99, 235, 0.02) !important;
}

/* Floating scrollbars or sticky headers */
.crm-table-sticky-header th {
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Unified Timeline */
.timeline-container {
  position: relative;
  padding-left: 45px;
}

.timeline-container::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 20px;
  width: 2px;
  background-color: var(--border-color);
}

.timeline-node {
  position: relative;
  margin-bottom: 2rem;
}

.timeline-icon-box {
  position: absolute;
  left: -45px;
  top: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  font-size: 1.1rem;
}

.timeline-card {
  padding: 1.25rem;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.01);
}

/* Custom Kanban board columns */
.kanban-board {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: 70vh;
}

.kanban-col {
  flex: 0 0 320px;
  width: 320px;
  display: flex;
  flex-direction: column;
  background-color: rgba(37, 99, 235, 0.02);
  border: 1px dashed var(--border-color);
  border-radius: 16px;
  padding: 1.25rem;
}

.kanban-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.02);
  cursor: grab;
  transition: all 0.2s ease;
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.06);
  border-color: var(--primary-color);
}

/* Theme Toggle styles */
.theme-switch {
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  color: var(--text-main);
  background-color: transparent;
  border: none;
}

.theme-switch:hover {
  background-color: rgba(37, 99, 235, 0.1);
}

/* Skeleton loader animations */
.skeleton-loader {
  width: 100%;
  height: 20px;
  background: linear-gradient(90deg, var(--border-color) 25%, var(--card-border) 50%, var(--border-color) 75%);
  background-size: 200% 100%;
  animation: loading-wave 1.5s infinite;
  border-radius: 6px;
}

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

.crm-sidebar {
  border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* Hide scrollbar for sidebar menu container while keeping scroll function active */
.crm-sidebar .overflow-y-auto::-webkit-scrollbar {
  display: none;
}
.crm-sidebar .overflow-y-auto {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.8rem 1.25rem;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 12px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.sidebar-link i {
  font-size: 1.15rem;
  color: #64748b;
  transition: color 0.2s, transform 0.2s ease;
}

.sidebar-link:hover {
  color: #f8fafc;
  background-color: rgba(255, 255, 255, 0.06);
}

.sidebar-link:hover i {
  color: #3b82f6;
  transform: scale(1.1);
}

.sidebar-link.active {
  color: #ffffff !important;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.25);
  font-weight: 600;
}

.sidebar-link.active i {
  color: #ffffff !important;
}

/* Responsive sidebars */
@media (max-width: 991.98px) {
  .crm-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-280px);
    transition: transform var(--transition-speed) ease;
    box-shadow: 0 32px 80px rgba(0,0,0,0.45);
  }
  .crm-sidebar.collapsed {
    transform: translateX(-280px);
  }
  /* When showing on mobile, apply class 'show-mobile' (toggled by JS) */
  .crm-sidebar.show-mobile {
    transform: translateX(0) !important;
  }
  .crm-sidebar ~ .crm-main-content { 
    margin-left: 0;
    width: 100%;
  }
}

/* Sidebar Legibility Enhancements */
.crm-sidebar .sidebar-heading {
  color: rgba(255, 255, 255, 0.55) !important;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.crm-sidebar small.text-muted, 
.crm-sidebar .text-muted {
  color: rgba(255, 255, 255, 0.6) !important;
}

/* Legacy Tailwind-style helper utilities used in the lead details page */
.text-main {
  color: var(--text-main) !important;
}
.font-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !important;
}
.leading-relaxed {
  line-height: 1.75 !important;
}
.text-slate-200 {
  color: #e2e8f0 !important;
}
.text-slate-300 {
  color: #cbd5e1 !important;
}
.bg-indigo-950 {
  background-color: #312e81 !important;
}
.border-indigo-800 {
  border-color: #3730a3 !important;
}
.bg-opacity-50 {
  opacity: 0.5 !important;
}
.bg-opacity-25 {
  opacity: 0.25 !important;
}
.justify-between {
  justify-content: space-between !important;
}
.border-t {
  border-top: 1px solid var(--border-color) !important;
}
.rounded-top-left-0 {
  border-top-left-radius: 0 !important;
}
.rounded-top-right-0 {
  border-top-right-radius: 0 !important;
}
.max-w-md {
  max-width: 28rem !important;
}
.max-height-30 {
  max-height: 30rem !important;
}
.space-y-2 > :not([hidden]) ~ :not([hidden]) {
  margin-top: 0.5rem !important;
}
.space-y-3 > :not([hidden]) ~ :not([hidden]) {
  margin-top: 1rem !important;
}

/* Kanban Column Accent Colors & styling */
.kanban-col {
  position: relative;
  border: 1px solid var(--card-border) !important;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.01);
  border-top: 4px solid var(--border-color) !important;
  transition: all 0.3s ease;
}

[data-bs-theme="dark"] .kanban-col {
  background: rgba(15, 23, 42, 0.4);
}

.kanban-col:hover {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.03);
}

.kanban-col.stage-new-lead {
  border-top-color: #3b82f6 !important;
}
.kanban-col.stage-connected {
  border-top-color: #f59e0b !important;
}
.kanban-col.stage-interested {
  border-top-color: #10b981 !important;
}
.kanban-col.stage-in-discussion {
  border-top-color: #8b5cf6 !important;
}
.kanban-col.stage-purchase-confirmed {
  border-top-color: #ec4899 !important;
}
.kanban-col.stage-won {
  border-top-color: #22c55e !important;
}
.kanban-col.stage-lost {
  border-top-color: #ef4444 !important;
}

/* Stage Heading Badges */
.stage-badge {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
}

.stage-new-lead .stage-badge { background-color: rgba(59, 130, 246, 0.1); color: #2563eb; }
.stage-connected .stage-badge { background-color: rgba(245, 158, 11, 0.1); color: #d97706; }
.stage-interested .stage-badge { background-color: rgba(16, 185, 129, 0.1); color: #059669; }
.stage-in-discussion .stage-badge { background-color: rgba(139, 92, 246, 0.1); color: #7c3aed; }
.stage-purchase-confirmed .stage-badge { background-color: rgba(236, 72, 153, 0.1); color: #db2777; }
.stage-won .stage-badge { background-color: rgba(34, 197, 94, 0.1); color: #16a34a; }
.stage-lost .stage-badge { background-color: rgba(239, 68, 68, 0.1); color: #dc2626; }

/* Kanban Card Styling */
.kanban-card {
  border-radius: 16px;
  padding: 1.15rem;
  border: 1px solid var(--card-border);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--card-bg);
}

.kanban-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.08);
  border-color: var(--primary-color);
}

.kanban-card h6 a {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  transition: color 0.2s;
}

.kanban-card h6 a:hover {
  color: var(--primary-color) !important;
}

/* Product Badges */
.product-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 8px;
  background-color: rgba(37, 99, 235, 0.06) !important;
  color: var(--primary-color) !important;
  border: 1px solid rgba(37, 99, 235, 0.1) !important;
}

.text-primary-dim {
  color: #3b82f6;
  opacity: 0.8;
}

/* Prevent SweetAlert2 height-auto class from spoiling the CRM's layout height */
html.swal2-height-auto,
body.swal2-height-auto {
  height: 100% !important;
  min-height: 100vh !important;
}

/* Pagination Styling */
.pagination {
  display: flex;
  padding-left: 0;
  list-style: none;
  border-radius: 12px;
  gap: 0.25rem;
  margin-bottom: 0;
}

.pagination .page-item .page-link {
  color: var(--text-main);
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.pagination .page-item:first-child .page-link,
.pagination .page-item:last-child .page-link {
  border-radius: 8px;
}

.pagination .page-item .page-link:hover {
  background-color: var(--primary-color);
  color: #fff !important;
  border-color: var(--primary-color);
}

.pagination .page-item.active .page-link {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
  border-color: var(--primary-color);
  color: #fff !important;
}

.pagination .page-item.disabled .page-link {
  color: var(--text-muted);
  background-color: var(--border-color);
  border-color: var(--border-color);
  opacity: 0.6;
  pointer-events: none;
}

/* Failsafe for giant SVGs inside navigation or paginators */
nav[role="navigation"] svg,
.pagination svg,
.w-5.h-5 {
  width: 1rem !important;
  height: 1rem !important;
  display: inline-block;
  vertical-align: middle;
}

nav[role="navigation"] .flex.justify-between.flex-1,
nav[role="navigation"] .hidden.sm\:flex-1 {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
}




