/* History page custom styling */
:root {
  --history-bg: var(--app-bg, #eef2f8);
  --history-card: var(--gtuit-surface-card, #ffffff);
  --history-border: #dce3ed;
  --history-ink: #0f172a;
  --history-muted: #6b7280;
  --history-primary: var(--gtuit-action-bg, var(--gtuit-accent-500, #3b82f6));
  --history-primary-dark: var(
    --gtuit-action-bg-hover,
    var(--gtuit-accent-600, #2563eb)
  );
  --history-primary-rgb: var(
    --gtuit-action-bg-rgb,
    var(--gtuit-accent-500-rgb, 59 130 246)
  );
  --history-primary-dark-rgb: var(
    --gtuit-action-bg-hover-rgb,
    var(--gtuit-accent-600-rgb, 37 99 235)
  );
  --history-accent-rgb: var(--gtuit-accent-500-rgb, 59 130 246);
  --history-focus: var(--focus-ring, rgba(219, 234, 254, 0.85));
  --history-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
}

.gtuit-history-page {
  display: grid;
  gap: 18px;
  padding-bottom: 32px;
  background: var(--history-bg);
}

.gtuit-history-page .gtuit-panel-card {
  background: var(--history-card);
  border: 1px solid var(--history-border);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: var(--history-shadow);
}

/* Filters */
.gtuit-history-filters {
  display: grid;
  gap: 12px;
  background: rgb(var(--history-primary-rgb) / 0.05);
  border: 1px solid var(--history-border);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.06);
}

.gtuit-history-filters__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  align-items: end;
}

.gtuit-form__field {
  display: grid;
  gap: 6px;
}

.gtuit-form__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--history-muted);
}

.gtuit-history-filters input,
.gtuit-history-filters select {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  font-size: 14px;
  color: var(--history-ink);
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.gtuit-history-filters select {
  border-radius: var(--gtuit-control-radius, 999px);
}

.gtuit-history-filters select[multiple],
.gtuit-history-filters select[size]:not([size="1"]) {
  border-radius: var(--gtuit-control-radius-multi, 16px);
}

.gtuit-history-filters input:focus,
.gtuit-history-filters select:focus {
  border-color: var(--history-primary);
  box-shadow: 0 0 0 3px var(--history-focus);
  outline: none;
  background: #fff;
}

.gtuit-history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
  grid-column: 1 / -1;
  align-self: end;
  justify-self: start;
}

.gtuit-history-filters__header {
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.gtuit-history-filters__header--inline {
  display: none;
}

.gtuit-history-filters__toggle .dashicons {
  font-size: 16px;
}

@media (max-width: 960px) {
  .gtuit-history-filters__header--inline {
    display: flex;
  }

  .gtuit-history-filters.is-collapsed .gtuit-history-filters__grid {
    display: none;
  }

  .gtuit-history-filters__grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .gtuit-history-actions {
    grid-column: 1 / -1;
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .gtuit-history-actions {
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
    width: 100%;
  }

  .gtuit-history-actions .gtuit-button {
    width: 100%;
    justify-content: center;
  }
}

/* Summary - matches dashboard KPI cards */
.gtuit-history-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.gtuit-history-summary__card {
  border-radius: 18px;
  padding: 20px 22px;
  color: #0f172a;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0.9),
    rgba(241, 245, 249, 0.8)
  );
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  min-height: 100px;
  justify-content: space-between;
}

/* Card color variants */
.gtuit-history-summary__card:nth-child(1) {
  border-color: rgba(37, 99, 235, 0.25);
  background: linear-gradient(
    135deg,
    rgba(219, 234, 254, 0.9),
    rgba(191, 219, 254, 0.9)
  );
}

.gtuit-history-summary__card:nth-child(2) {
  border-color: rgba(124, 58, 237, 0.25);
  background: linear-gradient(
    135deg,
    rgba(237, 233, 254, 0.9),
    rgba(221, 214, 254, 0.9)
  );
}

.gtuit-history-summary__card:nth-child(3) {
  border-color: rgba(13, 148, 136, 0.25);
  background: linear-gradient(
    135deg,
    rgba(222, 247, 250, 0.95),
    rgba(191, 235, 240, 0.9)
  );
}

.gtuit-history-summary__card:nth-child(4) {
  border-color: rgba(16, 185, 129, 0.25);
  background: linear-gradient(
    135deg,
    rgba(209, 250, 229, 0.95),
    rgba(167, 243, 208, 0.9)
  );
}

.gtuit-history-summary__label {
  margin: 0;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.5);
  line-height: 1.15;
}

.gtuit-history-summary__value {
  margin: 2px 0 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.005em;
  color: #0b132b;
  line-height: 1.12;
}

/* Layout */
.gtuit-history-layout {
  display: grid;
  grid-template-columns: 2.15fr 1fr;
  gap: 18px;
  align-items: start;
}

@media (max-width: 960px) {
  .gtuit-history-layout {
    grid-template-columns: 1fr;
  }
}

/* Tabs */
.gtuit-history-feed {
  display: grid;
  gap: 14px;
  min-height: 320px;
  overflow: visible;
  background: rgba(248, 250, 252, 0.65);
  border: 1px solid var(--history-border);
  border-radius: 18px;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.05);
}

