/* Blog Analytics Modern Dashboard Styles */
.blog-analytics {
  max-width: 1280px;
  margin: auto;
}

.ba-header {
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.ba-header-actions {
  align-items: center;
  gap: 12px;
}

.ba-header-actions button.primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: baSpin 0.7s linear infinite;
}

@keyframes baSpin {
  to { transform: rotate(360deg); }
}

@keyframes baPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.9); }
}

/* Filters */
.ba-ranges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ba-ranges button.active {
  background: var(--brand);
  color: var(--surface);
  border-color: var(--brand);
}

.ba-custom-form {
  margin-top: 14px;
  gap: 12px;
  align-items: flex-end;
}

.ba-site-filter {
  margin-top: 16px;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.ba-site-filter label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 650;
}

.ba-site-filter select {
  min-width: 240px;
}

.ba-period-text {
  font-weight: 500;
}

/* Sync Status Banner */
.ba-sync-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-radius: 12px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.ba-sync-banner.fresh {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.05);
}

.ba-sync-banner.stale {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
}

.ba-sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  flex-shrink: 0;
  animation: baPulse 2s ease-in-out infinite;
}

.ba-sync-banner.stale .ba-sync-dot {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.ba-sync-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.ba-sync-title {
  font-size: 13px;
  font-weight: 600;
}

.ba-sync-badge .badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text);
}

/* KPI Cards */
.ba-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.ba-kpi-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ba-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

.ba-kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ba-kpi-head span {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.ba-kpi-icon {
  font-size: 18px;
}

.ba-kpi-card b {
  font-size: 32px;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 2px 0;
}

.ba-kpi-foot {
  align-items: center;
  gap: 6px;
}

.ba-kpi-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text);
}

/* Interactive Growth Chart Card */
.ba-chart-panel {
  padding: 24px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.ba-chart-top {
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.ba-chart-heading {
  align-items: center;
  gap: 10px;
}

.ba-chart-heading h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.ba-chart-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 99px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--brand);
}

.ba-chart-controls {
  align-items: center;
  gap: 8px;
}

.ba-pill-group {
  display: inline-flex;
  background: var(--surface);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.ba-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ba-pill:hover:not(:disabled) {
  color: var(--text);
}

.ba-pill:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ba-pill.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 6px rgba(15, 118, 110, 0.25);
}

.ba-chart-site-bar {
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px dashed var(--border);
}

.ba-site-filter-label {
  font-weight: 600;
  margin-right: 4px;
}

.ba-site-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ba-site-pill:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}

.ba-site-pill.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.25);
}

.ba-color-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.ba-site-pill.active .ba-color-dot {
  background: #fff !important;
}

