/* =============================================================================
   BIBLIOMETRIC ANALYSIS WEB APP - STYLES
   Modern dark theme inspired by VOSviewer
   ============================================================================= */

/* CSS Variables - Dark Theme (default) */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-hover: #1f3460;

    --text-primary: #e8e8e8;
    --text-secondary: #a0a0b0;
    --text-muted: #6b6b80;

    --accent-primary: #4361ee;
    --accent-secondary: #3f37c9;
    --accent-success: #4CAF50;
    --accent-info: #2196F3;
    --accent-warning: #ff9800;

    --border-color: #2a2a4a;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);

    --sidebar-width: 260px;
    --header-height: 60px;
    --transition: all 0.3s ease;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #e8ecf1;

    --text-primary: #1a1a2e;
    --text-secondary: #4a5568;
    --text-muted: #718096;

    --accent-primary: #4361ee;
    --accent-secondary: #3f37c9;
    --accent-success: #38a169;
    --accent-info: #3182ce;
    --accent-warning: #dd6b20;

    --border-color: #e2e8f0;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Theme Toggle Switch */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
}

.theme-toggle-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.theme-switch {
    position: relative;
    width: 50px;
    height: 26px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 26px;
    transition: var(--transition);
}

.theme-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 2px;
    background: #ffffff;
    border-radius: 50%;
    transition: var(--transition);
}

.theme-switch input:checked+.theme-slider {
    background: var(--accent-primary);
}

.theme-switch input:checked+.theme-slider:before {
    transform: translateX(22px);
}

/* Keywords Action Icons */
.action-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    display: block;
    filter: invert(1);
    /* White in dark mode (default) */
    opacity: 0.8;
    transition: var(--transition);
}

.icon-btn:hover .action-icon {
    opacity: 1;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
    transition: var(--transition);
}

.modal-overlay.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

/* Modal Container */
.modal-container {
    background: var(--bg-card);
    width: 90%;
    max-width: 450px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px 20px;
}

.modal-body p {
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.modal-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-input-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Theme adaptation for modal */
[data-theme="light"] .modal-overlay {
    background: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .modal-container {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

/* Light theme toggle fix */
[data-theme="light"] .action-icon {
    filter: none;
    /* Black in light mode */
    opacity: 0.7;
}

[data-theme="light"] .theme-slider {
    background: #e2e8f0;
    border-color: #cbd5e0;
}

[data-theme="light"] .theme-slider:before {
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* =============================================================================
   LAYOUT
   ============================================================================= */

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 16px; /* Reduced from 20px */
    overflow-y: auto;
    scrollbar-width: thin; /* Firefox */
}

/* Custom Scrollbar for Sidebar */
.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.sidebar-footer a {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-decoration: none;
}

.sidebar-footer a:hover {
    color: var(--text-secondary);
    text-decoration: underline;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    width: 60px;
    height: 60px;
    object-fit: contain;
    flex-shrink: 0;
    transform: translateY(-1px);
}

.logo-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    transform: translateY(4px);
}

.logo-text h1 {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
    margin: 0;
    color: #4361ee;
    letter-spacing: -0.5px;
}

.logo-text .subtitle {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    margin-top: 4px;
    color: var(--text-secondary);
    max-width: 150px;
}

.sidebar-section {
    margin-bottom: 24px; /* Balanced spacing */
}

.sidebar-section:last-child {
    margin-bottom: 0;
}

.sidebar-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.sidebar-section-header {
    display: flex;
    justify-content: flex-start;
    gap: 4px;
    align-items: center;
    margin-bottom: 8px;
}

.sidebar-section-header h3 {
    margin-bottom: 0;
}

.icon-btn-sidebar {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.icon-btn-sidebar:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .icon-btn-sidebar:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Navigation */
.nav-list {
    list-style: none;
}

.nav-item {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-primary);
    color: white;
}

/* Upload Zone */
.upload-zone {
    text-align: center;
    padding: 15px;
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    transition: var(--transition);
}

.upload-zone:hover {
    border-color: var(--accent-primary);
}

.upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.data-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: 6px;
    font-size: 0.85rem;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-success);
}

/* Upload Zone */
.upload-zone {
    padding: 16px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

.upload-zone.drag-over {
    border-style: solid;
}

.upload-hint {
    margin: 8px 0 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

/* Button Icons */
.btn-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    filter: invert(1) brightness(2);
    /* Force pure white */
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: 10px;
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent-primary);
    width: 16px;
    height: 16px;
}

