/* ============================================================
   CRM Farmalink — Estilos personalizados
   Bootstrap 5 base + overrides + componentes propios
   ============================================================ */

/* Variables globales (sobrescritas por PHP en _plantilla.php) */
:root {
  --crm-color:        #1e6fb0;
  --crm-color-dark:   #164f80;
  --crm-sidebar-bg:   #1c2b3a;
  --crm-sidebar-w:    240px;
  --crm-topbar-h:     56px;
  --crm-radius:       .5rem;
  --crm-shadow:       0 .125rem .5rem rgba(0,0,0,.1);
}

/* ── LAYOUT GENERAL ────────────────────────────────────────── */
body {
  background: #f0f2f5;
  font-size: .9rem;
}

#crm-wrapper {
  min-height: 100vh;
}

/* ── SIDEBAR ───────────────────────────────────────────────── */
#crm-sidebar {
  width: var(--crm-sidebar-w);
  min-width: var(--crm-sidebar-w);
  background: var(--crm-sidebar-bg);
  color: #c8d6e0;
  min-height: 100vh;
  transition: transform .25s ease;
  z-index: 100;
}

.crm-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 1rem 1.25rem;
  color: #fff;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 700;
  background: rgba(0,0,0,.2);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.crm-brand:hover { color: #fff; }

.crm-user-info {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.crm-avatar { color: #7e9bb5; }

.crm-nav-link {
  color: #a8c0d1 !important;
  border-radius: var(--crm-radius);
  padding: .45rem .875rem;
  font-size: .855rem;
  transition: background .15s, color .15s;
}
.crm-nav-link:hover,
.crm-nav-link.active {
  background: rgba(255,255,255,.1);
  color: #fff !important;
}
.crm-nav-link i { width: 1.1rem; text-align: center; }

#crm-sidebar hr { border-color: rgba(255,255,255,.08); }

/* ── TOPBAR ────────────────────────────────────────────────── */
.crm-topbar {
  height: var(--crm-topbar-h);
  background: #fff;
  border-bottom: 1px solid #e5e9ef;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  position: sticky;
  top: 0;
  z-index: 50;
}

/* ── PÁGINA PRINCIPAL ──────────────────────────────────────── */
.crm-page-body {
  padding: 1.5rem;
}

.crm-seccion-titulo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid #e5e9ef;
}
.crm-seccion-titulo h4 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #1a2533;
}

/* ── TARJETAS MÉTRICAS ─────────────────────────────────────── */
.crm-metric-card {
  border-radius: var(--crm-radius);
}
.crm-metric-card .card-body {
  padding: 1rem 1.25rem;
}
.crm-metric-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: .5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── EVENTO ÍCONO (listado) ────────────────────────────────── */
.crm-evento-icono {
  width: 2rem;
  height: 2rem;
  border-radius: .375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: .8rem;
}

/* ── TABLA ─────────────────────────────────────────────────── */
.crm-tabla {
  font-size: .85rem;
}
.crm-tabla thead th {
  font-weight: 600;
  color: #445566;
  white-space: nowrap;
}
.btn-xs {
  padding: .15rem .45rem;
  font-size: .75rem;
  border-radius: .25rem;
}

/* ── FORMULARIOS DINÁMICOS ─────────────────────────────────── */
.crm-grupo-titulo {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--crm-color);
  font-weight: 700;
  margin: 1.25rem 0 .5rem;
  padding-bottom: .25rem;
  border-bottom: 2px solid var(--crm-color);
}
.crm-grupo-titulo:first-child { margin-top: 0; }

.crm-detalle-row dt {
  font-weight: 600;
  color: #445566;
  font-size: .85rem;
}
.crm-detalle-row dd {
  color: #1a2533;
  font-size: .875rem;
  margin-bottom: .35rem;
}

/* ── TIMELINE ──────────────────────────────────────────────── */
.crm-timeline {
  position: relative;
  padding-left: 2rem;
}
.crm-timeline::before {
  content: '';
  position: absolute;
  left: .95rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e5e9ef;
}
.crm-timeline-item {
  position: relative;
  margin-bottom: 1rem;
}
.crm-timeline-dot {
  position: absolute;
  left: -1.9rem;
  top: .6rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .65rem;
  z-index: 1;
  box-shadow: 0 0 0 3px #fff;
}
.crm-timeline-content {
  border-radius: var(--crm-radius) !important;
  border-left: 3px solid transparent;
}
.crm-evento-detalle {
  font-size: .82rem;
}

/* ── PAGINACIÓN ────────────────────────────────────────────── */
.page-link {
  color: var(--crm-color);
}
.page-item.active .page-link {
  background: var(--crm-color);
  border-color: var(--crm-color);
}

/* ── ABM PAGES ─────────────────────────────────────────────── */
.crm-abm-header {
  background: var(--crm-sidebar-bg);
  color: #fff;
  padding: .75rem 1.5rem;
  margin-bottom: 1.5rem;
}
.crm-abm-header h5 { margin: 0; font-weight: 700; }

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 767.98px) {
  #crm-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
  }
  #crm-sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 0 100vw rgba(0,0,0,.4);
  }
  .crm-page-body {
    padding: 1rem;
  }
}

/* ── SCROLLBAR ─────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f0f2f5; }
::-webkit-scrollbar-thumb { background: #c0ccd8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9aaabb; }

/* ── UTILIDADES ────────────────────────────────────────────── */
.text-truncate-2 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.fw-600 { font-weight: 600; }
.fs-75  { font-size: .75rem; }
