/* ============================================
   IEX VALIDATION DASHBOARD
   Extends the CHAMOS AI Global design system
   ============================================ */

/* ---------- Hero ---------- */
.iex-hero {
  padding-bottom: 64px;
}

.iex-hero .iex-hero-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(0, 153, 204, 0.08);
  border: 1px solid rgba(0, 153, 204, 0.18);
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ---------- Section shell ---------- */
.iex-section {
  background: var(--off-white);
  padding-top: 48px;
}

/* ---------- Toolbar ---------- */
.iex-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.iex-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.iex-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 9px 24px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--gray-500);
  font-family: var(--font-primary);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1.15;
}

.iex-tab span {
  font-family: var(--font-body);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  opacity: 0.65;
}

.iex-tab:hover {
  background: var(--gray-50);
  color: var(--primary);
}

.iex-tab.active {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 6px 18px -6px rgba(10, 22, 40, 0.55);
}

.iex-tab.active span {
  opacity: 0.7;
}

.iex-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Demo switch */
.iex-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 15px 7px 8px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.iex-switch:hover {
  border-color: var(--gray-300);
}

.iex-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.iex-switch-track {
  position: relative;
  flex-shrink: 0;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--gray-300);
  transition: var(--transition);
}

.iex-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(10, 22, 40, 0.35);
  transition: var(--transition);
}

.iex-switch input:checked + .iex-switch-track {
  background: var(--accent);
}

.iex-switch input:checked + .iex-switch-track::after {
  transform: translateX(16px);
}

.iex-switch input:focus-visible + .iex-switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.iex-switch-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--gray-600);
}

/* Refresh */
.iex-icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-500);
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.iex-icon-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.iex-icon-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.iex-icon-btn .fa-rotate {
  transition: transform 0.6s linear;
}

.iex-icon-btn.spinning .fa-rotate {
  animation: iexSpin 0.9s linear infinite;
}

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

/* ---------- Status row ---------- */
.iex-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.iex-snapshot {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: 14px;
  box-shadow: 0 4px 18px -10px rgba(10, 22, 40, 0.35);
}

.iex-snapshot-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--white);
  font-size: 0.9rem;
  box-shadow: 0 6px 16px -6px rgba(0, 153, 204, 0.8);
}

.iex-snapshot-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.iex-snapshot-label {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.iex-snapshot-date {
  font-family: var(--font-primary);
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
}

.iex-snapshot-time {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--gray-500);
  padding-left: 12px;
  margin-left: 4px;
  border-left: 1px solid var(--gray-200);
}

.iex-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.iex-badge.demo {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.iex-badge.live {
  background: #ecfdf5;
  border-color: #bbf7d0;
  color: #047857;
}

.iex-badge.live .iex-dot {
  position: relative;
  display: inline-flex;
  width: 8px;
  height: 8px;
}

.iex-badge.live .iex-dot::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #22c55e;
  opacity: 0.75;
  animation: iexPing 1.6s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.iex-badge.live .iex-dot::after {
  content: "";
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16a34a;
}

@keyframes iexPing {
  75%, 100% { transform: scale(2.2); opacity: 0; }
}

.iex-notice {
  font-size: 0.78rem;
  color: var(--gray-500);
}

/* ---------- KPI cards ---------- */
.iex-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 36px;
}

.iex-kpi {
  position: relative;
  overflow: hidden;
  padding: 22px;
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: 18px;
  box-shadow: 0 2px 22px -12px rgba(10, 22, 40, 0.35);
  transition: var(--transition);
}

.iex-kpi::after {
  content: "";
  position: absolute;
  top: -46px;
  right: -46px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 153, 204, 0.1), transparent 68%);
  pointer-events: none;
}

.iex-kpi:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 40px -22px rgba(10, 22, 40, 0.45);
  border-color: var(--gray-200);
}

.iex-kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.iex-kpi-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--accent-light);
  color: var(--accent-dark);
  font-size: 1rem;
}

.iex-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.iex-trend.up {
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #d1fae5;
}

.iex-trend.down {
  color: #be123c;
  background: #fff1f2;
  border: 1px solid #ffe4e6;
}

.iex-trend.flat {
  color: var(--gray-500);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
}

.iex-kpi-label {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gray-400);
  margin-bottom: 5px;
}

.iex-kpi-value {
  font-family: var(--font-primary);
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--primary);
  letter-spacing: -0.01em;
}

.iex-kpi-sub {
  margin-top: 5px;
  font-size: 0.78rem;
  color: var(--gray-400);
}

/* ---------- Chart cards ---------- */
.iex-charts {
  display: grid;
  gap: 24px;
}

.iex-chart-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: 20px;
  box-shadow: 0 2px 22px -12px rgba(10, 22, 40, 0.35);
  overflow: hidden;
}

.iex-chart-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
  background: linear-gradient(180deg, var(--white), rgba(248, 250, 252, 0.65));
}

.iex-chart-head-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #eef2ff;
  color: #4f46e5;
  font-size: 0.85rem;
}

.iex-chart-title {
  font-family: var(--font-primary);
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.3;
}

.iex-chart-desc {
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--gray-400);
}

.iex-chart-body {
  position: relative;
  height: 380px;
  padding: 14px 16px 6px;
}

.iex-chart-body canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ---------- Divider ---------- */
.iex-divider {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0 0 26px;
}

.iex-divider::before,
.iex-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

.iex-divider span {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gray-400);
  white-space: nowrap;
}

.iex-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  margin: 0 auto 26px;
  padding: 9px 18px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  color: #475569;
  font-size: 0.78rem;
}

.iex-note i {
  color: #3b82f6;
}

.iex-note strong {
  color: var(--primary);
  font-weight: 700;
}

/* ---------- Skeleton ---------- */
.iex-skeleton {
  background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 37%, #eef2f7 63%);
  background-size: 400% 100%;
  animation: iexShimmer 1.4s ease infinite;
  border-radius: 18px;
}

.iex-skeleton.kpi {
  height: 142px;
}

.iex-skeleton.chart {
  height: 380px;
}

@keyframes iexShimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.iex-loading .iex-charts {
  display: none;
}

/* ---------- Empty state ---------- */
.iex-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 60px 24px;
  text-align: center;
  border: 2px dashed var(--gray-200);
  border-radius: 20px;
  background: rgba(248, 250, 252, 0.6);
  color: var(--gray-500);
}

.iex-empty i {
  font-size: 1.8rem;
  color: var(--gray-300);
  margin-bottom: 8px;
}

.iex-empty strong {
  font-family: var(--font-primary);
  font-size: 1.1rem;
  color: var(--primary);
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .iex-kpis {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .iex-hero {
    padding-bottom: 48px;
  }

  .iex-section {
    padding-top: 36px;
  }

  .iex-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .iex-tabs {
    width: 100%;
  }

  .iex-tab {
    flex: 1;
    align-items: center;
  }

  .iex-controls {
    justify-content: space-between;
  }

  .iex-chart-body {
    height: 320px;
  }

  .iex-snapshot {
    width: 100%;
  }

  .iex-snapshot-time {
    margin-left: auto;
  }
}

@media (max-width: 520px) {
  .iex-kpis {
    grid-template-columns: 1fr;
  }

  .iex-kpi-value {
    font-size: 1.6rem;
  }

  .iex-chart-body {
    height: 290px;
    padding: 10px 8px 4px;
  }

  .iex-note {
    text-align: center;
    font-size: 0.72rem;
  }
}
