:root {
  --brand-start: #4f46e5;
  --brand-end: #7c3aed;
  --bg-soft: #f4f4f8;
  --sidebar-bg: #1c1c2e;
  --sidebar-hover: #2a2a40;
  --sidebar-active: #2d2d4a;
  --sidebar-text: rgba(255,255,255,0.72);
  --sidebar-text-active: #fff;
  --sidebar-accent: #FF6900;
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 52px;
}

/* ---------- Base ---------- */
body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-soft);
}

/* Sidebar collapse transition - applied to body so a single class
   controls everything: sidebar width, icon position, content margin */
body, .sidebar, .main-content {
  transition: width 0.22s ease, margin-left 0.22s ease;
}

/* ---------- Sidebar layout ---------- */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 1040;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.sidebar-brand:hover { color: #fff; }
.sidebar-brand-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  padding: 10px 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 18px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  position: relative;
}
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}
.sidebar-active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  border-left: 3px solid var(--sidebar-accent);
  padding-left: 15px;
}
.sidebar-link i {
  font-size: 1rem;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}
.sidebar-link span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-link-btn {
  background: none;
  border: none;
  cursor: pointer;
}

.sidebar-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.3);
  padding: 16px 18px 4px;
}

.sidebar-badge {
  margin-left: auto;
  background: var(--sidebar-accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}

.sidebar-bottom {
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 8px 0;
  flex-shrink: 0;
}

/* Collapse toggle button - sits between brand and nav */
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 6px 12px 6px 18px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.3);
  cursor: pointer;
  font-size: 0.75rem;
  transition: color 0.12s;
  width: 100%;
}
.sidebar-collapse-btn:hover {
  color: rgba(255,255,255,0.8);
}

/* ---- Collapsed state (toggled via .sidebar-collapsed on <body>) ---- */
/* Sidebar shrinks to icon-only width */
.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}
/* Main content expands to fill the freed space */
.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-width);
}
/* Hide text labels, section headings, badge text, brand name */
.sidebar-collapsed .sidebar-brand-name,
.sidebar-collapsed .sidebar-section-label,
.sidebar-collapsed .sidebar-link span,
.sidebar-collapsed .sidebar-badge {
  display: none;
}
/* Center icons when collapsed */
.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding: 10px 0;
}
.sidebar-collapsed .sidebar-link i {
  width: auto;
}
/* Center collapse button arrow */
.sidebar-collapsed .sidebar-collapse-btn {
  justify-content: center;
  padding: 6px 0;
}
/* Center brand logo */
.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 18px 0 16px;
}
/* Show tooltip on hover when collapsed so icons remain labelled */
.sidebar-collapsed .sidebar-link[title]:hover::after {
  content: attr(title);
  position: fixed;
  left: calc(var(--sidebar-collapsed-width) + 8px);
  background: #333;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 5px;
  white-space: nowrap;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
/* Never collapse on mobile - collapse is desktop-only */
@media (max-width: 991px) {
  .sidebar-collapsed .sidebar { width: var(--sidebar-width); }
  .sidebar-collapsed .main-content { margin-left: 0; }
  .sidebar-collapsed .sidebar-brand-name,
  .sidebar-collapsed .sidebar-section-label,
  .sidebar-collapsed .sidebar-link span,
  .sidebar-collapsed .sidebar-badge { display: unset; }
  .sidebar-collapsed .sidebar-link { justify-content: flex-start; padding: 9px 18px; }
  .sidebar-collapsed .sidebar-brand { justify-content: flex-start; padding: 20px 18px 16px; }
  .sidebar-collapsed .sidebar-collapse-btn { justify-content: flex-end; padding: 6px 12px 6px 18px; }
}

/* Main content pushed right of sidebar on desktop only */
.main-content {
  min-height: 100vh;
}
@media (min-width: 992px) {
  .main-content {
    margin-left: var(--sidebar-width);
  }
}
.page-body {
  padding: 16px 14px;
}
@media (min-width: 992px) {
  .page-body {
    padding: 28px 28px;
  }
}

/* Off-canvas sidebar for mobile */
.sidebar-offcanvas {
  background: var(--sidebar-bg);
  width: var(--sidebar-width) !important;
}
.sidebar-offcanvas .offcanvas-header {
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding: 16px 18px;
}
.sidebar-offcanvas .offcanvas-body {
  padding: 0;
}
.sidebar-dropdown-up {
  position: absolute !important;
}

/* Mobile top bar (visible only below lg) */
.mobile-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--sidebar-bg);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.mobile-topbar-brand {
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
}

/* ---------- Override Bootstrap btn-primary with Pipedrive orange ---------- */
.btn-primary {
  background-color: var(--sidebar-accent);
  border-color: var(--sidebar-accent);
  color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  background-color: #e55c00;
  border-color: #e55c00;
  color: #fff;
}
.btn-primary:active {
  background-color: #cc5200 !important;
  border-color: #cc5200 !important;
}
.btn-outline-primary {
  color: var(--sidebar-accent);
  border-color: var(--sidebar-accent);
}
.btn-outline-primary:hover {
  background-color: var(--sidebar-accent);
  border-color: var(--sidebar-accent);
  color: #fff;
}