.checkbox-label.link-toggle {
    font-size: 0.8rem;
    padding: 6px 10px;
    background: var(--bg-hover);
    border-radius: 6px;
    margin-bottom: 12px;
}

/* Type Tags */
.type-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.type-tag.internal {
    background: rgba(67, 97, 238, 0.15);
    color: var(--accent-primary);
    border: 1px solid rgba(67, 97, 238, 0.3);
}

.type-tag.external {
    background: rgba(158, 158, 158, 0.15);
    color: var(--text-muted);
    border: 1px solid rgba(158, 158, 158, 0.3);
}

/* Settings Group */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.number-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* Hide default spin buttons */
.input-number::-webkit-inner-spin-button,
.input-number::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-number {
    width: 100%;
    padding: 8px 30px 8px 12px;
    /* Extra padding on right for spin buttons */
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition);
    appearance: textfield;
}

.spin-buttons {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    width: 24px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-color);
}

.spin-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: none;
    color: var(--text-muted);
    font-size: 0.6rem;
    cursor: pointer;
    padding: 0;
    transition: var(--transition);
}

.spin-btn:first-child {
    border-bottom: 1px solid var(--border-color);
    border-top-right-radius: 5px;
}

.spin-btn:last-child {
    border-bottom-right-radius: 5px;
}

.spin-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.input-number:focus+.spin-buttons {
    border-color: var(--accent-primary);
}

.settings-link {
    font-size: 0.8rem;
    color: var(--accent-primary);
    text-decoration: none;
    cursor: pointer;
    margin-top: 4px;
    display: inline-block;
}

.settings-link:hover {
    text-decoration: underline;
}

/* Slim Range Slider */
.range-slim {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
}

.range-slim::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    border: 2px solid var(--bg-card);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.range-slim::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    border: 2px solid var(--bg-card);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.range-slim::-moz-range-track {
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
}

/* Sort Controls */
.sort-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.sort-control label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.stylish-select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    padding-right: 4px;
}

.stylish-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* =============================================================================
   MAIN CONTENT
   ============================================================================= */

.main-content {
    flex: 1;
    overflow: hidden;
    background: var(--bg-primary);
}

/* Keywords Progress Bar */
.keywords-loading-container {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.loading-status {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.progress-bar-bg {
    height: 10px;
    background: var(--bg-secondary);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), #4DD0E1);
    width: 0%;
    border-radius: 5px;
    transition: width 0.3s ease-out;
}

.loading-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Views */
.view {
    display: none;
    overflow-y: auto;
    /* Individual views can scroll */
    height: 100%;
    padding: 30px;
}

.view.active {
    display: flex;
    /* Changed from block to flex for dashboard layout support */
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.view-header {
    margin-bottom: 30px;
}

.view-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
}

.view-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.view-header-title h2 {
    margin-bottom: 0;
}

.refresh-icon {
    width: 16px;
    height: 16px;
    display: block;
    color: var(--text-primary);
    opacity: 0.8;
    transition: var(--transition);
}

.refresh-btn:hover .refresh-icon {
    opacity: 1;
    transform: rotate(90deg);
}

.view-header p {
    color: var(--text-secondary);
}

.core-count-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 12px;
    background: var(--accent-primary);
    color: white;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* Dashboard Sub-Layouts */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 30px;
}

.metrics-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.content-column {
    display: flex;
    flex-direction: column;
    height: 0px;
    min-height: 100%;
}

/* Flex Panel (occupies full height) */
.flex-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
}

.panel-header-sticky {
    padding: 24px;
}

.panel-header-sticky h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin: 0;
}

.full-height-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px 24px 24px;
}

