/* ================================================
 * Library Page Styles
 * Extracted from templates/pages/library.html
 * ================================================ */

.ldr-library-container {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.ldr-library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Library Status Bar */
.ldr-library-status-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    padding: 15px 20px;
    background: var(--card-bg, #2a2a2a);
    border: 1px solid var(--border-color, #333);
    border-radius: 8px;
    margin-bottom: 20px;
}

.ldr-library-status-bar .ldr-status-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ldr-library-status-bar .ldr-status-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

.ldr-library-status-bar .badge {
    padding: 6px 12px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 6px;
}

.ldr-library-status-bar .ldr-badge-button {
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.ldr-library-status-bar .ldr-badge-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    filter: brightness(1.1);
}

.ldr-library-status-bar .ldr-badge-button:active {
    transform: translateY(0);
}

.ldr-library-status-bar .badge-secondary {
    background: var(--text-muted);
    color: white;
}

.ldr-library-status-bar .badge-success {
    background: var(--success-color);
    color: white;
}

.ldr-library-status-bar .badge-warning {
    background: var(--warning-color);
    color: white;
}

.ldr-library-status-bar .ldr-status-hint {
    color: var(--accent-tertiary);
    font-size: 14px;
    cursor: help;
}

.ldr-header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.ldr-library-container .btn-group {
    display: flex;
    gap: 0;
}

.ldr-library-container .btn-group .btn {
    border-radius: 0;
}

.ldr-library-container .btn-group .btn:first-child {
    border-radius: 4px 0 0 4px;
}

.ldr-library-container .btn-group .btn:last-child {
    border-radius: 0 4px 4px 0;
}

.ldr-library-container .btn-info {
    background: var(--accent-tertiary);
    color: white;
    border: 1px solid var(--accent-tertiary);
}

.ldr-library-container .btn-info:hover {
    background: var(--accent-tertiary);
    border-color: var(--accent-tertiary);
    filter: brightness(0.85);
}

.ldr-library-stats {
    display: flex;
    gap: 15px;
    padding: 10px;
    background: var(--card-bg, #2a2a2a);
    border-radius: 8px;
    border: 1px solid var(--border-color, #333);
}

.ldr-stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
}

.ldr-filters-section {
    background: var(--card-bg, #2a2a2a);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color, #333);
}

.ldr-filter-row {
    display: flex;
    gap: 15px;
    align-items: end;
    flex-wrap: wrap;
}

/* Top row: Collection + Search bar, prominent */
.ldr-library-search-row {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color, #333);
    margin-bottom: 12px;
    flex-wrap: nowrap;
}

.ldr-library-search-row .ldr-filter-group:first-child {
    min-width: 180px;
    flex-shrink: 0;
}

.ldr-library-search-row .ldr-filter-group.ldr-library-search-group {
    flex: 1;
    min-width: 0;
}

.ldr-library-search-input {
    font-size: 1.05rem;
    padding: 0.6rem 0.85rem;
}

/* Secondary filters: single line, compact */
.ldr-library-filters-row {
    flex-wrap: nowrap;
    gap: 10px;
}

.ldr-library-filters-row .ldr-filter-group {
    flex-shrink: 0;
}

.ldr-library-filters-row label {
    font-size: 11px;
}

/* Mobile responsive: wrap search and filter rows */
@media (max-width: 768px) {
    .ldr-library-search-row {
        flex-wrap: wrap;
    }
    .ldr-library-search-row .ldr-filter-group:first-child {
        min-width: 100%;
    }
    .ldr-library-filters-row {
        flex-wrap: wrap;
        gap: 8px;
    }
    .ldr-library-filters-row .ldr-filter-group {
        flex-shrink: 1;
    }
    .ldr-library-search-input {
        font-size: 1rem;
    }
}

.ldr-filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ldr-filter-group label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary, #999);
}

/* Fix form controls for theme support */
.ldr-filter-group .form-control {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.ldr-filter-group .form-control:focus {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(var(--accent-primary-rgb), 0.2);
}

.ldr-filter-group select.form-control option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* View toggle buttons */
.ldr-view-toggle button {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.ldr-view-toggle button:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.ldr-view-toggle button.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.ldr-documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 350px), 1fr));
    gap: 20px;
}

.ldr-document-card {
    background: var(--card-bg, #2a2a2a);
    border: 1px solid var(--border-color, #333);
    border-radius: 8px;
    transition: all 0.2s;
    cursor: pointer;
}

.ldr-document-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.ldr-document-card .card-header {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.ldr-badge-arxiv {
    background: var(--error-color);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.ldr-badge-pubmed {
    background: var(--accent-tertiary);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.ldr-document-card .card-body {
    padding: 15px;
    position: relative;
}

/* Large action buttons */
.ldr-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.ldr-action-btn {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    flex: 1;
    min-width: 120px;
    justify-content: center;
}

.ldr-action-btn-pdf {
    background: var(--error-color);
    color: white;
}

.ldr-action-btn-pdf:hover {
    background: var(--error-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--error-color-rgb), 0.4);
    color: white;
    filter: brightness(0.9);
}

.ldr-action-btn-txt {
    background: var(--accent-tertiary);
    color: white;
}

.ldr-action-btn-txt:hover {
    background: var(--accent-tertiary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--accent-tertiary-rgb), 0.4);
    color: white;
    filter: brightness(0.9);
}

.ldr-action-btn-rag {
    background: var(--accent-secondary);
    color: white;
    cursor: default;
}

.ldr-action-btn-none {
    background: var(--text-muted);
    color: white;
    cursor: default;
    opacity: 0.7;
}

.ldr-doc-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.3;
}

.ldr-doc-authors {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 10px;
}

.ldr-doc-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.ldr-file-location {
    margin-top: 10px;
    padding: 10px;
    background: var(--bg-secondary, #1a1a1a);
    border-radius: 4px;
    font-size: 12px;
}

.ldr-file-location summary {
    cursor: pointer;
    user-select: none;
}

.ldr-location-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.ldr-location-info code {
    flex: 1;
    padding: 5px;
    background: var(--bg-primary, #1a1a1a);
    border-radius: 4px;
    overflow-x: auto;
    color: var(--text-primary, #e4e4e4);
}

.ldr-research-info {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
}

.ldr-document-card .card-footer {
    padding: 10px 15px;
    background: var(--bg-secondary, #1a1a1a);
    border-top: 1px solid var(--border-color, #333);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ldr-doc-tags {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.ldr-doc-actions {
    display: flex;
    gap: 8px;
}

.ldr-doc-actions button {
    background: transparent;
    border: 1px solid var(--border-color, #444);
    color: var(--text-secondary, #999);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
}

.ldr-doc-actions button:hover {
    background: var(--bg-tertiary, #333);
    color: var(--text-primary, #e4e4e4);
}

.ldr-doc-actions .ldr-btn-delete-doc:hover {
    background: rgba(var(--error-color-rgb), 0.2);
    border-color: var(--error-color);
    color: var(--error-color);
}

.ldr-doc-actions .ldr-btn-delete-blob:hover {
    background: rgba(var(--warning-color-rgb), 0.2);
    border-color: var(--warning-color);
    color: var(--warning-color);
}

.ldr-tag {
    padding: 2px 8px;
    background: var(--bg-tertiary, #333);
    border-radius: 12px;
    font-size: 11px;
    color: var(--text-secondary, #999);
}

/* List View */
.ldr-documents-list .ldr-document-card {
    display: flex;
    align-items: center;
    padding: 15px;
}

.ldr-documents-list .card-header,
.ldr-documents-list .card-body,
.ldr-documents-list .card-footer {
    border: none;
    padding: 0;
}

.ldr-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.ldr-empty-state-info {
    max-width: 600px;
    margin: 20px auto;
    text-align: left;
    background: var(--card-bg, #2a2a2a);
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--warning-color);
    color: var(--text-primary, #e4e4e4);
}

.ldr-empty-state-info p {
    margin: 10px 0;
    line-height: 1.6;
}

.ldr-empty-state-info ol {
    margin: 15px 0;
    padding-left: 25px;
}

.ldr-empty-state-info ol li {
    margin: 8px 0;
    line-height: 1.6;
}

.ldr-empty-state-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Modal */
#download-progress-modal,
#sync-library-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

/* Progress bar */
#download-progress-modal .progress-bar,
#sync-library-modal .progress-bar {
    width: 100%;
    height: 20px;
    background: var(--bg-secondary, #1a1a1a);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color, #333);
}

.ldr-progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

/* Download log */
.ldr-download-log {
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-secondary, #1a1a1a);
    border: 1px solid var(--border-color, #333);
    border-radius: 4px;
    padding: 10px;
    margin-top: 10px;
}

.ldr-download-entry {
    display: flex;
    align-items: center;
    padding: 8px;
    margin: 4px 0;
    background: var(--card-bg, #2a2a2a);
    border-radius: 4px;
    border: 1px solid var(--border-color, #333);
}

.ldr-download-entry.success {
    border-left: 3px solid var(--success-color);
}

.ldr-download-entry.failed {
    border-left: 3px solid var(--error-color);
}

.ldr-download-entry.skipped {
    border-left: 3px solid var(--warning-color);
}

.ldr-download-entry .ldr-entry-url {
    color: var(--text-muted);
    font-size: 0.85em;
    display: block;
    word-break: break-all;
}

#download-progress-modal .modal-content,
#sync-library-modal .modal-content {
    background: var(--card-bg, #2a2a2a);
    margin: 2% auto;
    padding: 20px;
    width: 90%;
    max-width: 1200px;
    border-radius: 8px;
    color: var(--text-primary, #e4e4e4);
}

#download-progress-modal .modal-header,
#sync-library-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

#download-progress-modal .modal-header .close,
#sync-library-modal .modal-header .close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary, #999);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

#download-progress-modal .modal-header .close:hover,
#sync-library-modal .modal-header .close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary, #e4e4e4);
}

/* Enhanced PDF Viewer Modal */
.ldr-pdf-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-in-out;
}

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

.ldr-pdf-modal-content {
    background: var(--bg-primary, #1a1a1a);
    margin: 20px auto;
    width: 95%;
    height: calc(100vh - 40px);
    max-width: 1600px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: ldr-slideUp 0.3s ease-out;
}

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

.ldr-pdf-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-secondary, #2a2a2a);
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ldr-pdf-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #e4e4e4);
    margin: 0;
    max-width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ldr-pdf-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ldr-pdf-action-btn,
.ldr-pdf-close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary, #a0a0a0);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.ldr-pdf-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary, #e4e4e4);
}

.ldr-pdf-close-btn:hover {
    background: rgba(var(--error-color-rgb), 0.2);
    color: var(--error-color);
}

.ldr-pdf-modal-body {
    flex: 1;
    padding: 0;
    overflow: hidden;
    background: var(--bg-tertiary);
    border-radius: 0 0 12px 12px;
}

.ldr-pdf-viewer-frame {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0 0 12px 12px;
}

/* Text viewer styles */
.ldr-text-viewer-content {
    width: 100%;
    height: 100%;
    padding: 20px;
    overflow-y: auto;
    background: var(--bg-primary, #1a1a1a);
    color: var(--text-primary, #e4e4e4);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    border-radius: 0 0 12px 12px;
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .ldr-pdf-modal-content {
        background: var(--bg-primary);
    }

    .ldr-pdf-modal-header {
        background: var(--bg-secondary);
    }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .ldr-pdf-modal-content {
        width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }

    .ldr-pdf-modal-header {
        border-radius: 0;
    }

    .ldr-pdf-modal-body,
    .ldr-pdf-viewer-frame {
        border-radius: 0;
    }
}
