/* Auto-Lead Pro — Global Styles */

/* ── CSS Variables ── */
:root {
  --sidebar-width: 260px;
  --sidebar-collapsed: 64px;
  --header-height: 60px;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; }
a { text-decoration: none; color: inherit; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  transition: width 0.25s ease, transform 0.25s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-text,
.sidebar.collapsed .sidebar-badge { display: none; }
.sidebar.collapsed .sidebar-collapse-icon { transform: rotate(180deg); }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .nav-item .nav-icon { margin: 0; }

/* ── Nav Items ── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  margin: 1px 8px;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #9ca3af;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: #2563eb; color: #fff; }
.nav-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 0.9rem; }

.sidebar-badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
}
.badge-blue   { background: #3b82f6; color: #fff; }
.badge-green  { background: #16a34a; color: #fff; }
.badge-purple { background: #7c3aed; color: #fff; }
.badge-orange { background: #f97316; color: #fff; }

/* ── Mobile Sidebar ── */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 50;
    width: var(--sidebar-width) !important;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar.collapsed { width: var(--sidebar-width) !important; }
  .sidebar.collapsed .sidebar-text { display: inline; }
  .sidebar.collapsed .sidebar-badge { display: inline; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 9px 16px; }
  #sidebarCloseBtn { display: block !important; }
  #sidebarCollapseBtn { display: none; }
}