.metrics-panel {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .metrics-panel {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}

.core-panel {
    border-color: rgba(67, 97, 238, 0.5);
    background: linear-gradient(145deg, var(--bg-card), rgba(67, 97, 238, 0.03));
}

.metrics-panel-title {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 24px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.core-panel .metrics-panel-title {
    color: var(--accent-primary);
    border-bottom-color: rgba(67, 97, 238, 0.2);
}

.main-stat {
    text-align: center;
    margin-bottom: 30px;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 6px;
    line-height: 1.2;
}

.main-stat .stat-value.highlight {
    font-size: 3.5rem;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.main-stat .stat-label {
    font-size: 1rem;
}

.sub-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: auto;
}

.sub-stat-card {
    background: var(--bg-secondary);
    padding: 16px 12px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.sub-stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
    background: var(--bg-hover);
}

@media (max-width: 1200px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
}

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

/* Panels */
.panel {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
}

.panel h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.placeholder {
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}

/* Article List */
.article-list {
    overflow-y: auto;
}

.article-item {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.article-item:last-child {
    margin-bottom: 0;
}

.article-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    transform: translateX(4px);
}

.article-title {
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.article-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.article-citations {
    display: inline-block;
    padding: 2px 8px;
    background: var(--accent-primary);
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: 8px;
}

/* =============================================================================
   NETWORK VISUALIZATION
   ============================================================================= */

.network-container {
    position: relative;
    height: calc(100vh - 160px);
    min-height: 500px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

/* Network Loading Overlay */
.network-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 12px;
}

[data-theme="light"] .network-loading-overlay {
    background: rgba(255, 255, 255, 0.6);
}

.cytoscape-container {
    width: 100%;
    height: 100%;
}

/* Node Details Panel */
.details-panel {
    position: absolute;
    top: 60px;
    right: 20px;
    width: 300px;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    z-index: 100;
}

.details-panel h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    padding-right: 30px;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-primary);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-label {
    color: var(--text-secondary);
}

/* Network Legend */
.network-legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 15px;
    margin-top: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

/* Network Fullscreen Button */
.network-fullscreen-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 101;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.network-fullscreen-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: scale(1.05);
}

/* Network Fullscreen Overlay */
.network-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    height: 100vh;
    min-height: unset;
    border-radius: 0;
    border: none;
    animation: fadeIn 0.25s ease;
}

.network-container.fullscreen .network-fullscreen-btn {
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    font-size: 1.3rem;
    z-index: 10001;
}

.network-container.fullscreen .details-panel {
    z-index: 10001;
}

/* Fullscreen Legend (overlay at bottom) */
.network-fullscreen-legend {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 12px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    z-index: 10001;
}

/* =============================================================================
   TABLES
   ============================================================================= */

.table-container {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: visible;
}

/* Specific height for empty table state to accommodate tooltips */
.data-table td[colspan] {
    padding: 40px !important;
    text-align: center;
    color: var(--text-muted);
    min-height: 120px;
}

.table-controls {
    margin-bottom: 15px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.data-table th,
.data-table td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    box-sizing: border-box;
}

.data-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.data-table th:first-child {
    border-top-left-radius: 11px;
}

.data-table th:last-child {
    border-top-right-radius: 11px;
}

/* Column Widths & Padding tweaks */
.data-table th:nth-child(1),
.data-table td:nth-child(1) {
    width: 45px;
    padding-left: 10px;
    padding-right: 10px;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
    width: 38%;
    padding-left: 10px;
}

.data-table th:nth-child(3),
.data-table td:nth-child(3) {
    width: 19%;
}

.data-table th:nth-child(4),
.data-table td:nth-child(4) {
    width: 6%;
}

.data-table th:nth-child(5),
.data-table td:nth-child(5) {
    width: 8%;
}

.data-table th:nth-child(6),
.data-table td:nth-child(6) {
    width: 8%;
}

.data-table th:nth-child(7),
.data-table td:nth-child(7) {
    width: 11%;
}

.data-table th:nth-child(8),
.data-table td:nth-child(8) {
    width: 7%;
}

/* Zebra striping */
.data-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .data-table tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.03);
}

.data-table tr:hover {
    background: var(--bg-hover) !important;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:last-child td:first-child {
    border-bottom-left-radius: 11px;
}

.data-table tr:last-child td:last-child {
    border-bottom-right-radius: 11px;
}

/* Numeric columns center align */
.data-table th:nth-child(1),
.data-table td:nth-child(1),
.data-table th:nth-child(4),
.data-table td:nth-child(4),
.data-table th:nth-child(5),
.data-table td:nth-child(5),
.data-table th:nth-child(6),
.data-table td:nth-child(6),
.data-table th:nth-child(7),
.data-table td:nth-child(7),
.data-table th:nth-child(8),
.data-table td:nth-child(8) {
    text-align: center;
}

/* Header Toggles Wrapper */
.header-toggle-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
}

.header-label {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 4px;
    font-size: 0.75rem;
}

.mini-toggle {
    display: inline-flex;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1px;
    cursor: pointer;
    font-weight: normal;
    flex-shrink: 0;
}

.mini-toggle-option {
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    transition: var(--transition);
}

.mini-toggle-option.active {
    background: var(--accent-primary);
    color: white;
}

[data-theme="light"] .mini-toggle {
    background: #edf2f7;
}