/* ---------- Kanban board ---------- */
.kanban-board {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.kanban-column {
  flex: 0 0 260px;
  width: 260px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}
@media (min-width: 992px) {
  .kanban-column {
    max-height: calc(100vh - 140px);
  }
}

@media (min-width: 992px) {
  .kanban-board {
    overflow-x: hidden;
    gap: 8px;
  }
  .kanban-column {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
  }
  .kanban-column-header span:first-child {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .kanban-column-header {
    gap: 6px;
  }
}

.kanban-column-header {
  padding: 10px 12px 8px;
  font-weight: 600;
  font-size: 0.82rem;
  border-top: 3px solid #6c757d;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  background: #fff;
  gap: 6px;
}
.kanban-column-header-sub {
  font-size: 0.72rem;
  font-weight: 400;
  color: #6c757d;
  padding: 0 12px 8px;
  border-bottom: 1px solid #f1f3f5;
}

.kanban-count {
  background: #f1f3f5;
  color: #6c757d;
  font-weight: 600;
  font-size: 0.72rem;
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: 10px;
}

.kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 80px;
}
.kanban-cards.drag-over {
  background: #fff8f4;
  border-radius: 0 0 8px 8px;
}

/* ---------- Lead cards ---------- */
.lead-card {
  background: #fff;
  border: 1px solid #e9ecef;
  border-left: 3px solid var(--sidebar-accent);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: box-shadow 0.12s ease, transform 0.05s ease;
}
.lead-card:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,0.10);
  transform: translateY(-1px);
}
.lead-card.dragging {
  opacity: 0.4;
}
.lead-card-aging  { border-left-color: #ffc107; }
.lead-card-stale  { border-left-color: #dc3545; }

.lead-card-stale-indicator {
  font-size: 0.72rem;
  margin-top: 5px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.lead-card-stale-indicator-aging { color: #b45309; }
.lead-card-stale-indicator-stale { color: #dc3545; font-weight: 600; }

/* ---------- Compact pipeline view ---------- */
#pipelineCompactToggle.active {
  background-color: var(--sidebar-accent);
  color: #fff;
  border-color: var(--sidebar-accent);
}
.kanban-compact .lead-card      { padding: 6px 8px; margin-bottom: 5px; }
.kanban-compact .lead-card-title { font-size: 0.8rem; margin-bottom: 0; }
.kanban-compact .lead-card-company { font-size: 0.7rem; margin-bottom: 2px; }
.kanban-compact .lead-card-due,
.kanban-compact .lead-card-stale-indicator,
.kanban-compact .lead-card-created { font-size: 0.66rem; margin-top: 2px; }
.kanban-compact .lead-card-meta .badge { font-size: 0.68rem; }
.kanban-compact .owner-pill     { width: 20px; height: 20px; font-size: 0.6rem; }
.kanban-compact .lead-score-badge { font-size: 0.52rem; }

/* ---------- Analytics charts ---------- */
.chart-card { align-self: flex-start; }
.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}
.chart-card-header h6 { margin-bottom: 0; }
.chart-wrap { position: relative; height: 130px; }
.chart-maximize-btn {
  background: transparent;
  border: none;
  color: #adb5bd;
  font-size: 0.95rem;
  padding: 2px 4px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.chart-maximize-btn:hover { color: var(--sidebar-accent); }

/* ---------- Lead card meta ---------- */
.lead-card-title {
  font-weight: 600;
  margin-bottom: 2px;
  font-size: 0.88rem;
}
.lead-score-badge { font-size: 0.62rem; flex-shrink: 0; }
.lead-card-company { font-size: 0.78rem; color: #6c757d; margin-bottom: 5px; }
.lead-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
}
.lead-card-due    { font-size: 0.74rem; margin-top: 5px; }
.lead-card-created { font-size: 0.68rem; margin-top: 3px; }

.owner-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-start), var(--brand-end));
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
}

/* ---------- Notes / Reminders ---------- */
.note-item, .reminder-item {
  border-bottom: 1px solid #f1f1f4;
  padding: 8px 0;
}
.note-item:last-child, .reminder-item:last-child { border-bottom: none; }
.note-meta  { font-size: 0.76rem; color: #6c757d; margin-bottom: 2px; }
.note-body  { font-size: 0.88rem; }
.reminder-sent { opacity: 0.55; }
.task-item { border-bottom: 1px solid #f1f1f4; padding: 8px 0; }
.task-item:last-child { border-bottom: none; }
.task-completed { opacity: 0.55; }
.task-completed strong { text-decoration: line-through; }

/* ---------- AI search ---------- */
.ai-search-box {
  background: linear-gradient(135deg, #fff8f4, #fff3ee);
  border: 1px solid #fde8d8;
  border-radius: 10px;
  padding: 16px;
}
.ai-answer {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  padding: 14px;
  margin-top: 12px;
  font-size: 0.9rem;
}
.ai-match-item {
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.12s;
}
.ai-match-item:hover { background: var(--bg-soft); }
.ai-match-reason { font-size: 0.8rem; color: #6c757d; }
.ai-analysis-box {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #fde8d8;
  padding: 14px 16px;
  font-size: 0.9rem;
}
.ai-analysis-box p  { margin-bottom: 8px; }
.ai-analysis-box ul { margin-bottom: 8px; padding-left: 20px; }
.ai-analysis-label {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sidebar-accent);
  margin-bottom: 8px;
}
.eml-drop-zone {
  border: 2px dashed #fcd0b4;
  border-radius: 10px;
  background: #fff;
  padding: 24px;
  text-align: center;
  color: #6c757d;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.eml-drop-zone:hover, .eml-drop-zone-active {
  background: #fff8f4;
  border-color: var(--sidebar-accent);
}

/* ---------- Login / marketing ---------- */
.login-pitch {
  background: linear-gradient(160deg, var(--brand-start), var(--brand-end));
  color: #fff;
  border-radius: 14px;
  padding: 40px 36px;
  height: 100%;
}
.login-pitch h2 { font-weight: 700; }
.ai-first-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 100px;
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 14px;
}
.ai-capability-list {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,0.2);
}
.ai-capability-list .ai-capability-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.75;
  margin-bottom: 10px;
}
.ai-capability-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 0.85rem;
  margin-bottom: 9px;
  opacity: 0.95;
}
.ai-capability-item:last-child { margin-bottom: 0; }
.ai-capability-item i { margin-top: 2px; flex-shrink: 0; opacity: 0.85; }
.login-pitch ul { list-style: none; padding-left: 0; margin-top: 24px; }
.login-pitch ul li { padding-left: 28px; position: relative; margin-bottom: 14px; opacity: 0.95; }
.login-pitch ul li::before { content: "\2713"; position: absolute; left: 0; top: 0; font-weight: 700; }

