/* =============================================================
   EXPLORADOR DE INOVACAO - KNOWLEDGE GRAPH VIEW
   Vis.js graph overlay, tooltips, detail panel, legend, controls
   ============================================================= */

/* ---- Graph container ---- */
.explorador-graph-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 180px);
    min-height: 400px;
    background: radial-gradient(ellipse at center, #1a1040 0%, var(--exp-bg-deep, #0f0c29) 70%);
    border-radius: var(--exp-radius, 14px);
    overflow: hidden;
    font-family: var(--exp-font, 'Sora', sans-serif);
}

.explorador-graph-container canvas {
    outline: none;
}

/* ---- Custom tooltip (nodes) ---- */
.graph-tooltip {
    display: none;
    position: fixed;
    z-index: 150;
    background: rgba(13, 13, 26, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 10px;
    padding: 12px 16px;
    max-width: 280px;
    pointer-events: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    font-family: var(--exp-font, 'Sora', sans-serif);
}
.graph-tooltip.show { display: block; }
.gt-name { font-size: 13px; font-weight: 600; color: #e0e0e0; margin-bottom: 4px; }
.gt-org { font-size: 11px; color: #9ca0b0; margin-bottom: 6px; }
.gt-score { font-size: 11px; display: flex; align-items: center; gap: 8px; }
.gt-score-bar {
    flex: 1; height: 4px; border-radius: 2px;
    background: rgba(255, 255, 255, 0.06); overflow: hidden;
}
.gt-score-fill { height: 100%; border-radius: 2px; }
.gt-score-val { font-weight: 600; font-size: 12px; }
.gt-type {
    font-size: 10px; margin-top: 6px; padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex; align-items: center; gap: 6px;
}
.gt-type-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ---- Edge tooltip ---- */
.edge-tooltip {
    display: none;
    position: fixed;
    z-index: 150;
    background: rgba(13, 13, 26, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 12px 16px;
    max-width: 300px;
    pointer-events: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    font-family: var(--exp-font, 'Sora', sans-serif);
}
.edge-tooltip.show { display: block; }
.et-label { font-size: 11px; color: #666; margin-bottom: 4px; }
.et-endpoints { font-size: 12px; color: #c8cbd3; }
.et-from, .et-to { font-weight: 500; }
.et-arrow { color: #555; margin: 0 2px; }
.et-score { margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.et-bar {
    flex: 1; height: 4px; border-radius: 2px;
    background: rgba(255, 255, 255, 0.06); overflow: hidden;
}
.et-fill { height: 100%; border-radius: 2px; }
.et-val { font-size: 12px; font-weight: 600; }
.et-reason {
    font-size: 11px; color: #9ca0b0; margin-top: 8px; padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06); font-style: italic;
}

/* ---- Floating detail panel (non-modal) ---- */
.graph-detail-panel {
    display: none;
    position: absolute;
    top: 12px; right: 12px;
    z-index: 120;
    width: 370px;
    max-height: calc(100% - 24px);
    overflow-y: auto;
    background: rgba(14, 14, 30, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-radius: 16px;
    padding: 22px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
    animation: graphSlideIn 0.25s ease-out;
    font-family: var(--exp-font, 'Sora', sans-serif);
}
.graph-detail-panel.show { display: block; }
@keyframes graphSlideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
.gdp-close {
    position: absolute; top: 10px; right: 12px;
    background: none; border: none; color: #555; font-size: 16px; cursor: pointer;
    width: 28px; height: 28px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.gdp-close:hover { background: rgba(255, 255, 255, 0.06); color: #e0e0e0; }
.gdp-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.gdp-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    border: 2px solid #7c3aed;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; color: #c4b5fd;
    background: #2a2a4a; flex-shrink: 0;
    overflow: hidden;
}
.gdp-avatar img { width: 100%; height: 100%; object-fit: cover; }
.gdp-title { font-size: 14px; font-weight: 600; color: #e0e0e0; }
.gdp-org { font-size: 12px; color: #9ca0b0; margin-top: 2px; }
.gdp-badges { display: flex; gap: 5px; margin-bottom: 12px; flex-wrap: wrap; }
.gdp-badge {
    font-size: 10px; padding: 2px 8px; border-radius: 10px;
    border: 1px solid; font-weight: 500;
}
.gdp-desc {
    font-size: 12px; color: #9ca0b0; line-height: 1.6;
    border-top: 1px solid rgba(255, 255, 255, 0.06); padding-top: 10px;
}
.gdp-score { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.gdp-score-label { font-size: 11px; color: #555; }
.gdp-score-bar {
    flex: 1; height: 5px; border-radius: 3px;
    background: rgba(255, 255, 255, 0.06); overflow: hidden;
}
.gdp-score-fill { height: 100%; border-radius: 3px; transition: width 0.4s; }
.gdp-score-val { font-size: 12px; font-weight: 600; min-width: 36px; text-align: right; }
.gdp-connections {
    margin-top: 12px; padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.gdp-connections h4 {
    font-size: 10px; color: #7c3aed; text-transform: uppercase;
    letter-spacing: 1px; margin-bottom: 8px; font-weight: 600;
}
.gdp-conn-item {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 0; font-size: 11px; color: #9ca0b0;
}
.gdp-conn-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.gdp-conn-clickable {
    cursor: pointer; border-radius: 6px; padding: 5px 8px; margin: 0 -8px;
    transition: background 0.15s;
}
.gdp-conn-clickable:hover { background: rgba(124,58,237,0.12); }

/* Force single-column layout for detail content inside graph panels */
.graph-detail-panel .detail-two-col,
.graph-detail-panel-2 .detail-two-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.graph-detail-panel .detail-meta-card,
.graph-detail-panel-2 .detail-meta-card {
    max-width: 100%;
}

/* Secondary detail panel - positioned to the left of primary */
.graph-detail-panel-2 {
    right: 395px;
}

/* scrollbar */
.graph-detail-panel::-webkit-scrollbar { width: 4px; }
.graph-detail-panel::-webkit-scrollbar-track { background: transparent; }
.graph-detail-panel::-webkit-scrollbar-thumb { background: rgba(124, 58, 237, 0.3); border-radius: 2px; }

/* ---- Legend ---- */
.graph-legend {
    position: absolute;
    bottom: 14px; left: 14px;
    z-index: 110;
    background: rgba(10, 10, 30, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 16px;
    min-width: 180px;
    font-family: var(--exp-font, 'Sora', sans-serif);
}
.graph-legend h3 {
    font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px;
    color: #7c3aed; margin-bottom: 8px; font-weight: 600;
}
.gl-item {
    display: flex; align-items: center; gap: 8px;
    padding: 3px 0; font-size: 11px; color: #9ca0b0;
    cursor: pointer; transition: opacity 0.2s;
}
.gl-item:hover { opacity: 0.7; }
.gl-item.disabled { opacity: 0.3; text-decoration: line-through; }
.gl-dot {
    width: 10px; height: 10px; border-radius: 50%;
    border: 2px solid; flex-shrink: 0;
}
.gl-diamond {
    width: 8px; height: 8px; flex-shrink: 0;
    transform: rotate(45deg); border: 2px solid;
}
.gl-star { font-size: 12px; flex-shrink: 0; width: 10px; text-align: center; }
.gl-count {
    margin-left: auto; font-size: 10px;
    background: rgba(255, 255, 255, 0.06); border-radius: 8px;
    padding: 1px 6px; color: #555;
}
/* Legend toggle button (mobile only) */
.gl-toggle-btn {
    display: none;
    align-items: center; justify-content: center;
    width: 38px; height: 38px;
    border-radius: 10px; border: 1px solid rgba(124,58,237,0.3);
    background: rgba(10, 10, 30, 0.92);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    color: #a78bfa; font-size: 16px;
    cursor: pointer; transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.gl-toggle-btn:hover { background: rgba(124,58,237,0.2); }

/* ---- Stats ---- */
.graph-stats {
    position: absolute;
    top: 14px; left: 14px;
    z-index: 110;
    background: rgba(10, 10, 30, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 6px 12px;
    font-size: 11px; color: #555;
    font-family: var(--exp-font, 'Sora', sans-serif);
}
.graph-stats span { color: #a78bfa; font-weight: 600; }

/* ---- Controls ---- */
.graph-controls {
    position: absolute;
    top: 46px; left: 14px;
    z-index: 120;
    display: flex; flex-direction: column; gap: 5px;
}
.gc-btn {
    width: 34px; height: 34px; border-radius: 9px;
    background: rgba(10, 10, 30, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #9ca0b0; font-size: 13px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.gc-btn:hover { background: rgba(124, 58, 237, 0.2); color: #c4b5fd; border-color: rgba(124, 58, 237, 0.3); }
.gc-btn.active { background: rgba(124, 58, 237, 0.3); color: #7c3aed; border-color: #7c3aed; }

/* ---- Display options panel ---- */
.graph-display-panel {
    position: absolute;
    top: 46px; left: 54px;
    z-index: 115;
    background: rgba(10, 10, 30, 0.95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 12px;
    font-family: var(--exp-font, 'Sora', sans-serif);
    width: 260px;
    max-height: calc(100% - 28px);
    overflow-y: auto;
    display: none;
}
.graph-display-panel.show { display: block; }
.graph-display-panel::-webkit-scrollbar { width: 3px; }
.graph-display-panel::-webkit-scrollbar-thumb { background: rgba(124,58,237,0.3); border-radius: 2px; }

.gd-body { padding: 0 14px 14px; }

.gd-section { margin-bottom: 12px; }
.gd-section-title {
    font-size: 10px; color: #555; text-transform: uppercase;
    letter-spacing: 1px; margin-bottom: 6px; font-weight: 500;
}

.gd-radio-group { display: flex; flex-direction: column; gap: 4px; }
.gd-radio {
    display: flex; flex-direction: column; gap: 2px;
    padding: 7px 10px; border-radius: 8px;
    font-size: 11px; color: #9ca0b0; cursor: pointer;
    border: 1px solid rgba(255,255,255,0.06);
    transition: all 0.15s;
}
.gd-radio input { display: none; }
.gd-radio .gd-radio-main { display: flex; align-items: center; gap: 8px; }
.gd-radio i { font-size: 11px; width: 14px; text-align: center; }
.gd-radio:hover { background: rgba(255,255,255,0.04); }
.gd-radio.active {
    background: rgba(124,58,237,0.12);
    border-color: rgba(124,58,237,0.3);
    color: #c4b5fd;
}
.gd-radio-desc {
    font-size: 9px; color: #555; padding-left: 22px;
}

.gd-check-group { display: flex; flex-direction: column; gap: 3px; }
.gd-check {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 10px; border-radius: 6px;
    font-size: 11px; color: #9ca0b0; cursor: pointer;
    transition: all 0.15s;
}
.gd-check:hover { background: rgba(255,255,255,0.04); }
.gd-check input[type="checkbox"] {
    width: 14px; height: 14px; accent-color: #7c3aed;
    cursor: pointer; flex-shrink: 0;
}
.gd-check i { font-size: 10px; width: 14px; text-align: center; color: #666; }

.gd-slider-row {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 0;
}
.gd-slider-val {
    font-size: 11px; color: #a78bfa; font-weight: 600;
    min-width: 32px; text-align: right;
}

/* ---- Physics tuner panel ---- */
.graph-tuner {
    position: absolute;
    top: 46px; left: 54px;
    z-index: 115;
    background: rgba(10, 10, 30, 0.95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 12px;
    font-family: var(--exp-font, 'Sora', sans-serif);
    overflow: hidden;
    width: 320px;
    display: none;
}
.graph-tuner.show { display: block; }
.gt-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 16px;
    padding: 4px 14px 12px;
}
.gt-row {
    display: flex; flex-direction: column; gap: 2px;
}
.gt-label {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 10px; color: #777;
}
.gt-label span:last-child {
    color: #a78bfa; font-weight: 600; font-size: 10px;
    min-width: 40px; text-align: right;
}
.gt-slider {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 4px;
    background: rgba(255,255,255,0.08);
    border-radius: 2px; outline: none;
    cursor: pointer;
}
.gt-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 12px; height: 12px;
    background: #7c3aed; border-radius: 50%;
    cursor: pointer;
    border: 2px solid #c4b5fd;
}
.gt-slider::-moz-range-thumb {
    width: 12px; height: 12px;
    background: #7c3aed; border-radius: 50%;
    cursor: pointer; border: 2px solid #c4b5fd;
}
.gt-preset-row {
    grid-column: 1 / -1;
    display: flex; gap: 6px; padding-top: 4px;
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: 2px;
}
.gt-preset {
    flex: 1; padding: 4px 0;
    font-size: 10px; text-align: center;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px; color: #888;
    cursor: pointer; transition: all 0.15s;
}
.gt-preset:hover { background: rgba(124,58,237,0.15); color: #c4b5fd; border-color: rgba(124,58,237,0.3); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .explorador-graph-container { height: calc(100vh - 140px); min-height: 300px; }

    /* Both detail panels: fixed full-width bottom sheet (fixed escapes overflow:hidden) */
    .graph-detail-panel,
    .graph-detail-panel-2 {
        position: fixed;
        top: auto; bottom: 0; left: 0; right: 0;
        width: 100%; max-height: 60vh;
        border-radius: 16px 16px 0 0;
        animation: graphSlideUp 0.25s ease-out;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        overscroll-behavior: contain;
        z-index: 200;
        box-sizing: border-box;
        padding: 16px;
    }
    /* All content inside must respect panel width */
    .graph-detail-panel *,
    .graph-detail-panel-2 * {
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    .graph-detail-panel .gdp-title,
    .graph-detail-panel-2 .gdp-title {
        font-size: 13px;
        line-height: 1.4;
    }
    /* Close button: visible and tappable on mobile */
    .graph-detail-panel .gdp-close,
    .graph-detail-panel-2 .gdp-close {
        position: absolute;
        top: 8px; right: 12px;
        z-index: 10;
        width: 36px; height: 36px;
        font-size: 22px;
        color: #aaa;
        background: rgba(30, 30, 50, 0.8);
        border-radius: 50%;
    }
    @keyframes graphSlideUp {
        from { opacity: 0; transform: translateY(20px); }
        to { opacity: 1; transform: translateY(0); }
    }
    /* Legend: collapsed by default on mobile, toggle via button */
    .graph-legend {
        bottom: 8px; left: 8px; padding: 0; min-width: auto;
        background: none; border: none; backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .graph-legend h3,
    .graph-legend .gl-item { display: none; }
    .graph-legend.legend-open {
        padding: 8px 12px; min-width: 150px;
        background: rgba(10, 10, 30, 0.9);
        border: 1px solid rgba(255, 255, 255, 0.08);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        bottom: 48px; /* above CTA banner */
    }
    .graph-legend.legend-open h3,
    .graph-legend.legend-open .gl-item { display: flex; }
    .graph-legend.legend-open h3 { display: block; }
    .gl-toggle-btn { display: flex !important; }

    .graph-stats { top: 8px; left: 8px; }
    .graph-controls { top: 8px; right: 8px; }
}