.header-toggle-container .sort-icon {
    font-size: 0.7rem;
    min-width: 10px;
}

/* Info Icon and Tooltip */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    font-size: 10px;
    color: var(--text-muted);
    cursor: help;
    font-style: normal;
    font-family: inherit;
    font-weight: bold;
    text-transform: none;
    transition: var(--transition);
    position: relative;
    margin-left: 2px;
}

.info-icon:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.tooltip-container {
    position: relative;
    display: inline-block;
}

.tooltip-text {
    visibility: hidden;
    width: max-content;
    max-width: 220px;
    background-color: var(--bg-card);
    color: var(--text-primary);
    text-align: left;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 1000;
    top: 150%;
    right: -15px;
    left: auto;
    opacity: 0;
    transition: opacity 0.3s;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    font-size: 12px;
    font-weight: normal;
    line-height: 1.4;
    text-transform: none;
    letter-spacing: normal;
    white-space: normal;
}

.tooltip-text::after {
    content: "";
    position: absolute;
    bottom: 100%;
    right: 17px;
    left: auto;
    border-width: 5px;
    border-style: solid;
    border-color: transparent transparent var(--border-color) transparent;
}

.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination button {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.pagination button:hover {
    background: var(--bg-hover);
}

.pagination button.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* =============================================================================
   KEYWORDS
   ============================================================================= */

.keywords-container {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
}

.keywords-list {
    max-height: 620px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.keywords-list::-webkit-scrollbar {
    width: 6px;
}

.keywords-list::-webkit-scrollbar-track {
    background: transparent;
}

.keywords-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.keywords-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Keyword Ranking List */
.keyword-ranking {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: none;
}

.keyword-rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    transition: var(--transition);
    border-bottom: 1px solid var(--border-color);
}

.keyword-rank-item:last-child {
    border-bottom: none;
}

.keyword-rank-item:hover {
    background: var(--bg-hover);
}

.keyword-rank-number {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* Highlight top 3 ranking numbers */
.keyword-rank-item:nth-child(1) .keyword-rank-number,
.keyword-rank-item:nth-child(2) .keyword-rank-number,
.keyword-rank-item:nth-child(3) .keyword-rank-number {
    background: var(--accent-primary);
    color: white;
}

.keyword-rank-term {
    flex: 1;
    font-size: 0.92rem;
    color: var(--text-primary);
}

.keyword-rank-freq {
    flex-shrink: 0;
    background: var(--accent-primary);
    color: white;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 600;
    min-width: 36px;
    text-align: center;
}

/* Keywords Grid Layout */
.keywords-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}

/* Keywords Header and Individual Actions */
.keywords-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.keywords-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(67, 97, 238, 0.1);
    /* Subtle blue tint using accent-primary color */
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.keywords-title {
    font-size: 1.1rem;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.keywords-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

/* Keywords Loading */
.keywords-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.keywords-loading p {
    color: var(--text-secondary);
    margin-top: 15px;
    text-align: center;
}

.loading-spinner-inline {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Clean up old toolbar styles */
.keywords-toolbar {
    display: none;
}

.export-dropdown-wrapper {
    position: relative;
}

.export-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 260px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow);
    z-index: 200;
    overflow: hidden;
    animation: fadeIn 0.15s ease;
}

.export-dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
}

.export-dropdown-item:last-child {
    border-bottom: none;
}

.export-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

/* =============================================================================
   LOADING
   ============================================================================= */

.loading-overlay {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2.5px);
    -webkit-backdrop-filter: blur(2.5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: var(--transition);
}

[data-theme="light"] .loading-overlay {
    background: rgba(255, 255, 255, 0.4);
}

.loading-content {
    background: rgba(22, 33, 62, 0.5);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 40px 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
    animation: loadingPopIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

[data-theme="light"] .loading-content {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1);
}

.loading-text {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 500;
    margin-top: 8px;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
}

.graph-spinner {
    width: 60px;
    height: 60px;
    margin-bottom: 24px;
    animation: spinLoader 8s linear infinite;
    display: flex;
    justify-content: center;
    align-items: center;
}

.graph-spinner svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.graph-spinner .graph-edges line {
    stroke: var(--border-color);
    stroke-width: 2;
    stroke-linecap: round;
    opacity: 0.3;
    animation: pulseEdge 1.5s ease-in-out infinite alternate;
}

.graph-spinner .graph-edges line:nth-child(1) {
    animation-delay: 0s;
}

.graph-spinner .graph-edges line:nth-child(2) {
    animation-delay: 0.5s;
}

