/* PDF Viewer Styles */

.pdf-viewer {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: #525659;
    position: relative;
    outline: none; /* Remove focus outline - keyboard nav works after clicking */
}

/* Spacer to push load button to right side of controls bar */
.pdf-controls-spacer {
    flex: 1;
}

/* Current URL display (in controls bar) */
.pdf-current-url {
    font-size: 0.8rem;
    color: #6c757d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 500px;
}

/* Load PDF button (in controls bar) */
.pdf-load-pdf-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid #0d6efd;
    border-radius: 4px;
    background-color: #0d6efd;
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    white-space: nowrap;
}

.pdf-load-pdf-btn:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

.pdf-load-pdf-btn:active {
    background-color: #0a58ca;
    border-color: #0a53be;
}

.pdf-load-pdf-btn i {
    font-size: 0.9rem;
}

.pdf-viewer-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.pdf-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background-color: #ffffff;
    color: #495057;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    padding: 0;
}

.pdf-btn:hover {
    background-color: #e9ecef;
    border-color: #ced4da;
}

.pdf-btn:active {
    background-color: #dee2e6;
}

.pdf-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pdf-page-info {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: #495057;
}

.pdf-page-input {
    width: 50px;
    height: 26px;
    text-align: center;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.85rem;
    padding: 0 4px;
}

.pdf-page-input:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.15);
}

.pdf-zoom-info {
    min-width: 45px;
    text-align: center;
    font-size: 0.85rem;
    color: #495057;
}

.pdf-separator {
    width: 1px;
    height: 20px;
    background-color: #dee2e6;
    margin: 0 4px;
}

.pdf-canvas-container {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.pdf-canvas-wrapper {
    position: relative;
    display: inline-block;
}

.pdf-canvas {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    background-color: #ffffff;
}

.pdf-annotation-layer {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
    pointer-events: none;
}

/* Text layer for native text selection */
.pdf-text-layer {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    overflow: hidden;
    line-height: 1.0;
}

.pdf-text-layer span {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
}

.pdf-titleText-mapIcon {
    position: absolute;
    color: #0d6efd;
    cursor: pointer;
    z-index: 5;
    line-height: 1;
    opacity: 0.7;
}

.pdf-titleText-mapIcon:hover {
    opacity: 1.0;
}

.pdf-text-layer span::selection {
    color: transparent;
    background: rgba(0, 100, 200, 0.3);
}

/* Custom context menu for text selection */
.pdf-context-menu {
    position: absolute;
    z-index: 30;
    background: #ffffff;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    padding: 4px 0;
    min-width: 220px;
}

.pdf-context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    font-size: 0.85rem;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
}

.pdf-context-menu-item:hover {
    background-color: #e9ecef;
}

.pdf-context-menu-item i {
    font-size: 0.9rem;
    color: #6c757d;
}

.pdf-context-menu-separator {
    height: 1px;
    background-color: #dee2e6;
    margin: 4px 0;
}

.pdf-annotation-link {
    position: absolute;
    pointer-events: auto;
    cursor: pointer;
    border-radius: 2px;
}

.pdf-annotation-link:hover {
    background-color: rgba(255, 255, 0, 0.25);
}

/* Main content area (sidebar + canvas) */
.pdf-main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* Bookmark Sidebar */
.pdf-bookmark-sidebar {
    width: 0;
    min-width: 0;
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.2s ease, min-width 0.2s ease;
}

.pdf-bookmark-sidebar.open {
    width: 220px;
    min-width: 220px;
}

.pdf-bookmark-header {
    padding: 8px 12px;
    font-weight: 600;
    font-size: 0.85rem;
    color: #495057;
    background-color: #e9ecef;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.pdf-bookmark-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.pdf-bookmark-empty {
    padding: 12px;
    color: #6c757d;
    font-size: 0.85rem;
    font-style: italic;
}

.pdf-bookmark-item {
    /* Container for label + children */
}

.pdf-bookmark-item.has-children > .pdf-bookmark-children {
    display: none;
}

.pdf-bookmark-item.has-children.expanded > .pdf-bookmark-children {
    display: block;
}

.pdf-bookmark-item.has-children.expanded > .pdf-bookmark-label .pdf-bookmark-toggle i {
    transform: rotate(90deg);
}

.pdf-bookmark-label {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #333;
    border-bottom: 1px solid #eee;
    transition: background-color 0.15s;
}

.pdf-bookmark-label:hover {
    background-color: #e9ecef;
}

.pdf-bookmark-toggle {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
}

.pdf-bookmark-toggle i {
    font-size: 0.7rem;
    transition: transform 0.15s;
}

.pdf-bookmark-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdf-bookmark-page {
    flex-shrink: 0;
    font-size: 0.7rem;
    color: #6c757d;
    background-color: #e9ecef;
    padding: 1px 5px;
    border-radius: 3px;
}

.pdf-bookmark-children {
    /* Nested children container */
}

/* Sidebar toggle button active state */
.pdf-sidebar-toggle-btn.active {
    background-color: #0d6efd;
    color: #ffffff;
    border-color: #0d6efd;
}

