/* ═══════════════════════════════════════════════════════════════════
   Table to Bar Chart — Premium Frontend Styles v2.0
   ═══════════════════════════════════════════════════════════════════ */

/* ── Wrapper / entrance animation ─────────────────────────────────── */
.ttbc-wrapper {
  margin: 2.5em 0;
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.ttbc-wrapper.ttbc-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Premium card ──────────────────────────────────────────────────── */
.ttbc-card {
  position: relative;
  background: linear-gradient(145deg, #0f0f1a 0%, #141428 60%, #0d0d1f 100%);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 20px;
  padding: 28px 28px 22px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04),
    0 8px 32px rgba(0,0,0,0.45),
    0 32px 80px rgba(0,0,0,0.3);
  overflow: hidden;
}

/* subtle grain overlay */
.ttbc-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
}

/* top glow accent */
.ttbc-card::after {
  content: "";
  position: absolute;
  top: -60px; left: 50%;
  transform: translateX(-50%);
  width: 70%; height: 120px;
  background: radial-gradient(ellipse, rgba(123,97,255,0.18) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.ttbc-card > * { position: relative; z-index: 1; }

/* ── Card header ───────────────────────────────────────────────────── */
.ttbc-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}

/* ── Stat pills ────────────────────────────────────────────────────── */
.ttbc-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ttbc-stat {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 7px 13px;
  backdrop-filter: blur(6px);
  transition: background 0.2s, border-color 0.2s;
}
.ttbc-stat:hover {
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.14);
}

.ttbc-stat__icon {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  color: rgba(255,255,255,0.4);
  line-height: 1;
}

.ttbc-stat__val {
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  line-height: 1;
}

.ttbc-stat__label {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.38);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1;
}

/* ── Controls row ──────────────────────────────────────────────────── */
.ttbc-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Type switcher */
.ttbc-type-switcher {
  display: flex;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.ttbc-type-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  color: rgba(255,255,255,0.35);
  transition: background 0.18s, color 0.18s;
  padding: 0;
}
.ttbc-type-btn svg {
  width: 16px; height: 16px;
  display: block;
}
.ttbc-type-btn:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.75);
}
.ttbc-type-btn.active {
  background: rgba(123,97,255,0.3);
  color: #a78bfa;
  box-shadow: 0 0 12px rgba(123,97,255,0.25);
}

/* Export button */
.ttbc-export-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  cursor: pointer;
  color: rgba(255,255,255,0.4);
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  padding: 0;
  flex-shrink: 0;
}
.ttbc-export-btn svg { width: 17px; height: 17px; display: block; }
.ttbc-export-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.16);
  color: rgba(255,255,255,0.85);
}

/* ── Canvas area ───────────────────────────────────────────────────── */
.ttbc-canvas-wrap {
  position: relative;
  width: 100%;
  height: 420px;   /* overridden inline by PHP config */
}

/* ── Source table toggle ───────────────────────────────────────────── */
.ttbc-source {
  margin-top: 12px;
}
.ttbc-source summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  color: rgba(255,255,255,0.28);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  list-style: none;
  transition: color 0.18s;
}
.ttbc-source summary::-webkit-details-marker { display: none; }
.ttbc-source summary::before {
  content: "›";
  display: inline-block;
  transition: transform 0.2s;
  font-size: 15px;
  line-height: 1;
}
.ttbc-source[open] summary::before { transform: rotate(90deg); }
.ttbc-source summary:hover { color: rgba(255,255,255,0.55); }

.ttbc-original-table {
  margin-top: 14px;
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.07);
}
.ttbc-original-table table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
}
.ttbc-original-table th,
.ttbc-original-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
  text-align: left;
}
.ttbc-original-table thead th {
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.9);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ttbc-original-table tbody tr:hover td {
  background: rgba(255,255,255,0.03);
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .ttbc-card { padding: 18px 16px 16px; }
  .ttbc-card__header { flex-direction: column; gap: 12px; }
  .ttbc-controls { width: 100%; justify-content: flex-end; }
  .ttbc-stats-row { gap: 7px; }
  .ttbc-stat { padding: 6px 10px; }
  .ttbc-stat__val { font-size: 13px; }
}

/* ── Light-mode override (if theme uses light background) ─────────── */
@media (prefers-color-scheme: light) {
  /* The dark card is intentional and looks great on both — no override needed */
}
