* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #0a0e27;
    color: white;
    overflow: hidden;
    height: 100vh;
}

#container {
    width: 100%;
    height: 100vh;
    position: relative;
}

#graph {
    width: 100%;
    height: 100%;
}

/* Make SVG node labels white with a dark outline for contrast */
#graph text.node-label,
#graph g.node text,
#graph text {
  fill: #ffffff !important;              /* label color */
  stroke: rgba(0,0,0,0.75);              /* dark outline */
  stroke-width: 2px;                     /* outline thickness */
  paint-order: stroke fill;              /* draw stroke behind fill */
  font-weight: 600;
  font-size: 12px;
  text-anchor: middle;                   /* center labels */
  dominant-baseline: middle;             /* vertical centering */
  pointer-events: none;                  /* let clicks pass through */
}

.node {
    cursor: pointer;
    transition: all 0.3s;
}

.dragging .node,
.dragging .node-circle,
.simulating .node,
.simulating .node-circle {
    transition: none !important;
}

.node:hover {
    filter: brightness(1.3);
}

.node-circle {
    stroke: white;
    stroke-width: 2px;
    transition: all 0.3s;
}

.node-circle.hovered {
    stroke: #fff;
    stroke-width: 4px;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.6));
}

.node-circle.pinned {
    stroke: #ffd700;
    stroke-width: 5px;
    filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.8));
}

.node-circle.dimmed {
    opacity: 0.15;
    pointer-events: none;
}

/* Ensure dimmed node text labels are also faded */
.node.dimmed text {
    opacity: 0.15;
}

.node-label {
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
    fill: white;
}


.link {
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 2px;
    fill: none;
}

.link-active {
    stroke: rgba(102, 126, 234, 0.8);
    stroke-width: 3px;
}

/* Control Panel */
.control-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(26, 32, 53, 0.95);
    padding: 20px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    max-width: 350px;
    z-index: 100;
}

.control-panel h2 {
    font-size: 1.3em;
    margin-bottom: 15px;
    color: #667eea;
}

.help-text {
    font-size: 0.75em;
    opacity: 0.6;
    margin-top: 10px;
    line-height: 1.4;
}

/* Subtle scrollbar for control panel and search results */
.control-panel::-webkit-scrollbar,
.info-panel::-webkit-scrollbar {
    width: 4px;
}

.control-panel::-webkit-scrollbar-track,
.info-panel::-webkit-scrollbar-track {
    background: transparent;
}

.control-panel::-webkit-scrollbar-thumb,
.info-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.control-panel::-webkit-scrollbar-thumb:hover,
.info-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.search-container {
    position: relative;
    margin-bottom: 15px;
}

.search-box {
    width: 100%;
    padding: 12px;
    padding-right: 35px;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 14px;
    outline: none;
}

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: none;
    align-items: center;
    justify-content: center;
}

.search-clear:hover {
    background: rgba(255, 255, 255, 0.3);
}

.search-clear.visible {
    display: flex;
}

/* Search results styling */
.search-result-item {
    cursor: pointer;
    transition: all 0.2s;
}

.search-result-item:hover {
    background: rgba(102, 126, 234, 0.3);
    transform: translateX(3px);
}

mark {
    background: #ffd700;
    color: #000;
    padding: 0 2px;
    border-radius: 2px;
}

.search-box:focus {
    border-color: #667eea;
    background: rgba(255, 255, 255, 0.15);
}

.search-box::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Toggle Buttons */
.toggle-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 15px;
}

