/* InsightPulse — Chart Generator (explorer) styles
 * Inherits the theme vars injected by the plugin (same as the dashboard).
 * Fully responsive: the sidebar drops under the charts on narrow screens.
 * ---------------------------------------------------------------- */
.ip-explorer {
    font-family: inherit;
    color: var(--ip-ink, #e7efe9);
    background: var(--ip-bg, #070d0b);
    padding: 22px;
    border-radius: 14px;
    box-sizing: border-box;
}
.ip-explorer * { box-sizing: border-box; }

/* Header */
.ip-exp-head { text-align: center; margin-bottom: 18px; }
.ip-exp-title { margin: 0; font-size: 26px; font-weight: 800; color: var(--ip-accent, #39d3a8); }
.ip-exp-subtitle { margin: 6px 0 0; font-size: 14px; letter-spacing: .04em; color: var(--ip-muted, #7e948b); }

/* Parent category tabs (cards) */
.ip-exp-cats { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 18px; }
.ip-exp-cat {
    display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    padding: 14px 28px; min-width: 140px;
    background: var(--ip-card, #0c1512);
    border: 1px solid var(--ip-line, #1c2b25);
    border-radius: 14px;
    color: var(--ip-muted, #7e948b);
    font-size: 15px; font-weight: 700; cursor: pointer;
    transition: border-color .15s, color .15s, transform .12s;
}
.ip-exp-cat-icon { width: 60px; height: 60px; object-fit: contain; display: block; }
.ip-exp-cat:hover { transform: translateY(-1px); color: var(--ip-ink, #e7efe9); }
.ip-exp-cat.active {
    color: var(--ip-ink, #e7efe9);
    border-color: var(--ip-tab-color, var(--ip-accent, #39d3a8));
    box-shadow: 0 0 0 1px var(--ip-tab-color, var(--ip-accent, #39d3a8)) inset;
}

/* Sub-category dropdown */
.ip-exp-subbar { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 22px; flex-wrap: wrap; }
.ip-exp-sub-label { font-size: 13px; color: var(--ip-muted, #7e948b); font-weight: 600; }
.ip-exp-sub-select {
    min-width: 240px; max-width: 100%;
    padding: 11px 14px;
    background: var(--ip-card, #0c1512);
    border: 1px solid var(--ip-line, #1c2b25);
    border-radius: 10px;
    color: var(--ip-ink, #e7efe9);
    font-size: 14px; font-weight: 600; cursor: pointer;
}
.ip-exp-sub-select:focus { outline: none; border-color: var(--ip-accent, #39d3a8); }
.ip-exp-sub-select option { color: #111; background: #fff; }

/* Body: charts (main) + Chart Generator (sidebar) */
.ip-exp-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.ip-exp-main { min-width: 0; display: flex; flex-direction: column; gap: 22px; }

.ip-exp-card {
    background: var(--ip-card, #0c1512);
    border: 1px solid var(--ip-line, #1c2b25);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.ip-exp-group-title { margin: 0 0 16px; font-size: 18px; font-weight: 700; color: var(--ip-ink, #e7efe9); }
.ip-exp-card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.ip-exp-card-title-row .ip-exp-group-title { margin: 0; }
.ip-exp-explain-btn {
    flex-shrink: 0;
    padding: 8px 12px;
    background: var(--ip-bg, #070d0b);
    border: 1px solid color-mix(in srgb, var(--ip-accent, #39d3a8) 55%, transparent);
    border-radius: 10px;
    color: var(--ip-ink, #e7efe9);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.ip-exp-explain-btn:hover { border-color: var(--ip-accent, #39d3a8); }
.ip-exp-chart-box { position: relative; height: 320px; min-width: 0; }
.ip-exp-chart-box canvas { display: block; }
.ip-exp-chart-empty {
    position: absolute; inset: 0;
    display: none; align-items: center; justify-content: center;
    padding: 24px; text-align: center;
    color: var(--ip-muted, #7e948b); font-size: 14px; font-weight: 600;
}
.ip-exp-chart-box.is-empty canvas { visibility: hidden; }
.ip-exp-chart-box.is-empty .ip-exp-chart-empty { display: flex; }

/* Sidebar — accordion of metric checkboxes + downloads (sticky on desktop).
   A flex column so the title and download buttons stay put while only the
   accordion list (.ip-exp-acc-scroll) scrolls when it's taller than the
   sidebar — otherwise a long category list pushes the download buttons
   below the fold with no way to reach them except scrolling past everything. */
.ip-exp-side {
    position: sticky; top: 16px;
    display: flex; flex-direction: column;
    background: var(--ip-card, #0c1512);
    border: 1px solid var(--ip-line, #1c2b25);
    border-radius: 16px;
    padding: 18px;
    max-height: calc(100vh - 32px);
}
.ip-exp-side-title { flex-shrink: 0; font-size: 17px; font-weight: 700; margin-bottom: 12px; color: var(--ip-ink, #e7efe9); }
.ip-exp-acc-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

.ip-exp-acc { border-top: 1px solid var(--ip-line, #1c2b25); }
.ip-exp-acc-hdr { display: flex; align-items: center; gap: 9px; width: 100%; padding: 11px 2px; }
.ip-exp-acc-check { accent-color: var(--ip-accent, #39d3a8); width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; }
.ip-exp-acc-toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    flex: 1; min-width: 0; padding: 0;
    background: none; border: none; cursor: pointer;
    color: var(--ip-ink, #e7efe9); font-size: 13.5px; font-weight: 700; text-align: left;
}
.ip-exp-caret { transition: transform .2s; color: var(--ip-muted, #7e948b); }
.ip-exp-acc.open .ip-exp-caret { transform: rotate(180deg); color: var(--ip-accent, #39d3a8); }
.ip-exp-acc-list { display: none; padding: 2px 0 10px; }
.ip-exp-acc.open .ip-exp-acc-list { display: block; }

.ip-exp-metric {
    display: flex; align-items: center; gap: 9px;
    padding: 6px 4px; font-size: 13px; color: var(--ip-ink, #e7efe9);
    cursor: pointer; border-radius: 6px;
}
.ip-exp-metric:hover { background: rgba(255, 255, 255, 0.04); }
.ip-exp-metric input { accent-color: var(--ip-accent, #39d3a8); width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; }
.ip-exp-acc-check,
.ip-exp-metric input {
    appearance: none !important;
    -webkit-appearance: none !important;
    margin: 0;
    border: 1px solid color-mix(in srgb, var(--ip-muted, #7e948b) 75%, transparent);
    border-radius: 3px;
    background-color: #fff;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: none;
}
.ip-exp-acc-check:checked,
.ip-exp-metric input:checked {
    border-color: var(--ip-accent, #39d3a8);
    background-color: var(--ip-accent, #39d3a8);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2300120c' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.2' d='m3.5 8.2 2.7 2.7 6.3-6.3'/%3E%3C/svg%3E");
}
.ip-exp-acc-check:indeterminate {
    border-color: var(--ip-accent, #39d3a8);
    background-color: var(--ip-accent, #39d3a8);
    background-image: linear-gradient(#00120c, #00120c);
    background-size: 8px 2px;
}
.ip-exp-acc-check:disabled,
.ip-exp-metric input:disabled { opacity: .38; cursor: not-allowed; }
.ip-exp-metric.unavailable { color: var(--ip-muted, #7e948b); cursor: not-allowed; }
.ip-exp-sw { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; display: inline-block; }
.ip-exp-sw.line { width: 18px; height: 3px; border-radius: 2px; }

/* Multi-colour charts have no single colour, so their swatch shows a small
   gradient of the first few category colours. */
.ip-exp-sw { background-size: cover; }

/* Download buttons */
.ip-exp-actions { flex-shrink: 0; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--ip-line, #1c2b25); display: flex; flex-direction: column; gap: 10px; }
.ip-exp-dl { width: 100%; padding: 13px; border: none; border-radius: 12px; font-weight: 700; font-size: 14px; cursor: pointer; transition: transform .12s, box-shadow .2s; }
.ip-exp-dl:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35); }
.ip-exp-dl-pdf {
    color: #00120c;
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--ip-accent, #39d3a8) 88%, #fff 12%),
        color-mix(in srgb, var(--ip-accent, #39d3a8) 78%, #000 22%));
}
.ip-exp-dl-xls { background: var(--ip-bg, #070d0b); border: 1px solid color-mix(in srgb, var(--ip-accent, #39d3a8) 55%, transparent); color: var(--ip-ink, #e7efe9); }

/* Data table */
.ip-exp-table-wrap {
    width: 100%; overflow-x: auto;
    margin-top: 20px; padding-top: 16px;
    border-top: 1px solid var(--ip-line, #1c2b25);
}
.ip-exp-table-title {
    margin-bottom: 8px;
    color: var(--ip-muted, #7e948b);
    font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
}
.ip-exp-table-empty { margin: 0; padding: 12px 0 2px; color: var(--ip-muted, #7e948b); font-size: 13px; }
.ip-exp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ip-exp-table th, .ip-exp-table td { padding: 10px 12px; border-top: 1px solid var(--ip-line, #1c2b25); white-space: nowrap; }
.ip-exp-table thead th { border-top: none; color: var(--ip-muted, #7e948b); font-weight: 700; text-align: right; }
.ip-exp-table thead th.ip-exp-th-corner { text-align: left; }
.ip-exp-table tbody th.ip-exp-row-label { text-align: left; font-weight: 400; color: var(--ip-ink, #e7efe9); }
.ip-exp-table tbody td { text-align: right; color: var(--ip-muted, #7e948b); font-variant-numeric: tabular-nums; }
.ip-exp-sr-only {
    position: absolute !important; width: 1px !important; height: 1px !important;
    padding: 0 !important; margin: -1px !important; overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important;
}

.ip-exp-empty {
    background: var(--ip-card, #0c1512);
    border: 1px dashed var(--ip-line, #1c2b25);
    border-radius: 16px; padding: 48px 24px; text-align: center;
    color: var(--ip-ink, #e7efe9);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
    .ip-exp-body { grid-template-columns: 1fr; }
    .ip-exp-side { position: static; max-height: none; order: 2; }
}
@media (max-width: 768px) {
    .ip-explorer { padding: 14px; }
    .ip-exp-title { font-size: 22px; }
    .ip-exp-cat { padding: 12px 18px; min-width: 120px; font-size: 14px; }
    .ip-exp-chart-box { height: 260px; }
    .ip-exp-sub-select { min-width: 100%; }
    .ip-exp-subbar { flex-direction: column; align-items: stretch; }
}
@media (max-width: 420px) {
    .ip-explorer { padding: 10px; }
    .ip-exp-card { padding: 14px; }
    .ip-exp-cats { gap: 8px; }
    .ip-exp-cat { flex: 1 1 auto; min-width: 0; }
}

/* Explorer explainer popup */
.ip-exp-explain-modal {
    position: fixed;
    inset: 0;
    z-index: 99998;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.58);
}
.ip-exp-explain-modal.open { display: flex; }
.ip-exp-explain-panel {
    position: relative;
    width: min(680px, 100%);
    max-height: min(760px, calc(100vh - 40px));
    overflow: auto;
    background: var(--ip-card, #0c1512);
    border: 1px solid var(--ip-line, #1c2b25);
    border-radius: 16px;
    padding: 24px;
    color: var(--ip-ink, #e7efe9);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
.ip-exp-explain-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    border: 1px solid var(--ip-line, #1c2b25);
    border-radius: 8px;
    background: var(--ip-bg, #070d0b);
    color: var(--ip-muted, #7e948b);
    cursor: pointer;
    font-weight: 700;
}
.ip-exp-explain-title { margin: 0 36px 12px 0; font-size: 20px; color: var(--ip-ink, #e7efe9); }
.ip-exp-explain-text { margin: 0 0 18px; color: var(--ip-muted, #7e948b); line-height: 1.6; }

/* Media icon-tabs (audio / video toggles) */
.ip-exp-media-tabs { display: flex; gap: 26px; margin: 0 0 14px; }
.ip-exp-media-tab {
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    background: none; border: none; padding: 0; cursor: pointer;
    color: var(--ip-muted, #7e948b);
}
.ip-exp-media-ico {
    width: 52px; height: 52px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--ip-card, #0c1512);
    border: 1.5px solid color-mix(in srgb, var(--ip-accent, #39d3a8) 50%, transparent);
    color: var(--ip-muted, #7e948b);
    transition: color .18s, border-color .18s;
}
.ip-exp-media-tab:hover .ip-exp-media-ico { border-color: var(--ip-accent, #39d3a8); color: var(--ip-ink, #e7efe9); }
.ip-exp-media-tab.active .ip-exp-media-ico { border-color: var(--ip-accent, #39d3a8); color: var(--ip-accent, #39d3a8); }
.ip-exp-media-lbl { font-size: 12px; color: var(--ip-ink, #e7efe9); }

/* Media stage — only the active pane is shown */
.ip-exp-media-pane { display: none; }
.ip-exp-media-pane.active { display: block; }

/* Themed audio mini-player (no native browser chrome) */
.ip-exp-audio {
    display: flex; align-items: center; gap: 12px;
    background: var(--ip-card, #0c1512);
    border: 1px solid var(--ip-line, #1c2b25);
    border-radius: 999px;
    padding: 8px 16px 8px 8px;
}
.ip-exp-audio-btn {
    flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
    background: var(--ip-accent, #39d3a8); border: none; color: #04342c;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.ip-exp-audio-eq { display: flex; align-items: flex-end; gap: 3px; height: 18px; flex-shrink: 0; }
.ip-exp-audio-eq i {
    width: 3px; height: 5px; border-radius: 1px;
    background: var(--ip-accent, #39d3a8); opacity: .55;
}
.ip-exp-audio.playing .ip-exp-audio-eq i { animation: ip-exp-eq .9s ease-in-out infinite; opacity: 1; }
.ip-exp-audio.playing .ip-exp-audio-eq i:nth-child(2) { animation-delay: .2s; }
.ip-exp-audio.playing .ip-exp-audio-eq i:nth-child(3) { animation-delay: .4s; }
.ip-exp-audio.playing .ip-exp-audio-eq i:nth-child(4) { animation-delay: .15s; }
@keyframes ip-exp-eq { 0%, 100% { height: 5px; } 50% { height: 16px; } }
.ip-exp-audio-seek { flex: 1; min-width: 60px; accent-color: var(--ip-accent, #39d3a8); cursor: pointer; height: 4px; }
.ip-exp-audio-time { font-size: 12px; color: var(--ip-muted, #7e948b); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.ip-exp-audio-vol { color: var(--ip-muted, #7e948b); flex-shrink: 0; display: flex; }

/* Avatar pane — empty by design. The third-party AR embed (uarembed.php)
   binds its launch handler to #showVideoPlayerButton, which lives directly
   on the Avatar icon tab; the AR experience renders in its own full-screen
   overlay so the stage pane stays blank. */
.ip-exp-avatar-marker { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Close button (icon) */
.ip-exp-explain-close { display: flex; align-items: center; justify-content: center; }
