/**
 * DevScholar JupyterLab Extension Styles
 */

/* Cell with paper references indicator */
.devscholar-has-papers {
    position: relative;
}

.devscholar-has-papers::before {
    content: '📚';
    position: absolute;
    left: -24px;
    top: 8px;
    font-size: 14px;
    opacity: 0.7;
}

/* Paper reference highlight */
.devscholar-paper-reference {
    background-color: rgba(var(--jp-brand-color1-rgb), 0.15);
    border-bottom: 2px solid var(--jp-brand-color1);
    cursor: pointer;
    padding: 0 2px;
    border-radius: 2px;
    transition: background-color 0.2s ease;
}

.devscholar-paper-reference:hover {
    background-color: rgba(var(--jp-brand-color1-rgb), 0.25);
}

/* Paper type badges */
.devscholar-paper-reference[data-paper-type="arxiv"] {
    border-bottom-color: #b31b1b;
}

.devscholar-paper-reference[data-paper-type="doi"] {
    border-bottom-color: #fcb426;
}

.devscholar-paper-reference[data-paper-type="ieee"] {
    border-bottom-color: #00629b;
}

.devscholar-paper-reference[data-paper-type="semantic_scholar"] {
    border-bottom-color: #1857b6;
}

.devscholar-paper-reference[data-paper-type="openalex"] {
    border-bottom-color: #a50f15;
}

/* Tooltip styles */
.devscholar-tooltip {
    font-family: var(--jp-ui-font-family);
}

.devscholar-tooltip a:hover {
    text-decoration: underline;
}

/* Paper count badge in cell */
.devscholar-has-papers::after {
    content: attr(data-devscholar-papers) ' paper(s)';
    position: absolute;
    right: 8px;
    top: 8px;
    font-size: 11px;
    color: var(--jp-ui-font-color2);
    background: var(--jp-layout-color2);
    padding: 2px 6px;
    border-radius: 10px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.devscholar-has-papers:hover::after {
    opacity: 1;
}

/* Dark mode adjustments */
[data-jp-theme-light="false"] .devscholar-tooltip {
    background: var(--jp-layout-color1);
    border-color: var(--jp-border-color2);
}

/* CodeMirror integration - paper reference underline */
.cm-devscholar-paper {
    text-decoration: underline;
    text-decoration-color: var(--jp-brand-color1);
    text-decoration-style: dotted;
    cursor: pointer;
}

.cm-devscholar-paper:hover {
    text-decoration-style: solid;
    background-color: rgba(var(--jp-brand-color1-rgb), 0.1);
}

/* Search dialog styles */
.devscholar-search-dialog {
    min-width: 550px;
    max-width: 650px;
}

.devscholar-search-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.devscholar-search-input-wrapper {
    position: relative;
}

.devscholar-search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--jp-border-color1);
    border-radius: 6px;
    font-size: 14px;
    background: var(--jp-layout-color0);
    color: var(--jp-ui-font-color0);
    box-sizing: border-box;
}

.devscholar-search-input:focus {
    outline: none;
    border-color: var(--jp-brand-color1);
    box-shadow: 0 0 0 2px rgba(var(--jp-brand-color1-rgb), 0.2);
}

.devscholar-search-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--jp-ui-font-color2);
    font-size: 13px;
    padding: 8px 0;
}

.devscholar-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--jp-border-color2);
    border-top-color: var(--jp-brand-color1);
    border-radius: 50%;
    animation: devscholar-spin 0.8s linear infinite;
}

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

.devscholar-search-results {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid var(--jp-border-color1);
    border-radius: 6px;
    background: var(--jp-layout-color1);
}

.devscholar-search-result-item {
    padding: 12px 14px;
    border-bottom: 1px solid var(--jp-border-color1);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.devscholar-search-result-item:last-child {
    border-bottom: none;
}

.devscholar-search-result-item:hover {
    background-color: var(--jp-layout-color2);
}

.devscholar-search-result-item.selected {
    background-color: rgba(var(--jp-brand-color1-rgb), 0.15);
    border-left: 3px solid var(--jp-brand-color1);
    padding-left: 11px;
}

.devscholar-result-title {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 4px;
    color: var(--jp-ui-font-color0);
}

.devscholar-result-authors {
    font-size: 12px;
    color: var(--jp-ui-font-color2);
    margin-bottom: 4px;
}

.devscholar-result-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--jp-ui-font-color3);
}

.devscholar-result-meta-info {
    color: var(--jp-ui-font-color2);
}

.devscholar-result-id {
    font-family: var(--jp-code-font-family);
    font-size: 10px;
    background: var(--jp-layout-color2);
    padding: 2px 6px;
    border-radius: 3px;
}

.devscholar-search-hint {
    font-size: 11px;
    color: var(--jp-ui-font-color3);
    text-align: center;
}

.devscholar-search-empty,
.devscholar-search-error {
    padding: 24px;
    text-align: center;
    color: var(--jp-ui-font-color2);
    font-size: 13px;
}

.devscholar-search-error {
    color: var(--jp-error-color1);
}

/* PDF Preview Styles */
.devscholar-pdf-preview {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #525659;
}

.devscholar-pdf-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.devscholar-pdf-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #323639;
    color: white;
    font-family: var(--jp-ui-font-family);
    font-size: 13px;
    flex-shrink: 0;
}

.devscholar-pdf-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

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

.devscholar-pdf-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.devscholar-pdf-page-info {
    font-size: 13px;
}

.devscholar-pdf-zoom-level {
    min-width: 50px;
    text-align: center;
}

.devscholar-pdf-spacer {
    flex: 1;
}

.devscholar-pdf-viewer {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.devscholar-pdf-viewer canvas {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    background: white;
}

.devscholar-pdf-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: white;
    font-family: var(--jp-ui-font-family);
}

.devscholar-pdf-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: devscholar-spin 0.8s linear infinite;
    margin-bottom: 16px;
}

.devscholar-pdf-loading-title {
    font-size: 12px;
    opacity: 0.7;
    max-width: 400px;
    text-align: center;
    margin-top: 8px;
}

.devscholar-pdf-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: white;
    font-family: var(--jp-ui-font-family);
    text-align: center;
    padding: 20px;
}

.devscholar-pdf-error-icon {
    width: 48px;
    height: 48px;
    border: 3px solid #ff6b6b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: #ff6b6b;
    margin-bottom: 16px;
}

.devscholar-pdf-error h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
}

.devscholar-pdf-error p {
    margin: 0 0 16px 0;
    opacity: 0.8;
    font-size: 13px;
}

.devscholar-pdf-error-link {
    color: var(--jp-brand-color1);
    text-decoration: none;
    padding: 8px 16px;
    border: 1px solid var(--jp-brand-color1);
    border-radius: 4px;
    transition: all 0.15s ease;
}

.devscholar-pdf-error-link:hover {
    background: var(--jp-brand-color1);
    color: white;
}