.toggle-btn {
    padding: 10px 12px;
    border: 2px solid rgba(102, 126, 234, 0.5);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn:hover {
    border-color: rgba(102, 126, 234, 0.8);
    background: rgba(102, 126, 234, 0.1);
}

.toggle-btn.active {
    background: rgba(102, 126, 234, 0.3);
    border-color: #667eea;
    color: white;
}

/* Show All Button */
.show-all-btn {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 15px;
    border: 2px solid rgba(102, 126, 234, 0.5);
    border-radius: 8px;
    background: rgba(102, 126, 234, 0.2);
    color: white;
    font-weight: 600;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
}

.show-all-btn:hover {
    background: rgba(102, 126, 234, 0.4);
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: #667eea;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9em;
}

.btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Info Panel */
.info-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(26, 32, 53, 0.95);
    padding: 20px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

/* Clickable info panel content */
.info-content-clickable {
    cursor: pointer;
    padding: 10px;
    margin: -10px;
    border-radius: 10px;
    transition: background 0.2s;
}

.info-content-clickable:hover {
    background: rgba(102, 126, 234, 0.1);
}

/* Clickable hint indicator */
.info-clickable-hint {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(102, 126, 234, 0.9);
    color: white;
    font-size: 0.7em;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.info-panel.active {
    display: block;
}

.info-panel.pinned {
    border: 2px solid #ffd700;
    box-shadow: 0 8px 32px rgba(255, 215, 0, 0.3);
}

.info-panel .pin-indicator {
    position: absolute;
    top: 15px;
    left: 15px;
    background: #ffd700;
    color: #000;
    font-size: 0.7em;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.info-panel h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.4em;
}

/* Title styling (small tweak so thumbnail sits neatly under it) */
.info-title {
    margin: 0 0 6px 0;
    font-size: 1.05rem;
    line-height: 1.1;
    text-align: center;
}

/* Small inline thumbnail row (placed under title) */
.info-thumb-row {
    text-align: center;
    margin: 4px 0 8px 0;
}

/* Thumbnail: fixed 50px height, keep aspect ratio */
.info-thumb {
    max-height: 50px;
    width: auto;
    max-width: 100%;
    object-fit: cover;
    border-radius: 4px;
    display: inline-block;
    vertical-align: middle;
    border: 1px solid rgba(0,0,0,0.08);
    background: #fff;
}



/* Badges row centered under thumbnail */
.info-badges-row {
    text-align: center;
    margin-bottom: 10px;
}

/* Main image row (displayed after abbreviation) */
.info-image-row {
    text-align: center;
    margin: 12px 0;
}

/* Main/feature image: larger than thumbnail, good for content images */
.info-image {
    max-height: 150px;
    max-width: 100%;
    width: auto;
    object-fit: cover;
    border-radius: 8px;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ===== Badge styles (replace existing badge rules) ===== */
.info-badge {
  display: inline-block;
  padding: 3px 8px;
  margin: 0 6px;
  font-size: 0.78rem;
  border-radius: 12px;
  vertical-align: middle;
  font-weight: 600;
  line-height: 1;
  color: #0b1220;               /* dark text for light backgrounds */
  background: rgba(255,255,255,0.92); /* neutral light pill by default */
  box-shadow: 0 2px 6px rgba(2,6,12,0.25);
  border: 1px solid rgba(0,0,0,0.06);
}

/* Type badge: pale blue with dark text */
.badge-type {
  background: rgba(191,225,255,0.98);
  color: #062038;
  border-color: rgba(9,40,66,0.06);
}

/* Abbreviation badge: slightly stronger tone */
.badge-abbr {
  background: rgba(120,190,255,0.98);
  color: #04162a;
}



.badge-division { background: #e3f2fd; color: #1976d2; }
.badge-department { background: #f3e5f5; color: #7b1fa2; }
.badge-institute { background: #e8f5e9; color: #388e3c; }
.badge-centre { background: #fff3e0; color: #f57c00; }

.info-section {
    margin: 15px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}







.info-label {
    font-size: 0.85em;
    opacity: 0.7;
    margin-bottom: 5px;
}

.info-value {
    font-size: 0.95em;
    line-height: 1.5;
}

/* Container for link buttons */
.info-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 15px 0;
    padding: 10px 0;
}

/* Smaller link buttons */
.info-link-btn {
    display: inline-block;
    padding: 6px 12px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 500;
    transition: all 0.2s;
}

.info-link-btn:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

.info-link {
    display: inline-block;
    margin-top: 10px;
    padding: 10px 20px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
}

.info-link:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.children-list {
    list-style: none;
    padding: 0;
}

.children-list li {
    padding: 8px;
    background: rgba(102, 126, 234, 0.1);
    margin-bottom: 5px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.children-list li:hover {
    background: rgba(102, 126, 234, 0.3);
    transform: translateX(5px);
}

/* Loading */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 200;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(102, 126, 234, 0.3);
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Zoom controls */
.zoom-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.zoom-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.9);
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    background: #667eea;
    transform: scale(1.1);
}

/* Back button for focus mode */
.back-button {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: rgba(102, 126, 234, 0.9);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.back-button.visible {
    opacity: 1;
    visibility: visible;
}

.back-button:hover {
    background: #667eea;
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Debug control */
.debug-control {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(10, 14, 39, 0.95);
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.3);
    font-size: 13px;
    z-index: 150;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.debug-control label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.debug-control input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

/* Debug info sections */
.debug-info {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(102, 126, 234, 0.3);
}

.debug-info .info-label {
    color: #f39c12;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.debug-stats {
    margin-top: 15px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.debug-stats h4 {
    font-size: 12px;
    color: #f39c12;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.debug-stats-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 12px;
    font-size: 12px;
}

.debug-stats-label {
    color: rgba(255, 255, 255, 0.7);
}

.debug-stats-count {
    color: #667eea;
    font-weight: 600;
    text-align: right;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(26, 32, 53, 0.95);
    padding: 10px 15px;
    border-radius: 8px;
    pointer-events: none;
    font-size: 0.9em;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1000;
}

.tooltip.active {
    opacity: 1;
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-container {
    width: 90vw;
    height: 90vh;
    background: rgba(26, 32, 53, 0.98);
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    background: rgba(102, 126, 234, 0.1);
    border-bottom: 1px solid rgba(102, 126, 234, 0.3);
}

.modal-title {
    font-size: 1.1em;
    font-weight: 600;
    color: #667eea;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
    margin-left: 15px;
}

.modal-open-tab {
    background: rgba(102, 126, 234, 0.2);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-open-tab:hover {
    background: rgba(102, 126, 234, 0.4);
    transform: translateY(-2px);
}

.modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5em;
    line-height: 1;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.modal-iframe {
    flex: 1;
    width: 100%;
    border: none;
    background: white;
}

/* Modal error state */
.modal-error {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px;
    text-align: center;
    background: rgba(26, 32, 53, 0.5);
}

.modal-error.active {
    display: flex;
}

.modal-error-icon {
    font-size: 4em;
    margin-bottom: 20px;
    opacity: 0.8;
}

.modal-error-message {
    font-size: 1.1em;
    margin-bottom: 25px;
    color: rgba(255, 255, 255, 0.9);
    max-width: 500px;
    line-height: 1.5;
}

.modal-error-btn {
    padding: 12px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-error-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

@media (max-width: 768px) {
    .control-panel, .info-panel {
        max-width: 90vw;
    }

    .modal-container {
        width: 95vw;
        height: 95vh;
    }
}
