/* 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: 30px; height: 30px; 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; }

/* Sidebar — accordion of metric checkboxes + downloads (sticky on desktop) */
.ip-exp-side {
    position: sticky; top: 16px;
    background: var(--ip-card, #0c1512);
    border: 1px solid var(--ip-line, #1c2b25);
    border-radius: 16px;
    padding: 18px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}
.ip-exp-side-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; color: var(--ip-ink, #e7efe9); }

.ip-exp-acc { border-top: 1px solid var(--ip-line, #1c2b25); }
.ip-exp-acc-hdr {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    width: 100%; padding: 11px 2px;
    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-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; }

/* Download buttons */
.ip-exp-actions { 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: 16px; }
.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-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 16px; color: var(--ip-muted, #7e948b); line-height: 1.6; }
.ip-exp-explain-audio audio { width: 100%; margin-bottom: 16px; }
.ip-exp-explain-video iframe,
.ip-exp-explain-video video {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 12px;
    background: #000;
}
.ip-exp-explain-video a {
    display: inline-block;
    color: var(--ip-accent, #39d3a8);
    font-weight: 700;
    text-decoration: none;
}