.gtuit-history-feed .gtuit-activity-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.gtuit-history-feed .gtuit-activity-tabs a {
  width: 100%;
  min-height: 36px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 999px;
  background: #fff;
  color: rgba(15, 23, 42, 0.75);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
  text-decoration: none;
}

.gtuit-history-feed .gtuit-activity-tabs a:hover,
.gtuit-history-feed .gtuit-activity-tabs a:focus {
  background: rgb(var(--history-primary-rgb) / 0.08);
  border-color: rgb(var(--history-primary-rgb) / 0.18);
  color: rgb(var(--history-primary-rgb) / 0.85);
  box-shadow: 0 4px 12px rgb(var(--history-primary-rgb) / 0.1);
}

.gtuit-history-feed .gtuit-activity-tabs a.is-active {
  background: var(--history-primary);
  color: #fff;
  border-color: rgb(var(--history-primary-rgb) / 0.8);
  box-shadow: 0 8px 18px rgb(var(--history-primary-rgb) / 0.18);
}

.gtuit-history-feed__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.gtuit-history-feed__status {
  display: grid;
  gap: 4px;
}

.gtuit-history-feed__eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--history-muted);
}

.gtuit-history-feed__count {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--history-ink);
}

.gtuit-history-pager {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.gtuit-history-pager__page {
  font-size: 12px;
  font-weight: 700;
  color: var(--history-muted);
}

@media (max-width: 720px) {
  .gtuit-history-feed__header {
    flex-direction: column;
    align-items: stretch;
  }

  .gtuit-history-pager {
    justify-content: space-between;
  }
}

/* Timeline */
.gtuit-history-feed .gtuit-history-timeline {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 10px 0 10px 28px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.gtuit-history-feed .gtuit-history-timeline::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: linear-gradient(
    180deg,
    rgb(var(--history-primary-rgb) / 0.3) 0%,
    rgb(var(--history-primary-rgb) / 0.08) 100%
  );
  border-radius: 2px;
}

.gtuit-history-feed .gtuit-history-timeline[data-has-history="0"]::before {
  display: none;
}

.gtuit-history-item {
  position: relative;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.gtuit-history-marker {
  margin-top: 12px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--history-primary);
  box-shadow: 0 0 0 4px rgb(var(--history-primary-rgb) / 0.12);
}

.gtuit-history-card {
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: none;
  display: grid;
  gap: 6px;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    border-color 0.12s ease;
}

.gtuit-history-card:hover {
  transform: translateY(-1px);
  border-color: rgb(var(--history-primary-rgb) / 0.2);
}

.gtuit-history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: rgba(15, 23, 42, 0.6);
  align-items: center;
}

.gtuit-history-type {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgb(var(--history-primary-rgb) / 0.12);
  color: var(--history-primary);
  font-weight: 700;
  letter-spacing: 0.03em;
  font-size: 10px;
  text-transform: uppercase;
}

.gtuit-history-type--created {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
}

.gtuit-history-type--updated {
  background: rgb(var(--history-primary-rgb) / 0.15);
  color: var(--history-primary-dark);
}

.gtuit-history-type--deleted {
  background: rgba(239, 68, 68, 0.15);
  color: #b91c1c;
}

.gtuit-history-type--stage-changed,
.gtuit-history-type--stage_changed {
  background: rgba(245, 158, 11, 0.18);
  color: #b45309;
}

.gtuit-history-type--linked,
.gtuit-history-type--unlinked {
  background: rgba(45, 212, 191, 0.16);
  color: #0f766e;
}

.gtuit-history-type--created::before,
.gtuit-history-type--updated::before,
.gtuit-history-type--deleted::before,
.gtuit-history-type--stage-changed::before,
.gtuit-history-type--stage_changed::before,
.gtuit-history-type--linked::before,
.gtuit-history-type--unlinked::before {
  content: none;
  display: none;
}

.gtuit-history-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--history-ink);
}

.gtuit-history-link-row {
  margin: 0;
}

.gtuit-history-link {
  font-size: 12px;
  font-weight: 700;
  color: var(--history-primary-dark);
  text-decoration: none;
}

.gtuit-history-link:hover,
.gtuit-history-link:focus {
  text-decoration: underline;
}

.gtuit-history-details {
  font-size: 13px;
  color: var(--history-muted);
  line-height: 1.45;
  margin: 0;
  padding-left: 16px;
  list-style: disc;
}

.gtuit-history-details li {
  margin: 0;
}

.gtuit-history-details li + li {
  margin-top: 4px;
}

.gtuit-history-author {
  font-weight: 600;
}

.gtuit-history-empty {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 18px;
  color: var(--history-muted);
  border: 1px dashed rgba(148, 163, 184, 0.6);
  border-radius: 16px;
}

.gtuit-history-empty .dashicons {
  font-size: 28px;
  color: rgb(var(--history-primary-rgb) / 0.65);
}