/* ── Mobile Bottom Nav ── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  z-index: 30;
}
@media (max-width: 1023px) {
  .mobile-bottom-nav { display: flex; }
  /* Add padding to main to avoid overlap */
  #pageContent { padding-bottom: 70px !important; }
}
.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.6rem;
  color: #6b7280;
  cursor: pointer;
  transition: color 0.15s;
  padding: 4px 0;
}
.mobile-nav-item i { font-size: 1.1rem; }
.mobile-nav-item.active { color: #2563eb; }

/* ── Cards ── */
.card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── KPI Cards ── */
.kpi-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  transition: box-shadow 0.15s, transform 0.15s;
}
.kpi-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); transform: translateY(-1px); }
.kpi-value { font-size: 1.75rem; font-weight: 700; color: #111827; }
.kpi-label { font-size: 0.8rem; color: #6b7280; margin-top: 2px; }
.kpi-change-pos { color: #16a34a; font-size: 0.8rem; font-weight: 600; }
.kpi-change-neg { color: #ef4444; font-size: 0.8rem; font-weight: 600; }

/* ── Buttons ── */
.btn-primary {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.btn-secondary:hover { background: #e5e7eb; }
.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover { background: #fecaca; }
.btn-icon {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  color: #6b7280;
  font-size: 0.8rem;
  transition: all 0.15s;
}
.btn-icon:hover { background: #f3f4f6; color: #111827; }

/* ── Forms ── */
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 5px;
}
.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #111827;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-input:disabled { background: #f9fafb; cursor: not-allowed; }
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 8px center; background-size: 16px; padding-right: 32px; }

/* ── Tables ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 10px 14px; text-align: left; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; border-bottom: 1px solid #e5e7eb; white-space: nowrap; }
.data-table td { padding: 12px 14px; font-size: 0.875rem; color: #374151; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f9fafb; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Status Badges ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-new       { background:#dbeafe; color:#1d4ed8; }
.status-contacted { background:#fef9c3; color:#854d0e; }
.status-test_drive{ background:#fce7f3; color:#9d174d; }
.status-offer     { background:#fff7ed; color:#c2410c; }
.status-won       { background:#dcfce7; color:#15803d; }
.status-lost      { background:#fee2e2; color:#b91c1c; }
.status-available { background:#dcfce7; color:#15803d; }
.status-reserved  { background:#fef9c3; color:#854d0e; }
.status-sold      { background:#fee2e2; color:#b91c1c; }
.status-active    { background:#dcfce7; color:#15803d; }
.status-customer  { background:#dbeafe; color:#1d4ed8; }
.status-vip       { background:#fae8ff; color:#7e22ce; }
.status-inactive  { background:#f3f4f6; color:#6b7280; }

/* ── Avatar ── */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* ── Score Bar ── */
.score-bar { height: 4px; border-radius: 2px; background: #e5e7eb; overflow: hidden; margin-top: 4px; }
.score-fill { height: 100%; border-radius: 2px; transition: width 0.5s; }

/* ── Kanban ── */
.kanban-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 8px; }
.kanban-board  { display: flex; gap: 12px; min-width: max-content; }
.kanban-col    { width: 280px; flex-shrink: 0; background: #f3f4f6; border-radius: 10px; padding: 12px; }
.kanban-col-header { font-size: 0.8rem; font-weight: 600; color: #374151; display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kanban-cards  { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.lead-card     { background: #fff; border-radius: 8px; border: 1px solid #e5e7eb; padding: 12px; cursor: pointer; transition: box-shadow 0.15s, transform 0.15s; }
.lead-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-1px); }

/* ── Vehicle Card ── */
.vehicle-card { background:#fff; border:1px solid #e5e7eb; border-radius:12px; overflow:hidden; transition: box-shadow 0.15s, transform 0.15s; cursor:pointer; }
.vehicle-card:hover { box-shadow:0 6px 20px rgba(0,0,0,0.1); transform:translateY(-2px); }
.vehicle-img { width:100%; height:160px; object-fit:cover; }

/* ── Timeline ── */
.timeline-item { display: flex; gap: 12px; padding: 10px 0; position: relative; }
.timeline-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; flex-shrink: 0; }
.timeline-content { flex: 1; min-width: 0; }
.timeline-body { font-size: 0.875rem; color: #374151; margin-top: 2px; }
.timeline-time { font-size: 0.75rem; color: #9ca3af; }

/* ── Tabs ── */
.tabs { display: flex; border-bottom: 2px solid #e5e7eb; gap: 0; overflow-x: auto; }
.tab-btn { padding: 10px 16px; font-size: 0.875rem; font-weight: 500; color: #6b7280; border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; white-space: nowrap; transition: color 0.15s, border-color 0.15s; }
.tab-btn:hover { color: #374151; }
.tab-btn.active { color: #2563eb; border-bottom-color: #2563eb; }

/* ── Modals ── */
.modal-box {
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Provider Card (phone modal) ── */
.provider-card {
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.provider-card:hover { border-color: #93c5fd; background: #eff6ff; }
.provider-card.selected { border-color: #2563eb; background: #eff6ff; }

/* ── Integration Cards ── */
.integration-card { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border: 1px solid #e5e7eb; border-radius: 10px; }
.integration-icon { width: 40px; height: 40px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.conn-dot.online  { background: #16a34a; }
.conn-dot.offline { background: #ef4444; }

/* ── Toast ── */
.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  animation: toastIn 0.3s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }
.toast-info    { background: #2563eb; }
.toast-warning { background: #f59e0b; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Loading Spinner ── */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid #e5e7eb; border-top-color: #2563eb; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Skeleton ── */
.skeleton { background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 4px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Chart Container ── */
.chart-container { position: relative; }

/* ── Toggle ── */
.toggle-switch { position:relative; display:inline-block; width:42px; height:24px; }
.toggle-switch input { opacity:0; width:0; height:0; }
.toggle-slider { position:absolute; inset:0; background:#d1d5db; border-radius:24px; cursor:pointer; transition: background 0.2s; }
.toggle-slider:before { content:''; position:absolute; height:18px; width:18px; left:3px; bottom:3px; background:#fff; border-radius:50%; transition:transform 0.2s; box-shadow:0 1px 3px rgba(0,0,0,0.2); }
.toggle-switch input:checked + .toggle-slider { background:#2563eb; }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ── Utilities ── */
.truncate-1 { overflow:hidden; display:-webkit-box; -webkit-line-clamp:1; -webkit-box-orient:vertical; }
.truncate-2 { overflow:hidden; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
.no-select  { user-select:none; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .card { padding: 14px; }
  .kpi-value { font-size: 1.4rem; }
  .kanban-col { width: 240px; }
  .hide-xs { display: none !important; }
}
@media (max-width: 768px) {
  .hide-sm { display: none !important; }
}
@media (max-width: 1024px) {
  .hide-md { display: none !important; }
}

/* ── Lead / Contact Detail Drawer ─────────────────────────── */
.lead-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 100vw;
  background: #fff;
  box-shadow: -8px 0 40px rgba(0,0,0,0.15);
  z-index: 45;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.lead-drawer.open {
  transform: translateX(0);
}
.lead-drawer-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.drawer-header {
  background: #fff;
  border-bottom: 1px solid #f3f4f6;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
}
@media (max-width: 640px) {
  .lead-drawer { width: 100vw; }
}

/* ── Pipeline Stage Bar ──────────────────────────────────── */
.stage-step {
  cursor: pointer;
  transition: opacity 0.15s;
}
.stage-step:hover { opacity: 0.85; }
.stage-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #e5e7eb;
  background: #fff;
  color: #9ca3af;
  font-size: 0.75rem;
  transition: all 0.2s;
  flex-shrink: 0;
}
.stage-done .stage-dot {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}
.stage-current .stage-dot {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.2);
}
.stage-done .text-xs,
.stage-current .text-xs {
  color: #111827;
  font-weight: 600;
}
.stage-pending .text-xs {
  color: #9ca3af;
}
.stage-line {
  height: 2px;
  background: #e5e7eb;
  margin-top: 15px;
  flex-shrink: 0;
}
.stage-line.done {
  background: #16a34a;
}

/* ── Timeline container ──────────────────────────────────── */
.timeline-container {
  position: relative;
}
.timeline-entry {
  transition: background 0.15s;
  border-radius: 8px;
  padding: 8px;
  margin: 0 -8px;
}
.timeline-entry:hover {
  background: #f9fafb;
}

/* ── Phone number card ───────────────────────────────────── */
.phone-number-card {
  transition: box-shadow 0.15s, border-color 0.15s;
}
.phone-number-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 2px 8px rgba(37,99,235,0.08);
}

/* ── Source tag pill ─────────────────────────────────────── */
.source-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #c2410c;
  cursor: default;
}
.source-tag-pill button {
  width: 14px;
  height: 14px;
  border: none;
  background: none;
  cursor: pointer;
  color: #f97316;
  font-size: 0.6rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.source-tag-pill button:hover { background: #fed7aa; }
