/* ==========================================================================
   Salex - Components (Stat cards, avatars, kanban, timeline, etc.)
   ========================================================================== */

/* Stat Cards */
.stat-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.1rem 1.2rem;
  background: #fff;
  border: 1px solid var(--salex-border);
  border-radius: var(--salex-radius-lg);
  box-shadow: var(--salex-shadow-sm);
  position: relative;
  overflow: hidden;
  height: 100%;
}
.stat-card .stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--salex-text-muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.stat-card .stat-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--salex-heading);
  line-height: 1.1;
  margin: 0;
}
.stat-card .stat-meta {
  font-size: 0.78rem;
  color: var(--salex-text-muted);
  margin-top: 0.45rem;
  display: flex; align-items: center; gap: 0.35rem;
}
.stat-card .stat-meta .trend-up { color: var(--salex-success); font-weight: 600; }
.stat-card .stat-meta .trend-down { color: var(--salex-danger); font-weight: 600; }
.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-card .stat-icon.bg-primary-soft { background: var(--salex-primary-50); color: var(--salex-primary); }
.stat-card .stat-icon.bg-warning-soft { background: var(--salex-accent-50); color: var(--salex-accent-600); }
.stat-card .stat-icon.bg-success-soft { background: var(--salex-success-50); color: var(--salex-success); }
.stat-card .stat-icon.bg-info-soft { background: var(--salex-info-50); color: var(--salex-info); }
.stat-card .stat-icon.bg-purple-soft { background: #F3E8FF; color: var(--salex-purple); }
.stat-card .stat-icon.bg-pink-soft { background: #FCE7F3; color: var(--salex-pink); }
.stat-card .stat-icon.bg-danger-soft { background: var(--salex-danger-50); color: var(--salex-danger); }
.stat-card .stat-spark { position: absolute; right: 0; bottom: 0; opacity: 0.45; pointer-events: none; }

/* Avatar */
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--salex-primary-50); color: var(--salex-primary); font-weight: 600; flex-shrink: 0; overflow: hidden; }
.avatar-xs { width: 24px; height: 24px; font-size: 0.7rem; }
.avatar-sm { width: 32px; height: 32px; font-size: 0.78rem; }
.avatar-md { width: 40px; height: 40px; font-size: 0.85rem; }
.avatar-lg { width: 52px; height: 52px; font-size: 1rem; }
.avatar-xl { width: 72px; height: 72px; font-size: 1.4rem; }
.avatar-2xl { width: 96px; height: 96px; font-size: 1.8rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.bg-primary { background: var(--salex-primary); color: #fff; }
.avatar.bg-warning { background: var(--salex-accent); color: #1B2F6F; }
.avatar.bg-success { background: var(--salex-success); color: #fff; }
.avatar.bg-danger { background: var(--salex-danger); color: #fff; }
.avatar.bg-info { background: var(--salex-info); color: #fff; }
.avatar.bg-purple { background: var(--salex-purple); color: #fff; }
.avatar.bg-pink { background: var(--salex-pink); color: #fff; }
.avatar.bg-teal { background: var(--salex-teal); color: #fff; }
.avatar.bg-secondary { background: #94A3B8; color: #fff; }
.avatar-status { position: relative; }
.avatar-status::after {
  content: "";
  width: 10px; height: 10px;
  position: absolute;
  bottom: 0; right: 0;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--salex-success);
}
.avatar-status.offline::after { background: #94A3B8; }
.avatar-status.away::after { background: var(--salex-accent); }
.avatar-status.busy::after { background: var(--salex-danger); }

.avatar-group { display: inline-flex; }
.avatar-group .avatar { border: 2px solid #fff; margin-left: -10px; }
.avatar-group .avatar:first-child { margin-left: 0; }
.avatar-group .avatar:hover { z-index: 2; transform: translateY(-2px); transition: transform .2s; }

/* Timeline */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px; background: var(--salex-border); }
.timeline-item { position: relative; padding-bottom: 1.4rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-marker {
  position: absolute;
  left: -1.5rem;
  top: 4px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--salex-primary);
  display: flex; align-items: center; justify-content: center;
  color: var(--salex-primary);
  font-size: 0.7rem;
}
.timeline-marker.bg-success { background: var(--salex-success-50); border-color: var(--salex-success); color: var(--salex-success); }
.timeline-marker.bg-warning { background: var(--salex-accent-50); border-color: var(--salex-accent); color: var(--salex-accent-600); }
.timeline-marker.bg-danger { background: var(--salex-danger-50); border-color: var(--salex-danger); color: var(--salex-danger); }
.timeline-marker.bg-info { background: var(--salex-info-50); border-color: var(--salex-info); color: var(--salex-info); }
.timeline-content {
  background: #fff;
  border: 1px solid var(--salex-border);
  border-radius: var(--salex-radius);
  padding: 0.85rem 1rem;
}
.timeline-time { font-size: 0.72rem; color: var(--salex-text-muted); }

/* Kanban */
.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
}
.kanban-col {
  flex: 0 0 320px;
  background: #F1F4FA;
  border-radius: var(--salex-radius-lg);
  padding: 0.85rem;
  display: flex; flex-direction: column;
  min-height: 200px;
  border: 1px solid var(--salex-border-soft);
}
.kanban-col-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.7rem;
  padding: 0 0.25rem;
}
.kanban-col-title { font-weight: 600; font-size: 0.85rem; color: var(--salex-heading); display: flex; align-items: center; gap: 0.5rem; }
.kanban-col-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--salex-primary); }
.kanban-col-count { background: rgba(15,23,42,0.08); color: var(--salex-text-muted); padding: 0 6px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.kanban-col-value { font-size: 0.78rem; color: var(--salex-text-muted); }
.kanban-list { display: flex; flex-direction: column; gap: 0.55rem; }
.kanban-card {
  background: #fff;
  border-radius: var(--salex-radius);
  border: 1px solid var(--salex-border);
  box-shadow: var(--salex-shadow-sm);
  padding: 0.85rem;
  cursor: grab;
  transition: transform .15s ease, box-shadow .15s ease;
}
.kanban-card:hover { box-shadow: var(--salex-shadow); transform: translateY(-1px); }
.kanban-card .card-title { font-size: 0.85rem; margin-bottom: 0.25rem; }
.kanban-card .price { color: var(--salex-success); font-weight: 600; font-size: 0.85rem; }

/* Chip / Tag */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--salex-border-soft);
  font-size: 0.74rem;
  color: var(--salex-text);
  font-weight: 500;
}
.chip .close { cursor: pointer; opacity: 0.6; }
.chip .close:hover { opacity: 1; color: var(--salex-danger); }

/* List Group */
.list-clean { list-style: none; padding: 0; margin: 0; }
.list-clean > li { padding: 0.85rem 0; border-bottom: 1px solid var(--salex-border-soft); display: flex; gap: 0.75rem; align-items: flex-start; }
.list-clean > li:last-child { border-bottom: 0; }

/* Stepper */
.stepper { display: flex; gap: 0; }
.stepper-item { flex: 1; display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.8rem; background: var(--salex-border-soft); position: relative; font-size: 0.84rem; color: var(--salex-text-muted); }
.stepper-item .num { width: 24px; height: 24px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.76rem; font-weight: 600; }
.stepper-item.done { background: var(--salex-success-50); color: var(--salex-success); }
.stepper-item.done .num { background: var(--salex-success); color: #fff; }
.stepper-item.active { background: var(--salex-primary); color: #fff; }
.stepper-item.active .num { background: #fff; color: var(--salex-primary); }
.stepper-item:not(:last-child)::after {
  content: ""; position: absolute; right: -10px; top: 50%; transform: translateY(-50%);
  border: 10px solid transparent; border-left-color: var(--salex-border-soft); z-index: 2;
}
.stepper-item.done:not(:last-child)::after { border-left-color: var(--salex-success-50); }
.stepper-item.active:not(:last-child)::after { border-left-color: var(--salex-primary); }

/* Health bar */
.health-bar { display: flex; gap: 2px; align-items: center; }
.health-bar span { display: block; width: 6px; height: 14px; background: var(--salex-border); border-radius: 2px; }
.health-bar.h-1 span:nth-child(-n+1) { background: var(--salex-danger); }
.health-bar.h-2 span:nth-child(-n+2) { background: var(--salex-warning); }
.health-bar.h-3 span:nth-child(-n+3) { background: var(--salex-warning); }
.health-bar.h-4 span:nth-child(-n+4) { background: var(--salex-success); }
.health-bar.h-5 span:nth-child(-n+5) { background: var(--salex-success); }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: flex; }
.auth-side {
  flex: 1;
  background: linear-gradient(135deg, #0B1437 0%, #1E3A8A 50%, #1E3A8A 100%);
  position: relative;
  color: #fff;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.auth-side::before {
  content: "";
  position: absolute;
  top: -100px; right: -100px;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(245,158,11,0.25) 0%, transparent 70%);
}
.auth-side::after {
  content: "";
  position: absolute;
  bottom: -150px; left: -100px;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, transparent 70%);
}
.auth-side > * { position: relative; z-index: 1; }
.auth-side .brand { display: flex; align-items: center; gap: 0.7rem; font-weight: 700; font-size: 1.4rem; color: #fff; text-decoration: none; }
.auth-side .brand .brand-icon { width: 42px; height: 42px; border-radius: 10px; background: linear-gradient(135deg, #F59E0B, #D97706); display: flex; align-items: center; justify-content: center; color: #1B2F6F; font-size: 1.3rem; }
.auth-side h1 { color: #fff; font-size: 2.2rem; line-height: 1.2; margin-bottom: 1rem; }
.auth-side .lead { color: rgba(255,255,255,0.78); font-size: 1.05rem; max-width: 480px; }
.auth-side .stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 2rem; max-width: 480px; }
.auth-side .stats-row .stat { background: rgba(255,255,255,0.06); padding: 0.85rem; border-radius: 10px; backdrop-filter: blur(10px); }
.auth-side .stats-row .stat .num { font-size: 1.3rem; font-weight: 700; color: var(--salex-accent); }
.auth-side .stats-row .stat .lbl { font-size: 0.75rem; color: rgba(255,255,255,0.7); }
.auth-side .testimonial { background: rgba(255,255,255,0.06); padding: 1.2rem; border-radius: 12px; backdrop-filter: blur(10px); max-width: 480px; }
.auth-form-side {
  width: 480px;
  padding: 3rem;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-form-side h2 { font-size: 1.6rem; margin-bottom: 0.4rem; }
.auth-form-side .sub { color: var(--salex-text-muted); margin-bottom: 1.5rem; }

@media (max-width: 991.98px) {
  .auth-side { display: none; }
  .auth-form-side { width: 100%; padding: 2rem 1.5rem; }
}

/* File / Document tile */
.file-tile {
  border: 1px solid var(--salex-border);
  border-radius: var(--salex-radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
  cursor: pointer;
}
.file-tile:hover { border-color: var(--salex-primary-300); box-shadow: var(--salex-shadow); }
.file-tile .icon { width: 44px; height: 44px; border-radius: 10px; background: var(--salex-primary-50); color: var(--salex-primary); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.file-tile .name { font-weight: 600; font-size: 0.9rem; color: var(--salex-heading); }
.file-tile .meta { font-size: 0.74rem; color: var(--salex-text-muted); }

/* Empty state */
.empty-state { padding: 3rem 1rem; text-align: center; color: var(--salex-text-muted); }
.empty-state .icon { font-size: 3rem; color: var(--salex-text-soft); margin-bottom: 1rem; }
.empty-state h5 { color: var(--salex-heading); margin-bottom: 0.4rem; }

/* Filter chips toolbar */
.toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--salex-border-soft);
}
.toolbar .form-control, .toolbar .form-select { height: 36px; font-size: 0.83rem; }

/* Pagination */
.pagination { gap: 4px; margin: 0; }
.page-link {
  border-radius: 8px !important;
  border: 1px solid var(--salex-border);
  color: var(--salex-text);
  font-size: 0.84rem;
  padding: 0.4rem 0.7rem;
  min-width: 34px;
  text-align: center;
}
.page-item.active .page-link { background: var(--salex-primary); border-color: var(--salex-primary); color: #fff; }
.page-link:hover { background: var(--salex-primary-50); border-color: var(--salex-primary-200); color: var(--salex-primary); }

/* Toast */
#toastHost {
  position: fixed; top: 90px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 2050;
  pointer-events: none;
}
.toast-msg {
  background: #fff;
  border: 1px solid var(--salex-border);
  border-left: 4px solid var(--salex-primary);
  border-radius: 10px;
  box-shadow: var(--salex-shadow-lg);
  padding: 0.7rem 1rem;
  display: flex; align-items: center; gap: 0.6rem;
  min-width: 280px;
  pointer-events: auto;
  animation: toastIn .25s ease;
}
.toast-msg.success { border-left-color: var(--salex-success); }
.toast-msg.warning { border-left-color: var(--salex-warning); }
.toast-msg.danger { border-left-color: var(--salex-danger); }
.toast-msg.info { border-left-color: var(--salex-info); }
.toast-msg i:first-child { font-size: 1.1rem; }
.toast-msg.success i:first-child { color: var(--salex-success); }
.toast-msg.warning i:first-child { color: var(--salex-warning); }
.toast-msg.danger i:first-child { color: var(--salex-danger); }
.toast-msg.info i:first-child { color: var(--salex-info); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* Quick add fab */
.fab {
  position: fixed; right: 24px; bottom: 24px;
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--salex-accent);
  color: #1B2F6F;
  border: none;
  box-shadow: 0 12px 28px rgba(245,158,11,0.4);
  font-size: 1.4rem;
  display: flex; align-items: center; justify-content: center;
  z-index: 1020;
}
.fab:hover { transform: translateY(-2px); }

/* Drag highlight */
.drag-over { outline: 2px dashed var(--salex-primary); outline-offset: -4px; background: var(--salex-primary-50) !important; }

/* Mini calendar */
.mini-cal { font-size: 0.8rem; }
.mini-cal table { width: 100%; }
.mini-cal th, .mini-cal td { padding: 0.3rem; text-align: center; }
.mini-cal th { font-size: 0.7rem; color: var(--salex-text-muted); font-weight: 600; }
.mini-cal td button { width: 28px; height: 28px; border-radius: 6px; border: none; background: transparent; font-size: 0.78rem; }
.mini-cal td.has-event button { font-weight: 600; color: var(--salex-primary); }
.mini-cal td.today button { background: var(--salex-primary); color: #fff; }
.mini-cal td.muted button { color: var(--salex-text-soft); }

/* Activity dots */
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

/* Score ring */
.score-ring {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: conic-gradient(var(--salex-primary) calc(var(--p) * 1%), var(--salex-border) 0);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--salex-primary);
  position: relative;
  font-size: 0.85rem;
}
.score-ring::before {
  content: ""; position: absolute; inset: 5px;
  border-radius: 50%; background: #fff;
}
.score-ring span { position: relative; z-index: 1; }

/* Pipeline funnel */
.funnel-stage {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--salex-primary);
  color: #fff;
  padding: 0.7rem 1.2rem;
  margin-bottom: 4px;
  font-weight: 500;
  font-size: 0.85rem;
}
.funnel-stage .meta { font-size: 0.78rem; opacity: 0.85; }

/* Quill / Editor */
.editor-toolbar {
  border: 1px solid var(--salex-border);
  border-bottom: 0;
  border-radius: var(--salex-radius-sm) var(--salex-radius-sm) 0 0;
  padding: 0.4rem 0.6rem;
  display: flex; flex-wrap: wrap; gap: 0.25rem;
  background: var(--salex-border-soft);
}
.editor-toolbar button { background: transparent; border: 0; width: 30px; height: 30px; border-radius: 4px; }
.editor-toolbar button:hover { background: #fff; }
.editor-area {
  border: 1px solid var(--salex-border);
  border-radius: 0 0 var(--salex-radius-sm) var(--salex-radius-sm);
  padding: 1rem;
  min-height: 220px;
  background: #fff;
}

/* Print */
@media print {
  .app-sidebar, .app-topbar, .app-footer, .fab, .topbar-actions, .no-print { display: none !important; }
  .app-main { margin: 0; padding: 0; }
}

/* Dark mode — component overrides */
html.theme-dark .toolbar { border-bottom-color: var(--salex-border); }
html.theme-dark .kanban-col { background: rgba(255,255,255,0.03); border-color: var(--salex-border); }
html.theme-dark .kanban-col-title { color: var(--salex-heading); }
html.theme-dark .kanban-col-count { background: rgba(255,255,255,0.08); color: var(--salex-text-muted); }
html.theme-dark .kanban-col-value { color: var(--salex-text-muted); }
html.theme-dark .timeline::before { background: var(--salex-border); }
html.theme-dark .timeline-marker { background: var(--salex-card-bg); border-color: var(--salex-accent); color: var(--salex-accent); }
html.theme-dark .stat-card .stat-label { color: var(--salex-text-muted); }
html.theme-dark .stat-card .stat-value { color: var(--salex-heading); }
html.theme-dark .stat-card .stat-meta { color: var(--salex-text-muted); }
html.theme-dark .file-tile .name { color: var(--salex-heading); }
html.theme-dark .file-tile .meta { color: var(--salex-text-muted); }
html.theme-dark .file-tile:hover { border-color: var(--salex-accent); }
html.theme-dark .empty-state { color: var(--salex-text-muted); }
html.theme-dark .empty-state h5 { color: var(--salex-heading); }
html.theme-dark .empty-state .icon { color: var(--salex-text-soft); }
html.theme-dark .editor-toolbar { background: rgba(255,255,255,0.04); border-color: var(--salex-border); }
html.theme-dark .editor-toolbar button { color: var(--salex-text-muted); }
html.theme-dark .editor-toolbar button:hover { background: rgba(255,255,255,0.08); color: var(--salex-text); }
html.theme-dark .editor-area { background: var(--salex-card-bg); border-color: var(--salex-border); color: var(--salex-text); }
html.theme-dark .stepper-item { background: rgba(255,255,255,0.04); color: var(--salex-text-muted); }
html.theme-dark .stepper-item .num { background: rgba(255,255,255,0.1); color: var(--salex-text); }
html.theme-dark .stepper-item:not(:last-child)::after { border-left-color: rgba(255,255,255,0.04); }
html.theme-dark .stepper-item.active { background: var(--salex-accent); color: #1B2F6F; }
html.theme-dark .stepper-item.active .num { background: #1B2F6F; color: var(--salex-accent); }
html.theme-dark .stepper-item.active:not(:last-child)::after { border-left-color: var(--salex-accent); }
html.theme-dark .stepper-item.done { background: rgba(16,185,129,0.18); color: #6EE7B7; }
html.theme-dark .stepper-item.done .num { background: var(--salex-success); color: #fff; }
html.theme-dark .stepper-item.done:not(:last-child)::after { border-left-color: rgba(16,185,129,0.18); }
html.theme-dark .health-bar span { background: rgba(255,255,255,0.1); }
html.theme-dark .toast-msg { background: var(--salex-card-bg); border-color: var(--salex-border); color: var(--salex-text); }
html.theme-dark .list-clean > li { border-bottom-color: var(--salex-border-soft); }
html.theme-dark .funnel-stage { background: var(--salex-accent); color: #1B2F6F; }
html.theme-dark .score-ring::before { background: var(--salex-card-bg); }
html.theme-dark .mini-cal th { color: var(--salex-text-muted); }
html.theme-dark .mini-cal td button { color: var(--salex-text); }
html.theme-dark .mini-cal td.muted button { color: var(--salex-text-soft); }
html.theme-dark .cal-cell { background: var(--salex-card-bg); color: var(--salex-text); }
html.theme-dark .cal-cell.muted { background: rgba(255,255,255,0.02); color: var(--salex-text-soft); }
html.theme-dark .cal-cell.today { background: rgba(245,158,11,0.12); }
html.theme-dark .cal-grid, html.theme-dark .cg { background: var(--salex-border); }
html.theme-dark .cc { background: var(--salex-card-bg); color: var(--salex-text); }
html.theme-dark .cc.muted { background: rgba(255,255,255,0.02); color: var(--salex-text-soft); }
html.theme-dark .tree-node, html.theme-dark .node { background: var(--salex-card-bg); border-color: var(--salex-border); color: var(--salex-text); }
html.theme-dark .tree-children, html.theme-dark .tree { border-left-color: var(--salex-border); }