/* ---------- KPI / analytics cards ---------- */
.kpi-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  padding: 16px 20px;
}
.kpi-value { font-size: 1.8rem; font-weight: 700; }
.kpi-label { color: #6c757d; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Calendar ---------- */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-dow  { font-weight: 600; font-size: 0.78rem; color: #6c757d; text-align: center; padding-bottom: 4px; }
.calendar-cell { background: #fff; border: 1px solid #e9ecef; border-radius: 6px; min-height: 100px; padding: 6px; }
.calendar-cell-empty  { background: transparent; border: none; }
.calendar-cell-today  { border-color: var(--sidebar-accent); box-shadow: 0 0 0 1px var(--sidebar-accent) inset; }
.calendar-day-num { font-size: 0.78rem; font-weight: 600; color: #6c757d; margin-bottom: 4px; }
.calendar-item {
  font-size: 0.7rem; padding: 2px 4px; border-radius: 4px; margin-bottom: 2px;
  cursor: pointer; white-space: nowrap; overflow: hidden;
  background: #fff3ee; color: var(--sidebar-accent);
}
.calendar-item-task   { background: #fff4e5; color: #b45309; }
.calendar-item-done   { opacity: 0.5; text-decoration: line-through; }
.calendar-item-more   { font-size: 0.66rem; color: #6c757d; }

/* ---------- Manual ---------- */
.manual-toc a { display: block; padding: 4px 0; color: #495057; text-decoration: none; }
.manual-toc a:hover { color: var(--sidebar-accent); }
.manual-section h4 { margin-top: 28px; scroll-margin-top: 70px; }

/* ---------- Migrate section (product.php) ---------- */
.migrate-panel { background: var(--bg-soft); border-radius: 12px; padding: 32px 28px; }
.migrate-card  { background: #fff; border-radius: 10px; padding: 24px; height: 100%; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.migrate-platforms { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.migrate-platform-badge { background: #f1f3f5; border-radius: 6px; padding: 4px 10px; font-size: 0.78rem; font-weight: 600; color: #495057; }
.migrate-steps { display: flex; align-items: flex-start; gap: 16px; margin: 20px 0; flex-wrap: wrap; }
.migrate-step  { flex: 1; min-width: 160px; text-align: center; }

/* ---------- Settings custom-field option rows ---------- */
.field-options-list .option-row { margin-bottom: 4px; }

/* ---------- Demo mode banner ---------- */
.demo-banner {
  background: #fff3cd;
  border-bottom: 2px solid #ffc107;
  color: #664d03;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.demo-banner-link {
  margin-left: auto;
  color: #664d03;
  font-weight: 600;
  text-decoration: underline;
}
.demo-banner-link:hover { color: #3d2e01; }
.sidebar-badge-demo {
  background: #ffc107;
  color: #212529;
}
.sidebar-demo-active {
  background: rgba(255,193,7,0.15);
}

/* ---------- Notif badge (legacy, kept for any inline use) ---------- */
.notif-badge {
  position: absolute; top: 0; right: -2px;
  font-size: 0.6rem; padding: 2px 5px;
}
