/* ========================================
   PDF Viewer Enhancement Styles
   ======================================== 
   
   Extends the glass shell design system for
   PDF viewing capabilities. Provides search,
   navigation, citations, and guidance UI.
   
   Design Tokens:
   - Primary: #8b5cf6 / #a78bfa (purple)
   - Accent: #eab308 / #fde047 (yellow)
   - Surface: rgba(15, 23, 42, 0.98) (dark)
   - Glass effects: backdrop-filter blur
   
   ======================================== */

/* ========================================
   In-PDF Search Bar UI
   ======================================== */

.pdf-search-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0 0 8px 8px;
}

.pdf-search-input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 6px;
    color: #ffffff;
    font-size: 14px;
    transition: all 0.15s ease;
}

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

.pdf-search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.08);
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.pdf-search-nav {
    display: flex;
    gap: 6px;
    align-items: center;
}

.pdf-search-nav button {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-size: 14px;
    padding: 0;
}

.pdf-search-nav button:hover:not(:disabled) {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
    color: #a78bfa;
}

.pdf-search-nav button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pdf-search-count {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    font-weight: 500;
}

/* ========================================
   Page Thumbnails Rail
   ======================================== */

.page-thumbnails-rail {
    display: flex;
    flex-direction: column;
    width: 90px;
    min-width: 90px;
    background: rgba(15, 23, 42, 0.98);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 8px;
    gap: 8px;
}

.page-thumbnails-rail::-webkit-scrollbar {
    width: 4px;
}

.page-thumbnails-rail::-webkit-scrollbar-track {
    background: transparent;
}

.page-thumbnails-rail::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.page-thumbnails-rail::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.page-thumbnail {
    position: relative;
    width: 74px;
    height: 100px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.page-thumbnail:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(139, 92, 246, 0.3);
    transform: translateY(-1px);
}

.page-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.page-thumbnail .page-number {
    position: absolute;
    bottom: 4px;
    right: 4px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 4px;
    border-radius: 3px;
}

.page-thumbnail.active {
    background: rgba(139, 92, 246, 0.15);
    border-color: #a78bfa;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.3), inset 0 0 8px rgba(139, 92, 246, 0.1);
}

.page-thumbnail.active .page-number {
    background: rgba(139, 92, 246, 0.6);
    color: #ffffff;
}

.thumbnail-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.thumbnail-wrapper .page-thumbnail {
    width: 100%;
    height: auto;
}

.thumbnail-page-num {
    position: absolute;
    bottom: 4px;
    right: 4px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
}

.thumbnail-wrapper:hover .thumbnail-page-num {
    background: rgba(139, 92, 246, 0.6);
    color: #ffffff;
}

.thumbnail-wrapper .page-thumbnail.active + .thumbnail-page-num,
.page-thumbnail.active ~ .thumbnail-page-num {
    background: rgba(139, 92, 246, 0.6);
    color: #ffffff;
}

.page-thumbnail .page-number {
    display: none;
}

.page-thumbnail.active .page-number,
.page-thumbnail:hover .page-number {
    display: block;
}

/* ========================================
   Text Highlight Styles
   ======================================== */

.pdf-text-highlight {
    background-color: rgba(234, 179, 8, 0.35);
    border-radius: 2px;
    padding: 2px 3px;
    transition: all 0.15s ease;
}

.pdf-text-highlight:hover {
    background-color: rgba(234, 179, 8, 0.5);
    box-shadow: 0 0 6px rgba(234, 179, 8, 0.4);
}

.pdf-text-highlight.current {
    background-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5), inset 0 0 4px rgba(139, 92, 246, 0.3);
    animation: pulse-highlight 1.2s ease-in-out infinite;
}

@keyframes pulse-highlight {
    0%, 100% {
        box-shadow: 0 0 10px rgba(139, 92, 246, 0.5), inset 0 0 4px rgba(139, 92, 246, 0.3);
    }
    50% {
        box-shadow: 0 0 15px rgba(139, 92, 246, 0.7), inset 0 0 6px rgba(139, 92, 246, 0.4);
    }
}

/* ========================================
   Citation Link Styles with Provenance
   ======================================== */

.citation-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 20px;
    font-size: 0.75rem;
    color: #a78bfa;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    position: relative;
}

.citation-chip:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
}

.citation-chip .citation-icon {
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.citation-chip .citation-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.provenance-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(234, 179, 8, 0.15);
    border: 1px solid rgba(234, 179, 8, 0.3);
    border-radius: 4px;
    font-size: 0.65rem;
    color: #fde047;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-left: auto;
    flex-shrink: 0;
}

