/* ================================================
   Citation Network - Layout & Styles
   ================================================ */

.cn-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 49px); /* viewport minus nav height */
}

/* ================================================
   Sidebar
   ================================================ */

.cn-sidebar {
    width: 320px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-light);
    background: var(--bg-white);
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cn-sidebar h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* ================================================
   Search
   ================================================ */

.cn-search-box {
    display: flex;
    gap: 6px;
}

.cn-search-box input {
    flex: 1;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.cn-search-box input:focus {
    border-color: var(--primary);
}

.cn-search-box button {
    padding: 8px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.cn-search-box button:hover {
    background: var(--primary-dark);
}

.cn-search-status {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    min-height: 18px;
}

.cn-search-status.error {
    color: #EF4444;
}

/* ================================================
   Paper Card (sidebar)
   ================================================ */

.cn-paper-card {
    background: var(--bg-gray);
    border-radius: var(--radius-md);
    padding: 14px;
    border: 1px solid var(--border-light);
}

.cn-paper-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 6px;
    word-break: break-word;
}

.cn-paper-meta {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.cn-paper-stats {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.cn-paper-stats .stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cn-paper-stats .stat strong {
    color: var(--text-primary);
}

/* ================================================
   Legend
   ================================================ */

.cn-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.cn-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ================================================
   Controls
   ================================================ */

.cn-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cn-control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.cn-control-row label {
    font-size: 13px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.cn-control-row select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-white);
    cursor: pointer;
}

.cn-control-row input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
}

/* ================================================
   Buttons
   ================================================ */

.cn-btn {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: background 0.2s, color 0.2s;
}

.cn-btn-primary {
    background: var(--primary);
    color: white;
}

.cn-btn-primary:hover {
    background: var(--primary-dark);
}

.cn-btn-secondary {
    background: var(--bg-gray);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.cn-btn-secondary:hover {
    background: var(--border-light);
}

.cn-selected-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* ================================================
   Graph Container
   ================================================ */

.cn-main {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #FAFBFC;
}

.cn-graph-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.cn-graph-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

.cn-graph-container canvas:active {
    cursor: grabbing;
}

/* ================================================
   Loading / Empty States
   ================================================ */

.cn-loading,
.cn-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(250, 251, 252, 0.9);
    z-index: 10;
}

.cn-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: cn-spin 0.8s linear infinite;
}

@keyframes cn-spin {
    to { transform: rotate(360deg); }
}

.cn-loading p {
    font-size: 14px;
    color: var(--text-muted);
}

.cn-empty h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 4px;
}

.cn-empty p {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    max-width: 360px;
    line-height: 1.6;
}

/* ================================================
   Tooltip
   ================================================ */

.cn-tooltip {
    position: absolute;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    pointer-events: none;
    z-index: 20;
    max-width: 320px;
    word-break: break-word;
}

.cn-tooltip .tt-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.cn-tooltip .tt-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ================================================
   Nav label
   ================================================ */

.nav-page-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ================================================
   Responsive
   ================================================ */

@media (max-width: 900px) {
    .cn-layout {
        flex-direction: column;
        height: auto;
    }

    .cn-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        max-height: 40vh;
        overflow-y: auto;
    }

    .cn-main {
        min-height: 60vh;
    }

    .cn-legend {
        display: none;
    }
}

@media (max-width: 480px) {
    .cn-sidebar {
        padding: 14px;
        gap: 14px;
    }

    .cn-controls {
        display: none;
    }
}
