/* ============================================
   Mobility 2.0 — Dashboard Styles
   ============================================ */

:root {
  --sidebar-width: 240px;
  --sidebar-bg: #1a1d23;
  --sidebar-hover: #2a2d35;
  --sidebar-active: #0d6efd;
  --sidebar-text: #a0a4b0;
  --sidebar-text-active: #ffffff;
  --header-height: 64px;
  --content-bg: #f4f6f9;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--content-bg);
  overflow-x: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  z-index: 1040;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand i {
  font-size: 1.4rem;
  color: var(--sidebar-active);
}

.sidebar .nav {
  padding: 8px 0;
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  font-size: 0.9rem;
  border-radius: 0;
  transition: all 0.15s ease;
  text-decoration: none;
}

.sidebar .nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.sidebar .nav-link.active {
  background: rgba(13, 110, 253, 0.15);
  color: var(--sidebar-active);
  font-weight: 600;
  border-left: 3px solid var(--sidebar-active);
  padding-left: 17px;
}

.sidebar .nav-link i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 8px 16px;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 8px 0;
}

.sidebar-footer .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  font-size: 0.85rem;
  text-decoration: none;
}

.sidebar-footer .nav-link:hover {
  color: var(--sidebar-text-active);
}

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.content-body {
  padding: 24px;
  flex: 1;
}

/* ---- Stats Cards ---- */
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #e5e7eb;
  transition: box-shadow 0.2s;
}

.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1a1d23;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.82rem;
  color: #6b7280;
  margin-top: 4px;
}

/* ---- Cards ---- */
.card-panel {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}

.card-panel .card-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-panel .card-panel-header h6 {
  margin: 0;
  font-weight: 600;
  color: #1a1d23;
}

.card-panel .card-panel-body {
  padding: 20px;
}

/* ---- Tables ---- */
.table-container {
  overflow-x: auto;
}

.table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  font-weight: 600;
  border-bottom-width: 1px;
  white-space: nowrap;
}

.table td {
  font-size: 0.88rem;
  vertical-align: middle;
}

.table-hover tbody tr {
  cursor: pointer;
}

.table-hover tbody tr:hover {
  background: #f0f4ff;
}

/* ---- Badges ---- */
.badge-sync {
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.badge-delta {
  background: #dcfce7;
  color: #166534;
}

.badge-full {
  background: #fef3c7;
  color: #92400e;
}

.badge-entity {
  background: #e0e7ff;
  color: #3730a3;
}

/* ---- Status Dots ---- */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online { background: #22c55e; }
.status-dot.offline { background: #ef4444; }
.status-dot.pending { background: #f59e0b; }

/* ---- User Selector ---- */
.user-selector {
  max-width: 320px;
}
.user-selector-wrap {
  min-width: 280px;
  max-width: 400px;
}
.user-selector-wrap .dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1080;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  border: 1px solid #dee2e6;
  display: none;
}
.user-selector-wrap .dropdown-menu.show {
  display: block;
}
.user-selector-wrap .dropdown-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 8px 12px;
}
.user-selector-wrap .dropdown-item:hover {
  background: #f0f4ff;
}
/* Allow dropdown to overflow card-panel */
.card-panel:has(.user-selector-wrap),
.card-panel.overflow-visible {
  overflow: visible;
}

/* ---- Breadcrumb-like nav ---- */
.entity-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.entity-breadcrumb .crumb {
  font-size: 0.85rem;
  color: var(--sidebar-active);
  cursor: pointer;
  text-decoration: none;
}

.entity-breadcrumb .crumb:hover {
  text-decoration: underline;
}

.entity-breadcrumb .crumb.current {
  color: #1a1d23;
  font-weight: 600;
  cursor: default;
}

.entity-breadcrumb .separator {
  color: #9ca3af;
  font-size: 0.8rem;
}

/* ---- Detail View ---- */
.detail-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
  font-size: 0.88rem;
}

.detail-grid .detail-label {
  color: #6b7280;
  font-weight: 500;
}

.detail-grid .detail-value {
  color: #1a1d23;
  word-break: break-word;
}

/* ---- Spinner ---- */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #6b7280;
}

.loading-spinner .spinner-border {
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 12px;
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #9ca3af;
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
}

/* ---- Pagination ---- */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  font-size: 0.85rem;
  color: #6b7280;
}

/* ---- Sync Buttons ---- */
.sync-btn-group .btn {
  font-size: 0.82rem;
  padding: 4px 12px;
}

/* ---- Toast ---- */
.toast {
  min-width: 280px;
}

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: block !important;
  }
}

@media (min-width: 992px) {
  .sidebar-toggle {
    display: none !important;
  }
}

/* ---- Scrollbar ---- */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

/* ---- Email Body ---- */
.email-body-container {
  min-height: 100px;
  max-height: 800px;
  overflow-y: auto;
}

/* ---- Global Search ---- */
.global-search-wrapper {
  position: relative;
  width: 280px;
}

.global-search-wrapper .input-group {
  border-radius: 8px;
  overflow: hidden;
}

.global-search-wrapper .input-group-text {
  border-color: #e5e7eb;
}

.global-search-wrapper .form-control {
  border-color: #e5e7eb;
}

.global-search-wrapper .form-control:focus {
  box-shadow: none;
  border-color: #0d6efd;
}

.search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  margin-top: 6px;
  max-height: 420px;
  overflow-y: auto;
  z-index: 1050;
}

.search-category {
  padding: 8px 14px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  border-top: 1px solid #f0f0f0;
}

.search-category:first-child {
  border-top: none;
}

.search-result-item {
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.1s;
}

.search-result-item:hover {
  background: #f0f4ff;
}

.search-result-title {
  font-size: 0.85rem;
  color: #1a1d23;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-subtitle {
  font-size: 0.75rem;
  color: #9ca3af;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-empty {
  padding: 20px;
  text-align: center;
  color: #9ca3af;
  font-size: 0.85rem;
}

/* ---- Kanban Drag & Drop ---- */
.kanban-card {
  transition: box-shadow 0.15s, opacity 0.15s;
  user-select: none;
}
.kanban-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,.15) !important;
}
.kanban-card[draggable="true"]:active {
  cursor: grabbing;
}
.kanban-drop-zone.drag-over {
  background: #e2e6ea !important;
  outline: 2px dashed #6c757d;
  outline-offset: -4px;
  border-radius: 4px;
}

/* ---- Mail Actions ---- */
.mail-action-btn { font-size: 0.82rem; padding: 4px 10px; }
.mail-importance-btn { font-size: 0.82rem; padding: 4px 8px; }
.mail-read-toggle { font-size: 0.9rem; line-height: 1; text-decoration: none !important; cursor: pointer; }
.mail-read-toggle:hover { transform: scale(1.15); transition: transform 0.1s ease; }

/* ---- Animations ---- */
.fade-in {
  animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Contact Summary ---- */
.summary-card { border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; }
.summary-card h6 { font-size: 0.82rem; text-transform: uppercase; color: #6b7280; margin-bottom: 8px; }
.summary-item { font-size: 0.85rem; padding: 6px 0; border-bottom: 1px solid #f0f0f0; }
.summary-item:last-child { border-bottom: none; }
.ai-summary-box { background: #f8f9fa; border-radius: 8px; padding: 16px; font-size: 0.9rem; line-height: 1.6; white-space: pre-wrap; }
