/* Graph Page Styles */

.graph-controls {
    position: relative;
    display: flex;
    gap: 12px 16px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    padding-right: 40px;
}

.graph-controls > .btn-icon:last-child {
    position: absolute;
    top: -20px;
    right: -20px;
}

.graph-control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.graph-control-group label {
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.graph-control-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.graph-vanity-search,
.graph-company-search {
    flex: 1 1 300px;
    min-width: 0;
}

.graph-vanity-search .autocomplete-wrapper,
.graph-company-search .autocomplete-wrapper {
    flex: 1;
    min-width: 0;
    max-width: none;
}

.graph-control-group .score-input {
    max-width: none;
}

#graphContainer {
    width: 100%;
    height: 500px;
    border: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
    background: var(--bg-white);
    position: relative;
}

.graph-resize-handle {
    width: 100%;
    height: 10px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
}

.graph-resize-handle::after {
    content: '';
    width: 40px;
    height: 3px;
    border-radius: 2px;
    background: var(--border-color);
}

.graph-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--bg-light);
    border-radius: 8px;
    flex-wrap: wrap;
}

.graph-stat-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.graph-stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.graph-stat-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Details Panel */
.graph-details-panel {
    position: fixed;
    right: 20px;
    top: 100px;
    width: 350px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.graph-details-panel.hidden {
    display: none;
}

.graph-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.graph-details-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.graph-detail-section {
    margin-bottom: 16px;
}

.graph-section-header {
    margin: 0 0 4px 0;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.graph-detail-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--bg-light);
}

.graph-detail-item:last-child {
    border-bottom: none;
}

/* Engagement stats */
.graph-engagement-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding: 2px 0;
}

.graph-stat-detail {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* AI response key-value rows */
.ai-response-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.ai-response-value {
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* Positions section - scrollable past positions */
.graph-positions-section .graph-section-header:not(:first-child) {
    margin-top: 8px;
}

.graph-position-item {
    padding: 4px 0;
    font-size: 0.82rem;
    line-height: 1.3;
    border-bottom: 1px solid var(--bg-light);
}

.graph-position-item:last-child {
    border-bottom: none;
}

.graph-position-item strong {
    font-size: 0.82rem;
    font-weight: 600;
}

.graph-position-item span {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.graph-positions-scroll-wrapper {
    position: relative;
}

.graph-positions-scroll-wrapper.has-overflow::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 28px;
    background: linear-gradient(transparent, var(--bg-white));
    pointer-events: none;
    transition: opacity 0.2s;
}

.graph-positions-scroll-wrapper.scrolled-end::after {
    opacity: 0;
}

.graph-positions-scroll {
    max-height: 150px;
    overflow-y: auto;
}

.graph-connection-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.graph-connection-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary);
}

.graph-connection-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.graph-connection-name {
    font-size: 1.1rem;
    font-weight: 600;
}

.graph-connection-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Paths Panel */
.graph-paths-panel {
    position: fixed;
    left: 280px;
    bottom: 20px;
    width: calc(100% - 320px);
    max-width: 800px;
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.graph-paths-panel.hidden {
    display: none;
}

.graph-paths-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.graph-paths-header h3 {
    margin: 0;
}

.graph-paths-summary {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-light);
    border-radius: 6px;
    flex-wrap: wrap;
}

.graph-paths-group {
    margin-bottom: 16px;
}

.graph-paths-group h4 {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.graph-path-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-light);
    border-radius: 6px;
    margin-bottom: 6px;
}

.graph-path-item--clickable {
    cursor: pointer;
    transition: background 0.15s;
}

.graph-path-item--clickable:hover {
    background: #eaeaea;
}

.graph-path-item:last-child {
    margin-bottom: 0;
}

.graph-path-item--nested {
    margin-left: 12px;
}

.graph-path-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.graph-path-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.graph-path-info {
    flex: 1;
    min-width: 0;
}

.graph-path-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.graph-path-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.graph-path-via {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.graph-expand-toggle:hover {
    color: var(--text-primary) !important;
    text-decoration: underline;
}

/* Source badges */
.graph-source-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-light);
    color: var(--text-secondary);
}

.graph-source-badge.network-1 {
    background: var(--success-bg);
    color: var(--success);
}

.graph-source-badge.network-2 {
    background: var(--warning-bg);
    color: var(--warning);
}

/* Path item action buttons */
.graph-path-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: auto;
}

.graph-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    padding: 0;
    flex-shrink: 0;
    line-height: 1;
}

.graph-icon-btn:hover {
    background: #e0e0e0;
    color: var(--text-primary);
}

/* G6 Tooltip */
.g6-tooltip {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    box-shadow: var(--shadow);
    font-size: 0.85rem;
}

.g6-tooltip strong {
    display: block;
    margin-bottom: 4px;
}

/* G6 Minimap container */
.g6-minimap {
    position: absolute !important;
    right: 10px;
    bottom: 10px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

/* Legend */
.graph-legend {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--bg-light);
    border-radius: 6px;
    font-size: 0.85rem;
}

.graph-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.graph-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.graph-legend-color.first-degree {
    background: #2e7d32;
}

.graph-legend-color.second-degree {
    background: #e65100;
}

.graph-legend-color.engagement {
    background: #999;
}

/* Loading state */
#graphContainer.loading::after {
    content: 'Loading graph...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Engagement content popup */
.engagement-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.engagement-item:last-child {
    border-bottom: none;
}

.engagement-item-header {
    margin-bottom: 6px;
}

.engagement-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 500;
}

.engagement-badge--comment {
    background: var(--warning-bg);
    color: var(--warning);
}

.engagement-badge--reaction {
    background: var(--success-bg);
    color: var(--success);
}

.engagement-publication {
    margin-bottom: 4px;
}

.engagement-comment {
    margin-left: 16px;
    padding-left: 8px;
    border-left: 2px solid var(--border-color);
}

.engagement-pub-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.engagement-pub-type {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.engagement-pub-date {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.engagement-pub-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
}

.engagement-pub-link:hover {
    color: var(--primary);
}

.engagement-pub-content {
    font-size: 0.8rem;
    color: var(--text-primary);
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 150px;
    overflow-y: auto;
    padding: 6px 8px;
    background: var(--bg-light);
    border-radius: 4px;
    margin-bottom: 4px;
}

.engagement-pub-no-content {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 2px 8px;
    margin-bottom: 4px;
}