.ba-chart-badges {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.ba-badge-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.ba-badge-item b {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.ba-badge-item .micro {
  font-size: 11px;
  color: var(--muted);
}

.text-success {
  color: #10b981 !important;
}

.text-danger {
  color: #ef4444 !important;
}

.ba-chart-wrap {
  position: relative;
  width: 100%;
  height: 330px;
}

.ba-chart-note {
  margin-top: 10px;
  text-align: right;
  line-height: 1.5;
}

/* Two-column Layout: Staff Ranking & Blog Share */
.ba-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.ba-panel-card {
  padding: 20px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.ba-ranking {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 440px;
  overflow-y: auto;
  padding-right: 6px;
  margin-top: 14px;
}

.ba-person {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ba-person:hover {
  background: var(--surface-3);
  transform: translateX(2px);
}

.ba-person.active {
  border-color: var(--brand);
  background: rgba(15, 118, 110, 0.08);
}

.ba-bar {
  height: 8px;
  margin: 8px 0;
  border-radius: 9px;
  background: var(--surface-3);
  overflow: hidden;
}

.ba-bar span {
  display: block;
  height: 100%;
  border-radius: 9px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}

.ba-person strong {
  color: var(--brand);
  white-space: nowrap;
}

.ba-person strong small {
  font-weight: 500;
}

.ba-person-foot {
  align-items: center;
}

.ba-person-share {
  font-weight: 700;
  color: var(--brand);
  font-size: 11px;
}

/* Blog Donut */
.ba-donut {
  width: 190px;
  height: 190px;
  margin: 22px auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.ba-donut > div {
  width: 144px;
  height: 144px;
  background: var(--surface);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ba-donut b {
  font-size: 28px;
  font-weight: 750;
}

.ba-donut small {
  color: var(--muted);
}

.ba-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.ba-legend-row {
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.ba-legend-row:hover {
  background: var(--surface-3);
}

.ba-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 9px;
  border-radius: 3px;
}

.ba-legend .row {
  gap: 18px;
}

.ba-legend b {
  white-space: nowrap;
}

/* Auto / AI Channels */
.ba-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.ba-auto-item {
  padding: 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.ba-auto-item b {
  font-size: 14px;
  color: var(--text);
}

.ba-auto-item p {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* Top Articles */
.ba-top {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.ba-top-card {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ba-top-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

.ba-top-rank {
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.ba-top-badge {
  font-size: 11px;
  font-weight: 750;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--brand);
}

.ba-top h3 {
  font-size: 15px;
  line-height: 1.5;
  margin: 12px 0;
  text-transform: capitalize;
  overflow-wrap: anywhere;
}

.ba-top a {
  text-decoration: none;
  color: var(--text);
}

.ba-top a:hover {
  color: var(--brand);
  text-decoration: underline;
}

/* Article Table & Lookup */
.ba-articles-panel {
  padding: 22px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.ba-articles-header {
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.ba-btn-export {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.ba-filter-active-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--text);
  font-size: 12px;
  margin-bottom: 14px;
}

.ba-filter-active-pill button {
  border: none;
  padding: 0 4px;
  color: var(--brand);
  cursor: pointer;
  font-weight: 700;
}

.ba-article-filters {
  gap: 12px;
  margin: 14px 0 18px;
  align-items: center;
}

.ba-article-filters input {
  flex: 1;
  min-width: 240px;
}

.ba-article-filters select {
  width: auto;
  min-width: 160px;
  max-width: 240px;
}

.ba-table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.ba-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-size: 13px;
}

.ba-table th {
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-2);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.ba-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.ba-table tr:last-child td {
  border-bottom: none;
}

.ba-table tr:hover td {
  background: rgba(15, 118, 110, 0.02);
}

.ba-table .num {
  text-align: right;
  white-space: nowrap;
}

.ba-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--surface-3);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.ba-rank-badge.top {
  background: rgba(15, 118, 110, 0.15);
  color: var(--brand);
}

.ba-article-title-row a {
  font-weight: 650;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
  text-transform: capitalize;
}

.ba-article-title-row a:hover {
  color: var(--brand);
}

.ba-path {
  display: block;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.4;
  margin-top: 4px;
}

.ba-table .ba-path {
  max-width: 480px;
}

.ba-site-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-3);
  border-left: 3px solid var(--brand);
  white-space: nowrap;
}

.ba-num-highlight {
  font-size: 14px;
  color: var(--brand);
}

.ba-btn-copy {
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
}

.ba-table-empty {
  text-align: center;
  padding: 32px 16px !important;
}

.ba-pagination {
  padding-top: 16px;
  align-items: center;
}

.ba-pagination-controls {
  align-items: center;
  gap: 10px;
}

.ba-explainer {
  line-height: 1.7;
  margin-top: 16px;
}

.blog-analytics .panel {
  margin-bottom: 20px;
  padding: 20px;
}

/* Responsive Media Queries */
@media (max-width: 960px) {
  .ba-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ba-chart-badges {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ba-grid {
    grid-template-columns: 1fr;
  }
  .ba-top {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .ba-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .ba-chart-top {
    flex-direction: column;
    align-items: flex-start;
  }
  .ba-chart-controls {
    width: 100%;
    justify-content: flex-start;
  }
  .ba-chart-wrap {
    height: 270px;
  }
  .ba-site-filter {
    flex-direction: column;
    align-items: flex-start;
  }
  .ba-site-filter label {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
  }
  .ba-site-filter select {
    width: 100%;
  }
  .ba-article-filters {
    flex-direction: column;
    align-items: stretch;
  }
  .ba-article-filters input,
  .ba-article-filters select {
    width: 100%;
    max-width: none;
  }
  .ba-pagination {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .ba-pagination-controls {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 480px) {
  .ba-kpis {
    grid-template-columns: 1fr;
  }
  .ba-chart-badges {
    grid-template-columns: 1fr;
  }
  .ba-ranges button {
    padding: 6px 9px;
    font-size: 12px;
  }
}
