/**
 * activity-timeline.css — Audit Trail / Activity Timeline UI v1.0
 * Namespace: .atl-  · Zero interference with existing layout.
 */

/* ── TOKENS ──────────────────────────────────────────── */
:root {
  --atl-accent:    var(--primary, #8e44ad);
  --atl-line:      #E5E7EB;
  --atl-node-sz:   32px;

  /* Category colors */
  --atl-usuario:   #3B82F6;
  --atl-entidad:   #8B5CF6;
  --atl-estado:    #10B981;
  --atl-ia:        #06B6D4;
  --atl-sistema:   #6B7280;
  --atl-admin:     #EF4444;
}

/* ── PAGE SECTION ─────────────────────────────────────── */
.atl-section {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ── HEADER + CONTROLS ─────────────────────────────────── */
.atl-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.atl-header__title {
  font-size: 20px; font-weight: 900; color: #1F2937;
  display: flex; align-items: center; gap: 8px;
}
.atl-header__sub {
  font-size: 13px; color: #9CA3AF; margin-top: 2px;
}

/* Stats strip */
.atl-stats {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px;
}
.atl-stat {
  flex: 1; min-width: 100px;
  background: #F9FAFB; border: 1px solid #F3F4F6;
  border-radius: 10px; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
}
.atl-stat__icon { font-size: 20px; }
.atl-stat__val  { font-size: 18px; font-weight: 800; color: #1F2937; }
.atl-stat__label{ font-size: 11px; color: #6B7280; }

/* ── FILTER BAR ────────────────────────────────────────── */
.atl-filters {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 20px; align-items: center;
}
.atl-filter-group {
  display: flex; align-items: center; gap: 5px;
}
.atl-filter-group label {
  font-size: 12px; font-weight: 700; color: #6B7280; white-space: nowrap;
}
.atl-select, .atl-input {
  height: 34px; padding: 0 10px;
  border: 1.5px solid #E5E7EB; border-radius: 8px;
  font-size: 12px; color: #374151; background: #fff;
  outline: none; transition: border-color .15s;
}
.atl-select:focus, .atl-input:focus { border-color: var(--atl-accent); }
.atl-input { min-width: 160px; }
.atl-btn-apply {
  height: 34px; padding: 0 16px;
  background: var(--atl-accent); color: #fff;
  border: none; border-radius: 8px; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: opacity .15s;
}
.atl-btn-apply:hover { opacity: .88; }
.atl-btn-reset {
  height: 34px; padding: 0 12px;
  background: #F3F4F6; color: #6B7280;
  border: none; border-radius: 8px; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: background .13s;
}
.atl-btn-reset:hover { background: #E5E7EB; }

/* Category tab strip */
.atl-cats {
  display: flex; gap: 5px; margin-bottom: 18px;
  overflow-x: auto; scrollbar-width: none;
}
.atl-cats::-webkit-scrollbar { display: none; }
.atl-cat {
  padding: 5px 12px; border-radius: 99px;
  border: 1.5px solid #E5E7EB; background: #fff; color: #6B7280;
  font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: all .13s;
}
.atl-cat:hover { border-color: var(--atl-accent); color: var(--atl-accent); }
.atl-cat.active { background: var(--atl-accent); color: #fff; border-color: var(--atl-accent); }

/* ── TIMELINE ──────────────────────────────────────────── */
.atl-timeline {
  position: relative;
  padding-left: 52px;
}
/* Vertical rule */
.atl-timeline::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 15px;
  width: 2px; background: var(--atl-line);
  border-radius: 1px;
}

/* Date group label */
.atl-day {
  position: relative; margin-bottom: 6px; margin-top: 22px;
  font-size: 11px; font-weight: 800; color: #9CA3AF;
  text-transform: uppercase; letter-spacing: .5px;
  padding-left: 0;
  margin-left: -37px; /* align to line */
}
.atl-day::before {
  content: '';
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--atl-line);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--atl-line);
  vertical-align: middle;
  margin-right: 10px;
  position: absolute;
  left: -36px; top: 50%; transform: translateY(-50%);
}

/* ── EVENT CARD ─────────────────────────────────────────── */
.atl-event {
  position: relative;
  display: flex; gap: 0;
  margin-bottom: 4px;
}

/* Node */
.atl-event__node {
  position: absolute;
  left: -51px; top: 10px;
  width: var(--atl-node-sz); height: var(--atl-node-sz);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  box-shadow: 0 0 0 3px #fff, 0 0 0 4px var(--atl-line);
  z-index: 1;
  transition: transform .18s, box-shadow .18s;
}
.atl-event:hover .atl-event__node {
  transform: scale(1.12);
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--atl-accent);
}
/* Category node colors */
.atl-event--usuario .atl-event__node   { background: #EFF6FF; color: var(--atl-usuario); }
.atl-event--entidad .atl-event__node   { background: #F5F3FF; color: var(--atl-entidad); }
.atl-event--estado  .atl-event__node   { background: #ECFDF5; color: var(--atl-estado);  }
.atl-event--ia      .atl-event__node   { background: #ECFEFF; color: var(--atl-ia);      }
.atl-event--sistema .atl-event__node   { background: #F3F4F6; color: var(--atl-sistema); }
.atl-event--admin   .atl-event__node   { background: #FEF2F2; color: var(--atl-admin);   }

/* Card body */
.atl-event__card {
  flex: 1;
  background: #fff;
  border: 1px solid #F3F4F6;
  border-radius: 10px;
  padding: 10px 14px;
  transition: border-color .15s, box-shadow .15s;
  cursor: default;
}
.atl-event__card:hover {
  border-color: #E5E7EB;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.atl-event__card.has-diff { cursor: pointer; }
.atl-event__card.has-diff:hover { border-color: var(--atl-accent); }

.atl-event__top {
  display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap;
}
.atl-event__action {
  font-size: 13px; font-weight: 700; color: #1F2937; flex: 1;
}
.atl-event__time {
  font-size: 11px; color: #9CA3AF; white-space: nowrap; flex-shrink: 0;
}
.atl-event__who {
  font-size: 12px; color: #6B7280; margin-top: 2px;
}
.atl-event__entity {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 5px; padding: 3px 8px;
  background: #F9FAFB; border-radius: 6px;
  font-size: 11px; color: #6B7280; font-weight: 600;
  border: 1px solid #F3F4F6;
}
.atl-event__entity-link {
  color: var(--atl-accent); text-decoration: none; font-weight: 700;
}
.atl-event__entity-link:hover { text-decoration: underline; }

/* Category badge */
.atl-cat-badge {
  font-size: 9px; font-weight: 800; padding: 2px 6px;
  border-radius: 99px; text-transform: uppercase; letter-spacing: .3px; flex-shrink: 0;
}
.atl-cat-badge--usuario   { background:#EFF6FF; color:var(--atl-usuario); }
.atl-cat-badge--entidad   { background:#F5F3FF; color:var(--atl-entidad); }
.atl-cat-badge--estado    { background:#ECFDF5; color:var(--atl-estado); }
.atl-cat-badge--ia        { background:#ECFEFF; color:var(--atl-ia); }
.atl-cat-badge--sistema   { background:#F3F4F6; color:var(--atl-sistema); }
.atl-cat-badge--admin     { background:#FEF2F2; color:var(--atl-admin); }

/* ── DIFF BLOCK ─────────────────────────────────────────── */
.atl-diff {
  margin-top: 8px;
  background: #F9FAFB; border-radius: 7px;
  border: 1px solid #F3F4F6;
  overflow: hidden;
  display: none;
}
.atl-diff.open { display: block; }
.atl-diff__row {
  display: grid; grid-template-columns: 120px 1fr 1fr;
  gap: 0; font-size: 12px;
  border-bottom: 1px solid #F3F4F6;
  padding: 0;
}
.atl-diff__row:last-child { border: none; }
.atl-diff__field {
  padding: 7px 10px; font-weight: 700; color: #6B7280;
  background: #F3F4F6; border-right: 1px solid #E5E7EB;
  display: flex; align-items: center;
}
.atl-diff__before {
  padding: 7px 10px; color: #991B1B;
  background: #FFF5F5; border-right: 1px solid #E5E7EB;
  word-break: break-all;
}
.atl-diff__after {
  padding: 7px 10px; color: #065F46;
  background: #F0FDF4; word-break: break-all;
}
.atl-diff__hdr {
  display: grid; grid-template-columns: 120px 1fr 1fr;
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  color: #9CA3AF; letter-spacing: .4px;
  background: #F3F4F6; border-bottom: 1px solid #E5E7EB;
}
.atl-diff__hdr span { padding: 5px 10px; }

.atl-diff-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 5px; padding: 3px 8px;
  background: none; border: 1px solid #E5E7EB; border-radius: 5px;
  font-size: 11px; font-weight: 700; color: #6B7280; cursor: pointer;
  transition: all .12s;
}
.atl-diff-toggle:hover { background: #F3F4F6; color: #374151; }

/* ── SKELETON ─────────────────────────────────────────── */
.atl-skel { padding-left: 52px; }
.atl-skel-event {
  display: flex; gap: 12px; margin-bottom: 8px;
}
.atl-skel-node {
  width:32px; height:32px; border-radius:50%; flex-shrink:0;
  background:linear-gradient(90deg,#F3F4F6 25%,#E9EAED 50%,#F3F4F6 75%);
  background-size:200% 100%; animation:atlShim 1.4s infinite;
}
.atl-skel-card {
  flex:1; height:56px; border-radius:10px;
  background:linear-gradient(90deg,#F3F4F6 25%,#E9EAED 50%,#F3F4F6 75%);
  background-size:200% 100%; animation:atlShim 1.4s infinite;
}
@keyframes atlShim { 0%{background-position:200% 0}100%{background-position:-200% 0} }

/* ── EMPTY ────────────────────────────────────────────── */
.atl-empty {
  padding: 60px 20px; text-align: center;
}
.atl-empty__icon  { font-size: 36px; display: block; margin-bottom: 10px; }
.atl-empty__title { font-size: 14px; font-weight: 700; color: #374151; }
.atl-empty__sub   { font-size: 12px; color: #9CA3AF; margin-top: 4px; }

/* ── LOAD MORE ────────────────────────────────────────── */
.atl-load-more-wrap { text-align: center; margin-top: 20px; }
.atl-load-more {
  background: none; border: 1.5px solid #E5E7EB;
  padding: 8px 24px; border-radius: 8px;
  font-size: 13px; font-weight: 700; color: #6B7280; cursor: pointer;
  transition: all .13s;
}
.atl-load-more:hover { border-color: var(--atl-accent); color: var(--atl-accent); }

/* ── CONTEXTUAL WIDGET ─────────────────────────────────── */
.atl-widget {
  border: 1px solid #F3F4F6; border-radius: 12px;
  overflow: hidden; background: #fff;
}
.atl-widget__hdr {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid #F3F4F6;
  font-size: 13px; font-weight: 800; color: #1F2937;
}
.atl-widget__hdr-btn {
  margin-left: auto; font-size: 11px; font-weight: 700;
  color: var(--atl-accent); background: none; border: none;
  cursor: pointer; padding: 4px 8px; border-radius: 5px;
  transition: background .12s;
}
.atl-widget__hdr-btn:hover { background: #F5F3FF; }
.atl-widget__body {
  padding: 0; max-height: 340px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.atl-widget .atl-timeline { padding-left: 44px; padding-right: 12px; }
.atl-widget .atl-timeline::before { left: 12px; }
.atl-widget .atl-event__node { left: -43px; }

/* ── RESPONSIVE ────────────────────────────────────────── */
@media (max-width: 640px) {
  .atl-section      { padding: 16px 12px 60px; }
  .atl-timeline     { padding-left: 44px; }
  .atl-timeline::before { left: 12px; }
  .atl-event__node  { left: -43px; }
  .atl-diff__row    { grid-template-columns: 90px 1fr 1fr; }
  .atl-stats        { gap: 6px; }
  .atl-stat         { min-width: 80px; padding: 8px 10px; }
}
