/* ==========================================================================
   Inteligen CMS — Admin Dashboard v2 Stylesheet
   admin-v2.css  ·  loads after admin.css  ·  all classes use "v2-" prefix

   Design tokens
     Background     #f1f5f9
     Card BG        #ffffff
     Dark           #0f172a
     Accent/Gold    #fbbf24
     Text primary   #0f172a  |  secondary #64748b  |  muted #94a3b8
     Success        #22c55e / #dcfce7
     Warning        #f59e0b / #fef3c7
     Danger         #ef4444 / #fee2e2
     Info           #0ea5e9 / #e0f2fe
     Radius         16px cards · 12px smaller · 8px inputs
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. SCOPED RESET
   -------------------------------------------------------------------------- */

[class*="v2-"],
[class^="v2-"] {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* --------------------------------------------------------------------------
   2. KEYFRAMES
   -------------------------------------------------------------------------- */

@keyframes v2FadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes v2SlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes v2Shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* --------------------------------------------------------------------------
   3. ANIMATION UTILITIES
   -------------------------------------------------------------------------- */

.v2-fade-in {
  animation: v2FadeIn 0.3s ease-out both;
}
.v2-slide-up {
  animation: v2SlideUp 0.4s ease-out both;
}

/* --------------------------------------------------------------------------
   4. KPI GRID
   -------------------------------------------------------------------------- */

.v2-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

/* ── Card ── */

.v2-kpi-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  border-left: 5px solid #fbbf24; /* overridden per-card via inline style */
  position: relative;
  overflow: hidden;
  transition:
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.25s ease;
}

.v2-kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

/* Decorative radial glow (top-right corner) */
.v2-kpi-card::after {
  content: "";
  position: absolute;
  top: -30px;
  right: -30px;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.1) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

/* ── Icon circle ── */

.v2-kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

/* Colour helpers (used when icon bg is set via class instead of inline) */
.v2-kpi-icon.green {
  background: #dcfce7;
  color: #16a34a;
}
.v2-kpi-icon.blue {
  background: #e0f2fe;
  color: #0284c7;
}
.v2-kpi-icon.amber {
  background: #fef3c7;
  color: #d97706;
}
.v2-kpi-icon.purple {
  background: #ede9fe;
  color: #7c3aed;
}

/* ── Value & labels ── */

.v2-kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
  margin-bottom: 4px;
}

.v2-kpi-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.v2-kpi-sub {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}

/* ── Period badge (e.g. "Today", "This Week") ── */

.v2-kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
  margin-top: 8px;
}

.v2-kpi-trend.up {
  background: #dcfce7;
  color: #166534;
}
.v2-kpi-trend.down {
  background: #fee2e2;
  color: #991b1b;
}
.v2-kpi-trend.neu {
  background: #f1f5f9;
  color: #475569;
}

/* --------------------------------------------------------------------------
   5. TREND + SIGNUPS GRID WRAPPER
   -------------------------------------------------------------------------- */

.v2-trend-signups-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

/* ── Shared card shell ── */

.v2-trend-section {
  background: #ffffff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

/* --------------------------------------------------------------------------
   6. REVENUE TREND CHART
   -------------------------------------------------------------------------- */

.v2-trend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.v2-trend-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  border: none;
  padding: 0;
}

/* Toggle pill group */

.v2-trend-toggle {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
}

.v2-trend-btn {
  padding: 5px 14px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #64748b;
  font-family: inherit;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.v2-trend-btn:hover {
  color: #0f172a;
}

.v2-trend-btn.active {
  background: #0f172a;
  color: #fbbf24;
}

/* Bars container — JS writes bars directly into #revenueTrendBars */

.v2-trend-bars {
  position: relative;
  min-height: 160px;
}

/* Individual bar — JS sets height% via inline style */

.v2-trend-bar {
  position: relative;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: default;
}

/* CSS tooltip driven by JS-written data-value attribute */

.v2-trend-bar::after {
  content: attr(data-value);
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%) scale(0.85);
  background: #0f172a;
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  z-index: 10;
}