.graph-spinner .graph-edges line:nth-child(3) {
    animation-delay: 1s;
}

.graph-spinner .graph-nodes circle {
    fill: var(--bg-card);
    stroke: var(--accent-primary);
    stroke-width: 2.5;
    transition: var(--transition);
}

.graph-spinner .core-node {
    fill: var(--accent-primary);
    animation: pulseCore 1.5s ease-in-out infinite alternate;
}

.graph-spinner .satellite-node.s1 {
    animation: pulseSatellite 1.5s ease-in-out infinite alternate 0s;
}

.graph-spinner .satellite-node.s2 {
    animation: pulseSatellite 1.5s ease-in-out infinite alternate 0.5s;
}

.graph-spinner .satellite-node.s3 {
    animation: pulseSatellite 1.5s ease-in-out infinite alternate 1s;
}

@keyframes pulseCore {
    0% {
        r: 8;
        opacity: 0.8;
    }

    100% {
        r: 12;
        opacity: 1;
        stroke-width: 4;
    }
}

@keyframes pulseSatellite {
    0% {
        r: 4;
        stroke-width: 2;
        fill: var(--bg-card);
    }

    100% {
        r: 6;
        stroke-width: 3;
        fill: var(--bg-hover);
    }
}

@keyframes pulseEdge {
    0% {
        opacity: 0.2;
        stroke-width: 1.5;
    }

    100% {
        opacity: 0.8;
        stroke-width: 3;
        stroke: var(--accent-primary);
    }
}

.btn-cancel {
    margin-top: 24px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.btn-cancel:hover {
    background: var(--accent-primary);
    color: #ffffff;
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

@keyframes loadingPopIn {
    0% {
        transform: scale(0.95);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes spinLoader {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes spinLoaderReverse {
    0% {
        transform: rotate(360deg);
    }

    100% {
        transform: rotate(0deg);
    }
}

@keyframes loadingDots {

    0%,
    20% {
        opacity: 0;
        transform: translateY(0);
    }

    50% {
        opacity: 1;
        transform: translateY(-2px);
    }

    80%,
    100% {
        opacity: 0;
        transform: translateY(0);
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: fixed;
        top: 0;
        left: -100%;
        z-index: 1000;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .main-content {
        padding: 20px;
    }

    .content-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .details-panel {
        width: calc(100% - 40px);
        left: 20px;
        right: 20px;
    }
}

/* =============================================================================
   TOAST NOTIFICATIONS
   ============================================================================= */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    color: var(--text-primary);
    font-size: 0.9rem;
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease, toastFadeOut 0.3s ease forwards;
    animation-delay: 0s, 4s;
    max-width: 400px;
}

.toast.success {
    border-left: 4px solid var(--accent-success);
}

.toast.error {
    border-left: 4px solid #e53e3e;
}

.toast.info {
    border-left: 4px solid var(--accent-info);
}

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    margin-left: auto;
    padding: 0 4px;
}

.toast-close:hover {
    color: var(--text-primary);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateX(50%);
    }
}

/* =============================================================================
   EXPORT DROPDOWN
   ============================================================================= */

.export-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.export-dropdown-wrapper .btn-icon {
    filter: none;
    width: 16px;
    height: 16px;
    opacity: 0.7;
    transition: var(--transition);
}

/* Dark theme: invert the icon to white */
:root .export-dropdown-wrapper .btn-icon {
    filter: invert(1) brightness(2);
}

[data-theme="light"] .export-dropdown-wrapper .btn-icon {
    filter: none;
    opacity: 0.7;
}

.export-dropdown {
    position: fixed;
    min-width: 240px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    overflow: hidden;
    animation: dropdownSlideIn 0.2s ease;
}

[data-theme="light"] .export-dropdown {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.export-dropdown.hidden {
    display: none;
}

@keyframes dropdownSlideIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.export-dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
    color: var(--text-primary);
}

.export-dropdown-item:last-child {
    border-bottom: none;
}

.export-dropdown-item:hover {
    background: var(--bg-hover);
}

.export-dropdown-item:active {
    background: var(--accent-primary);
    color: white;
}

.export-dropdown-item:active .export-format-desc {
    color: rgba(255, 255, 255, 0.8);
}

.export-format-icon {
    font-size: 1.3rem;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.export-format-name {
    font-weight: 600;
    font-size: 0.9rem;
    display: block;
    line-height: 1.3;
}

.export-format-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    line-height: 1.3;
}