.provenance-badge .badge-icon {
    width: 10px;
    height: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.citation-chip:hover .provenance-badge {
    background: rgba(234, 179, 8, 0.25);
    border-color: rgba(234, 179, 8, 0.5);
}

.citation-chip .chunk-id {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(139, 92, 246, 0.2);
    border-radius: 3px;
    font-size: 0.65rem;
    font-family: 'Monaco', 'Courier New', monospace;
    margin-left: 4px;
}

/* ========================================
   User Guidance Styles
   ======================================== */

.guidance-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(
        135deg,
        rgba(139, 92, 246, 0.12) 0%,
        rgba(234, 179, 8, 0.08) 100%
    );
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-bottom: 1px solid rgba(234, 179, 8, 0.15);
    border-radius: 8px;
    margin-bottom: 16px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.guidance-banner__icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
    font-size: 12px;
}

.guidance-banner__content {
    flex: 1;
    min-width: 0;
}

.guidance-banner__title {
    margin: 0 0 4px 0;
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
}

.guidance-banner__text {
    margin: 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.5;
}

.guidance-banner__close {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 14px;
    padding: 0;
    font-weight: 600;
}

.guidance-banner__close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.7);
}

.guidance-banner.info {
    background: linear-gradient(
        135deg,
        rgba(59, 130, 246, 0.12) 0%,
        rgba(59, 130, 246, 0.06) 100%
    );
    border-color: rgba(59, 130, 246, 0.25);
}

.guidance-banner.info .guidance-banner__icon {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.guidance-banner.success {
    background: linear-gradient(
        135deg,
        rgba(34, 197, 94, 0.12) 0%,
        rgba(34, 197, 94, 0.06) 100%
    );
    border-color: rgba(34, 197, 94, 0.25);
}

.guidance-banner.success .guidance-banner__icon {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.guidance-banner.warning {
    background: linear-gradient(
        135deg,
        rgba(251, 191, 36, 0.12) 0%,
        rgba(251, 191, 36, 0.06) 100%
    );
    border-color: rgba(251, 191, 36, 0.25);
}

.guidance-banner.warning .guidance-banner__icon {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.guidance-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-left: 3px solid rgba(139, 92, 246, 0.4);
    border-radius: 6px;
    margin-bottom: 8px;
    transition: all 0.15s ease;
}

.guidance-step:hover {
    background: rgba(255, 255, 255, 0.05);
    border-left-color: #a78bfa;
}

.guidance-step.completed {
    background: rgba(34, 197, 94, 0.08);
    border-left-color: #22c55e;
}

.guidance-step__number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #a78bfa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.guidance-step.completed .guidance-step__number {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
    color: #22c55e;
}

.guidance-step.completed .guidance-step__number::after {
    content: '✓';
    position: absolute;
    font-size: 14px;
}

.guidance-step__content {
    flex: 1;
    min-width: 0;
}

.guidance-step__title {
    margin: 0 0 4px 0;
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
}

.guidance-step__description {
    margin: 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.4;
}

.guidance-step.completed .guidance-step__title {
    text-decoration: line-through;
    color: rgba(255, 255, 255, 0.5);
}

.guidance-step__action {
    margin-top: 8px;
}

.guidance-step__action button {
    padding: 6px 12px;
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 4px;
    color: #a78bfa;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 500;
}

.guidance-step__action button:hover {
    background: rgba(139, 92, 246, 0.3);
    border-color: rgba(139, 92, 246, 0.5);
}

/* ========================================
   Enhanced Citation List
   ======================================== */

.citation-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.citation-list-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 6px;
    transition: all 0.15s ease;
}

.citation-list-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(139, 92, 246, 0.3);
}

.citation-list-item__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.citation-list-item__ref {
    font-size: 12px;
    font-weight: 600;
    color: #a78bfa;
    font-family: 'Monaco', 'Courier New', monospace;
}

.citation-list-item__source {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

.citation-list-item__excerpt {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ========================================
   Accessibility & Reduced Motion
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .pdf-search-input,
    .pdf-search-nav button,
    .page-thumbnail,
    .citation-chip,
    .guidance-step,
    .citation-list-item {
        transition: none;
    }
    
    .pdf-text-highlight.current {
        animation: none;
        box-shadow: 0 0 10px rgba(139, 92, 246, 0.5), inset 0 0 4px rgba(139, 92, 246, 0.3);
    }
}

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

@media (max-width: 768px) {
    .page-thumbnails-rail {
        width: 70px;
        min-width: 70px;
        padding: 8px 6px;
    }
    
    .page-thumbnail {
        width: 58px;
        height: 80px;
    }
    
    .pdf-search-container {
        flex-wrap: wrap;
    }
    
    .pdf-search-input {
        flex-basis: 100%;
    }
    
    .citation-chip .citation-text {
        max-width: 120px;
    }
}

@media (max-width: 480px) {
    .page-thumbnails-rail {
        width: 60px;
        min-width: 60px;
    }
    
    .page-thumbnail {
        width: 50px;
        height: 70px;
    }
    
    .guidance-banner {
        padding: 12px;
        gap: 10px;
    }
    
    .guidance-banner__icon {
        width: 18px;
        height: 18px;
    }
}