/* Scrollbar styling for bookmark list */
.pdf-bookmark-list::-webkit-scrollbar {
    width: 6px;
}

.pdf-bookmark-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.pdf-bookmark-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.pdf-bookmark-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.pdf-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 10;
}

.pdf-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #dee2e6;
    border-top-color: #0d6efd;
    border-radius: 50%;
    animation: pdf-spin 0.8s linear infinite;
}

@keyframes pdf-spin {
    to { transform: rotate(360deg); }
}

.pdf-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 16px 24px;
    background-color: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
    border-radius: 6px;
    text-align: center;
    z-index: 10;
}

.pdf-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 24px 32px;
    color: #6c757d;
    font-size: 1.1em;
    text-align: center;
    max-width: 400px;
}

/* PDF bookmark highlight bar - positioned at destination Y coordinate */
.pdf-highlight-bar {
    position: absolute;
    left: 0;
    right: 0;
    height: 24px;
    background: linear-gradient(
        to bottom,
        rgba(255, 193, 7, 0) 0%,
        rgba(255, 193, 7, 0.5) 20%,
        rgba(255, 193, 7, 0.5) 80%,
        rgba(255, 193, 7, 0) 100%
    );
    pointer-events: none;
    z-index: 5;
    animation: pdf-highlight-bar-fade 2s ease-out forwards;
}

@keyframes pdf-highlight-bar-fade {
    0% {
        opacity: 1;
    }
    70% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* Canvas container needs relative positioning for highlight bar */
.pdf-canvas-container {
    position: relative;
}

/* Fallback: whole page flash animation (when no position available) */
.pdf-canvas.highlight-flash {
    animation: pdf-highlight-flash 0.6s ease-out;
}

@keyframes pdf-highlight-flash {
    0% {
        box-shadow: 0 0 0 4px rgba(255, 193, 7, 0.8), 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(255, 193, 7, 0.4), 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    100% {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
}

/* Error flash animation (red) for bookmark not found, etc. */
.pdf-canvas.error-flash {
    animation: pdf-error-flash 1.2s ease-in-out;
}

@keyframes pdf-error-flash {
    0% {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    10% {
        box-shadow: inset 0 0 30px rgba(220, 53, 69, 0.4), 0 0 0 12px rgba(220, 53, 69, 0.8), 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    25% {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    40% {
        box-shadow: inset 0 0 30px rgba(220, 53, 69, 0.4), 0 0 0 12px rgba(220, 53, 69, 0.8), 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    55% {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    70% {
        box-shadow: inset 0 0 20px rgba(220, 53, 69, 0.3), 0 0 0 8px rgba(220, 53, 69, 0.6), 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    100% {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
}

/* Drag and drop overlay */
.pdf-drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(13, 110, 253, 0.12);
    border: 2px dashed rgba(13, 110, 253, 0.5);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 20;
    pointer-events: none;
    color: #0d6efd;
    font-size: 1.1em;
}

.pdf-drop-overlay i {
    font-size: 2.5em;
}

/* Warning toast message - flashes and fades out */
.pdf-warning-toast {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 16px 24px;
    background-color: #fff3cd;
    color: #664d03;
    border: 1px solid #ffecb5;
    border-radius: 6px;
    text-align: center;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
}

.pdf-warning-toast.show {
    animation: pdf-warning-flash-fade 2.5s ease-in-out forwards;
}

@keyframes pdf-warning-flash-fade {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    10% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.05);
    }
    20% {
        transform: translate(-50%, -50%) scale(1);
    }
    70% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}


/* Search Controls */
.pdf-search-group {
    display: flex;
    align-items: center;
    position: relative;
}

.pdf-search-icon {
    position: absolute;
    left: 8px;
    color: #6c757d;
    font-size: 0.8rem;
    pointer-events: none;
    z-index: 1;
}

.pdf-search-input {
    width: 150px;
    height: 26px;
    padding: 0 26px 0 26px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.8rem;
}

.pdf-search-input:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.15);
}

.pdf-search-input::placeholder {
    color: #adb5bd;
}

.pdf-search-clear {
    position: absolute;
    right: 4px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    border-radius: 3px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s, background-color 0.15s;
}

.pdf-search-clear:hover {
    background-color: #e9ecef;
    color: #495057;
}

.pdf-search-clear.visible {
    opacity: 1;
    visibility: visible;
}

.pdf-match-info {
    font-size: 0.75rem;
    color: #495057;
    min-width: 55px;
    text-align: center;
    white-space: nowrap;
}

.pdf-match-info.no-matches {
    color: #dc3545;
}

/* Search highlight overlay on canvas */
.pdf-search-highlight {
    position: absolute;
    background: rgba(255, 255, 0, 0.4);
    border: 2px solid #f0ad4e;
    border-radius: 2px;
    pointer-events: none;
    z-index: 5;
    animation: pdf-search-highlight-pulse 0.5s ease-out;
}

@keyframes pdf-search-highlight-pulse {
    0% {
        background: rgba(255, 255, 0, 0.8);
        transform: scale(1.1);
    }
    100% {
        background: rgba(255, 255, 0, 0.4);
        transform: scale(1);
    }
}