.gtuit-history-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  color: var(--history-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 12px;
}

.gtuit-history-divider::before,
.gtuit-history-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(148, 163, 184, 0.35);
}

/* Sidebar highlights */
.gtuit-history-side {
  display: grid;
  gap: 12px;
}

.gtuit-history-side h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--history-ink);
}

.gtuit-history-side p {
  margin: 0 0 8px 0;
  color: var(--history-muted);
  font-size: 13px;
}

.gtuit-history-side ul {
  margin: 4px 0 12px 18px;
  color: var(--history-ink);
  font-size: 13px;
}

.gtuit-history-side strong {
  color: var(--history-ink);
}

.gtuit-history-side .gtuit-panel-card {
  background: var(--history-card);
  border: 1px solid var(--history-border);
  box-shadow: var(--history-shadow);
}

.gtuit-history-side .gtuit-panel-card ul li {
  padding: 4px 0;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.3);
}

.gtuit-history-side .gtuit-panel-card ul li:last-child {
  border-bottom: 0;
}

.gtuit-history-side .gtuit-panel-card span.gtuit-history-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgb(var(--history-primary-rgb) / 0.1);
  color: var(--history-primary-dark);
  font-weight: 700;
  font-size: 12px;
}

.gtuit-history-object {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.9);
  display: inline-block;
}

.gtuit-history-object--task,
.gtuit-history-object--note,
.gtuit-history-object--file,
.gtuit-history-object--upload,
.gtuit-history-object--attachment {
  background: #475569;
}

.gtuit-history-object {
  display: none;
}

/* Activity Grid */
.gtuit-history-activity-card h3 {
  margin-bottom: 14px;
}

.gtuit-history-activity-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 10px;
  background: rgba(241, 245, 249, 0.6);
  border-radius: 12px;
  margin-bottom: 12px;
}

.gtuit-history-activity-tile {
  aspect-ratio: 1;
  border-radius: 6px;
  background: rgba(203, 213, 225, 0.4);
  cursor: default;
  position: relative;
}

.gtuit-history-activity-tile::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.15s ease 0.2s,
    visibility 0.15s ease 0.2s;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
}

.gtuit-history-activity-tile:hover::after {
  opacity: 1;
  visibility: visible;
}

.gtuit-history-activity-tile--level-0 {
  background: rgba(203, 213, 225, 0.4);
}

.gtuit-history-activity-tile--level-1 {
  background: rgb(var(--gtuit-accent-200-rgb) / 0.7);
}

.gtuit-history-activity-tile--level-2 {
  background: rgb(var(--gtuit-accent-400-rgb) / 0.8);
}

.gtuit-history-activity-tile--level-3 {
  background: rgb(var(--gtuit-accent-500-rgb) / 0.9);
}

.gtuit-history-activity-tile--level-4 {
  background: var(--gtuit-accent-600);
}

.gtuit-history-activity-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  font-size: 12px;
  color: var(--history-muted);
}

.gtuit-history-activity-legend .gtuit-history-activity-tile {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  cursor: default;
}

.gtuit-history-activity-legend .gtuit-history-activity-tile:hover {
  transform: none;
  box-shadow: none;
}

/* Most Active Users */
.gtuit-history-most-active-card h3 {
  margin-bottom: 14px;
}

.gtuit-history-most-active-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
}

.gtuit-history-most-active-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.gtuit-history-most-active-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.gtuit-history-most-active-item:first-child {
  padding-top: 0;
}

.gtuit-history-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  flex-shrink: 0;
}

.gtuit-history-avatar--rank-1 {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
}

.gtuit-history-avatar--rank-2 {
  background: linear-gradient(
    135deg,
    var(--gtuit-accent-600),
    var(--gtuit-accent-400)
  );
}

.gtuit-history-avatar--rank-3 {
  background: linear-gradient(135deg, #10b981, #6ee7b7);
}

.gtuit-history-most-active-info {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.gtuit-history-most-active-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--history-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gtuit-history-most-active-count {
  font-size: 13px;
  color: var(--history-muted);
}

.gtuit-history-most-active-rank {
  font-size: 18px;
  font-weight: 700;
  color: rgba(148, 163, 184, 0.7);
  margin-left: auto;
}

/* Volume Bar Chart */
.gtuit-history-volume-card h3 {
  margin-bottom: 14px;
}

.gtuit-history-volume-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 80px;
  padding: 10px 6px;
  background: rgba(241, 245, 249, 0.6);
  border-radius: 12px;
  margin-bottom: 12px;
}

.gtuit-history-volume-bar {
  flex: 1;
  min-height: 4px;
  background: linear-gradient(
    180deg,
    var(--gtuit-accent-400),
    var(--gtuit-accent-600)
  );
  border-radius: 3px 3px 0 0;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
  cursor: pointer;
}

.gtuit-history-volume-bar:hover {
  opacity: 0.8;
  transform: scaleY(1.05);
  transform-origin: bottom;
}

.gtuit-history-volume-total {
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: var(--history-muted);
}

.gtuit-history-volume-total strong {
  color: var(--history-ink);
  font-weight: 700;
}