.v2-trend-bar:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* Zero / low bar variant */
.v2-trend-bar.warn {
  background: linear-gradient(180deg, #f59e0b, #d97706) !important;
}

.v2-trend-bar-label {
  font-size: 10px;
  color: #94a3b8;
  font-weight: 600;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   7. RECENT SIGNUPS LIST
   -------------------------------------------------------------------------- */

.v2-signups-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.v2-signups-list::-webkit-scrollbar {
  width: 5px;
}
.v2-signups-list::-webkit-scrollbar-track {
  background: transparent;
}
.v2-signups-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.v2-signup-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.12s ease;
}

.v2-signup-item:last-child {
  border-bottom: none;
}

/* Avatar */

.v2-signup-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  /* Colour is set via inline style (green = new, slate = older) */
}

/* Info block */

.v2-signup-info {
  flex: 1;
  min-width: 0;
}

.v2-signup-name {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-signup-email {
  font-size: 12px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-signup-inst {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Time column */

.v2-signup-time {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  flex-shrink: 0;
}

.v2-signup-time.recent {
  color: #22c55e;
  font-weight: 700;
}

/* Paid / Free badge */

.v2-signup-paid-badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 700;
  white-space: nowrap;
  margin-top: 3px;
}

.v2-signup-paid-badge.paid {
  background: #dcfce7;
  color: #166534;
}
.v2-signup-paid-badge.free {
  background: #f1f5f9;
  color: #64748b;
}

/* --------------------------------------------------------------------------
   8. TWO-COLUMN LAYOUT HELPER
   -------------------------------------------------------------------------- */

.v2-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.v2-section-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --------------------------------------------------------------------------
   9. INSIGHT ROW (Institutions + Top Trainers)
   -------------------------------------------------------------------------- */

.insight-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* --------------------------------------------------------------------------
   10. EMPTY STATE
   -------------------------------------------------------------------------- */

.v2-empty {
  text-align: center;
  padding: 40px 20px;
  color: #94a3b8;
  font-size: 14px;
}

/* --------------------------------------------------------------------------
   11. LOADING SKELETON
   -------------------------------------------------------------------------- */

.v2-skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: v2Shimmer 1.5s infinite;
  border-radius: 8px;
}

/* --------------------------------------------------------------------------
   12. SCROLLBAR — all v2 overflow containers
   -------------------------------------------------------------------------- */

.v2-scroll-container {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.v2-scroll-container::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.v2-scroll-container::-webkit-scrollbar-track {
  background: transparent;
}
.v2-scroll-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

/* --------------------------------------------------------------------------
   13. RESPONSIVE
   -------------------------------------------------------------------------- */

/* Tablet landscape (≤ 1024px) */
@media (max-width: 1024px) {
  .v2-two-col {
    grid-template-columns: 1fr;
  }
  .v2-kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  .v2-trend-signups-grid {
    grid-template-columns: 1fr;
  }
  .insight-row {
    grid-template-columns: 1fr;
  }
}

/* Tablet portrait (≤ 900px) */
@media (max-width: 900px) {
  .v2-trend-signups-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .insight-row {
    grid-template-columns: 1fr;
  }
}

/* Tablet (≤ 768px) */
@media (max-width: 768px) {
  .v2-kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
  .v2-kpi-value {
    font-size: 1.4rem;
  }
  .v2-kpi-card {
    padding: 16px;
  }
  .v2-kpi-icon {
    width: 38px;
    height: 38px;
    font-size: 17px;
    margin-bottom: 8px;
  }

  .v2-trend-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .v2-signups-section,
  .v2-trend-section {
    padding: 16px;
  }
}

/* Mobile (≤ 600px) */
@media (max-width: 600px) {
  .v2-kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .v2-kpi-card {
    padding: 14px;
  }
  .v2-kpi-value {
    font-size: 1.3rem;
  }
  .v2-kpi-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
    margin-bottom: 8px;
  }
  .v2-trend-signups-grid {
    grid-template-columns: 1fr;
  }
  .insight-row {
    grid-template-columns: 1fr;
  }

  .v2-signup-avatar {
    width: 36px;
    height: 36px;
    font-size: 13px;
  }
  .v2-signup-item {
    gap: 10px;
    padding: 9px 0;
  }
  .v2-signup-paid-badge {
    display: none;
  } /* save space on tiny screens */

  /* Show only every 3rd bar label */
  .v2-trend-bar-wrap:nth-child(n) .v2-trend-bar-label {
    visibility: hidden;
  }
  .v2-trend-bar-wrap:nth-child(3n) .v2-trend-bar-label {
    visibility: visible;
  }
}
