/* ============================================================
   CRM Maroc — Styles principaux
   ============================================================ */

:root {
  --sidebar-bg:       #1e3a5f;
  --sidebar-hover:    #2a4f80;
  --sidebar-active:   #0d6efd;
  --sidebar-width:    240px;
  --sidebar-muted:    rgba(255,255,255,.45);
  --accent:           #0d6efd;
  --navbar-height:    56px;
}

/* ── Layout ─────────────────────────────────────────────── */
body {
  background: #f4f6f9;
  font-size: .875rem;
}

#wrapper {
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: #fff;
  flex-shrink: 0;
  transition: width .25s ease;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 58px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: var(--navbar-height);
  background: rgba(0,0,0,.15);
}

.sidebar-brand-text {
  font-weight: 700;
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.sidebar-logo {
  max-height: 36px;
  max-width: 36px;
  object-fit: contain;
  border-radius: 4px;
}

.border-sidebar { border-color: rgba(255,255,255,.12) !important; }

/* Navigation items */
.sidebar .nav-link {
  color: rgba(255,255,255,.75);
  border-radius: 6px;
  padding: .45rem .75rem;
  font-size: .82rem;
  transition: background .15s, color .15s;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.sidebar .nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar .nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

.nav-icon {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.nav-section-title {
  list-style: none;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--sidebar-muted);
  padding: 1rem .75rem .2rem;
  text-transform: uppercase;
}

/* Avatar user footer */
.sidebar-footer {
  background: rgba(0,0,0,.15);
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.text-sidebar-muted { color: var(--sidebar-muted); }
.text-accent { color: var(--accent); }

/* ── Page content ───────────────────────────────────────── */
#page-content-wrapper {
  min-width: 0;
  overflow: auto;
}

/* ── KPI Cards ──────────────────────────────────────────── */
.kpi-card .kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.kpi-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.1;
}

.kpi-label {
  font-size: .75rem;
  font-weight: 600;
  color: #555;
}

.kpi-sub {
  font-size: .7rem;
  color: #888;
}

.bg-primary-soft { background: rgba(13,110,253,.12); }
.bg-success-soft { background: rgba(25,135, 84,.12); }
.bg-info-soft    { background: rgba(13,202,240,.12); }
.bg-danger-soft  { background: rgba(220, 53, 69,.12); }

/* ── Tables ─────────────────────────────────────────────── */
.table td, .table th {
  vertical-align: middle;
}

.table-hover tbody tr:hover {
  background: rgba(13,110,253,.04);
}

/* ── Buttons extra-small ─────────────────────────────────── */
.btn-xs {
  padding: .15rem .4rem;
  font-size: .75rem;
  border-radius: 4px;
}

/* ── Login ──────────────────────────────────────────────── */
.bg-login {
  background: linear-gradient(135deg, #1e3a5f 0%, #2a4f80 50%, #0d6efd 100%);
}

.login-logo-wrap {
  width: 60px;
  height: 60px;
  background: rgba(13,110,253,.1);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

/* ── Chart bars ─────────────────────────────────────────── */
.chart-bar {
  min-width: 4px;
  transition: height .3s ease;
  opacity: .85;
}

.chart-bar:hover { opacity: 1; }

/* ── Typography helpers ──────────────────────────────────── */
.x-small { font-size: .7rem; }

/* ── Cards ──────────────────────────────────────────────── */
.card-header {
  font-size: .82rem;
}

/* ── Mobile sidebar toggle ───────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    z-index: 1040;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }

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

  #page-content-wrapper {
    width: 100%;
  }
}

/* ── Sidebar toggle (desktop) ────────────────────────────── */
#wrapper.sidebar-collapsed .sidebar {
  width: 58px;
}

#wrapper.sidebar-collapsed .sidebar-brand-text,
#wrapper.sidebar-collapsed .nav-section-title,
#wrapper.sidebar-collapsed .nav-link span:not(.nav-icon),
#wrapper.sidebar-collapsed .sidebar-footer .lh-sm {
  display: none;
}

/* Badge "Avoir" */
.bg-purple { background: #6f42c1 !important; }
