/* BESS CRM - Custom Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #f1f5f9;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}
@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.05); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

.fade-in { animation: fadeIn 0.25s ease-out; }
.slide-in { animation: slideInRight 0.3s ease-out; }
.bounce-in { animation: bounceIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); }

/* Sidebar */
#sidebar {
  width: 260px;
  min-height: 100vh;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
  transition: width 0.3s ease;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  overflow: hidden;
}
#sidebar.collapsed { width: 64px; }
#main-content { margin-left: 260px; transition: margin-left 0.3s ease; }
#main-content.expanded { margin-left: 64px; }

.nav-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 8px;
  margin: 2px 8px;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover { background: rgba(99,102,241,0.15); color: #e2e8f0; }
.nav-item.active { background: linear-gradient(90deg, #6366f1, #4f46e5); color: white; box-shadow: 0 2px 8px rgba(99,102,241,0.4); }
.nav-item i { width: 20px; min-width: 20px; text-align: center; font-size: 15px; }
.nav-label { margin-left: 12px; font-size: 14px; font-weight: 500; }

/* Cards */
.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.06);
  border: 1px solid #f1f5f9;
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

/* Stats card */
.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #e2e8f0;
  transition: all 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.08); }

/* Pipeline stages */
.stage-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Priority */
.priority-high { color: #ef4444; background: #fef2f2; }
.priority-medium { color: #f59e0b; background: #fffbeb; }
.priority-low { color: #22c55e; background: #f0fdf4; }

/* Checklist */
.checklist-item {
  display: flex;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background 0.15s;
  cursor: pointer;
}
.checklist-item:hover { background: #f8fafc; }
.checklist-item.completed .item-text { text-decoration: line-through; color: #94a3b8; }

/* Custom checkbox */
.checkbox-custom {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  cursor: pointer;
}
.checkbox-custom.checked { background: #6366f1; border-color: #6366f1; }
.checkbox-custom.checked::after {
  content: '✓';
  color: white;
  font-size: 11px;
  font-weight: bold;
}

/* Reminder popup */
#reminder-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 380px;
  pointer-events: none;
}
.reminder-popup {
  background: white;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 0 0 1px rgba(99,102,241,0.1);
  padding: 16px 18px;
  border-left: 4px solid #6366f1;
  pointer-events: all;
  animation: bounceIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.reminder-popup.urgent { border-left-color: #ef4444; }
.reminder-popup.high { border-left-color: #f59e0b; }

/* Pulse dot for notifications */
.pulse-dot {
  position: relative;
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
}
.pulse-dot::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #ef4444;
  animation: pulse-ring 1.5s ease-out infinite;
}

/* Timeline */
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal-content {
  background: white;
  border-radius: 16px;
  max-height: 90vh;
  overflow-y: auto;
  width: 100%;
  max-width: 680px;
  animation: fadeIn 0.25s ease;
  box-shadow: 0 25px 60px rgba(0,0,0,0.25);
}

/* Progress bar */
.progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  transition: width 0.5s ease;
}

/* Pipeline board */
.pipeline-column {
  min-width: 220px;
  max-width: 220px;
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  transition: outline 0.15s, background 0.15s;
}
.pipeline-card {
  background: white;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid #e2e8f0;
  cursor: grab;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s, opacity 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.pipeline-card:hover { 
  box-shadow: 0 4px 12px rgba(99,102,241,0.15); 
  border-color: #a5b4fc;
  transform: translateY(-1px);
}
.pipeline-card:active {
  cursor: grabbing;
  transform: scale(1.02) rotate(1deg);
  box-shadow: 0 10px 30px rgba(99,102,241,0.25);
  z-index: 100;
}
.pipeline-card[draggable="true"]:hover::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  border: 2px solid #a5b4fc;
  pointer-events: none;
}
/* Drop zone active state */
.drop-zone.drag-over {
  background: rgba(99,102,241,0.05);
  border-radius: 8px;
  min-height: 80px;
}
@keyframes cardDrop {
  0% { transform: scale(1.04); box-shadow: 0 8px 24px rgba(99,102,241,0.3); }
  100% { transform: scale(1); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
}
.card-dropped {
  animation: cardDrop 0.35s ease-out forwards;
}

/* Table */
table { border-collapse: collapse; width: 100%; }
th { background: #f8fafc; font-weight: 600; font-size: 12px; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #f1f5f9; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn-primary:hover { box-shadow: 0 4px 14px rgba(99,102,241,0.4); transform: translateY(-1px); }
.btn-secondary {
  background: white;
  color: #374151;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #e2e8f0;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-danger { background: #fef2f2; color: #ef4444; border: 1px solid #fecaca; }
.btn-danger:hover { background: #ef4444; color: white; }

/* Form inputs */
.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  color: #1e293b;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.form-label { font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 4px; display: block; }

/* Tab navigation */
.tab-nav {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
}
.tab-btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  color: #64748b;
  border: none;
  background: transparent;
}
.tab-btn.active { background: white; color: #1e293b; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.tab-btn:hover:not(.active) { color: #374151; background: rgba(255,255,255,0.5); }

/* Kanban/Category header */
.category-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748b;
  padding: 8px 0 4px;
  margin-top: 12px;
  border-bottom: 2px solid;
}

/* Status badges */
.status-active { background: #dcfce7; color: #16a34a; }
.status-inactive { background: #f1f5f9; color: #64748b; }
.status-lost { background: #fee2e2; color: #dc2626; }
.status-pending { background: #fffbeb; color: #d97706; }
.status-completed { background: #dcfce7; color: #16a34a; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Login page */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #312e81 100%);
}

/* Responsive */
@media (max-width: 768px) {
  #sidebar { width: 64px; }
  #sidebar .nav-label { display: none; }
  #main-content { margin-left: 64px; }
}

/* Loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 9999;
  animation: fadeIn 0.2s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 200px;
}
.toast.success { background: #065f46; }
.toast.error { background: #7f1d1d; }

/* Tooltip */
[data-tip] { position: relative; cursor: help; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 100;
}

/* Badge count */
.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
}

/* KML tooltip – rich multi-line */
.kml-tip {
  background: white !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,.15) !important;
  padding: 8px 12px !important;
  font-size: 12px !important;
  line-height: 1.6 !important;
  max-width: 220px !important;
  color: #1e293b !important;
  white-space: normal !important;
}
.kml-tip::before { display:none !important; }

/* ── Leaflet z-index fix ─────────────────────────────────────────────────────
   Leaflet's internal panes use high z-index values relative to the container.
   By setting the container itself to z-index:0 + isolation:isolate, all
   Leaflet layers stay inside their own stacking context so modals/drawers
   (z-index 9000+) always render on top. */
.leaflet-container {
  z-index: 0 !important;
  isolation: isolate;
}

/* ── Radius circle tooltip labels ────────────────────────────────────────────*/
.radius-label-2km {
  background: #6366f1 !important;
  border: none !important;
  border-radius: 99px !important;
  color: white !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  padding: 2px 8px !important;
  white-space: nowrap !important;
  box-shadow: 0 2px 6px rgba(99,102,241,.35) !important;
}
.radius-label-2km::before { display: none !important; }

.radius-label-5km {
  background: #0ea5e9 !important;
  border: none !important;
  border-radius: 99px !important;
  color: white !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  padding: 2px 8px !important;
  white-space: nowrap !important;
  box-shadow: 0 2px 6px rgba(14,165,233,.3) !important;
}
.radius-label-5km::before { display: none !important; }

/* ── KML marker wrapper ──────────────────────────────────────────────────────*/
.kml-marker-wrap {
  background: transparent !important;
  border: none !important;
}

/* kV labels hidden by default, shown by JS at zoom >= 9 */
.kv-label {
  display: none;
  pointer-events: none;
}

/* Fullscreen map body-lock */
body.map-fullscreen {
  overflow: hidden;
}
