/* Annotate PDF Tool */

/* Annotation Toolbar */
.annotation-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    background-color: var(--bs-body-bg);
    align-items: center;
}

.toolbar-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.toolbar-divider {
    width: 1px;
    height: 32px;
    background-color: var(--bs-border-color);
}

.tool-btn {
    width: 40px;
    height: 40px;
    padding: 0.5rem;
    border: 2px solid var(--bs-border-color);
    border-radius: 0.375rem;
    background-color: var(--bs-body-bg);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn:hover {
    border-color: var(--bs-primary);
    background-color: rgba(13, 110, 253, 0.1);
}

.tool-btn.active {
    border-color: #28a745;
    background-color: rgba(40, 167, 69, 0.15);
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.25);
}

.tool-btn img {
    width: 18px;
    height: 18px;
}

.toolbar-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toolbar-option label {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    margin-bottom: 0;
}

.toolbar-option .form-select-sm {
    width: auto;
    min-width: 70px;
}

.color-picker {
    width: 36px;
    height: 36px;
    padding: 2px;
    border: 2px solid var(--bs-border-color);
    border-radius: 0.375rem;
    cursor: pointer;
    background: none;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 0.25rem;
}

.opacity-slider {
    width: 80px;
    cursor: pointer;
}

#opacityValue {
    font-size: 0.85rem;
    min-width: 40px;
}

/* Pages List */
.pages-list-annotate {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    background-color: var(--bs-body-bg);
    max-height: 200px;
    overflow-y: auto;
}

.page-thumb {
    position: relative;
    border: 2px solid var(--bs-border-color);
    border-radius: 0.375rem;
    padding: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
    background-color: white;
}

.page-thumb:hover {
    border-color: var(--bs-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.page-thumb.active {
    border-color: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.3);
}

.page-thumb .page-badge {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.15rem 0.35rem;
    border-radius: 0.25rem;
    font-size: 0.65rem;
    font-weight: 600;
}

.page-thumb .thumb-canvas {
    width: 100%;
    display: block;
    border-radius: 0.25rem;
}

/* Page Navigation */
.page-nav-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#currentPageDisplay {
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

/* Canvas Wrapper */
.canvas-wrapper {
    position: relative;
    border: 2px solid var(--bs-border-color);
    border-radius: 0.375rem;
    background: #f5f5f5;
    padding: 1rem;
    overflow: auto;
    max-height: 600px;
}

#annotationCanvas {
    display: block;
    margin: 0 auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    background: white;
    max-width: 100%;
}

/* Text Input Container */
#textInputContainer {
    position: absolute;
    z-index: 100;
    background: white;
    border: 2px solid var(--bs-primary);
    border-radius: 0.375rem;
    padding: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#textInput {
    width: 200px;
    min-height: 60px;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.25rem;
    padding: 0.5rem;
    resize: both;
    font-family: Arial, sans-serif;
}

.text-input-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    justify-content: flex-end;
}

/* Annotations List */
.annotations-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    background-color: var(--bs-body-bg);
}

.annotation-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--bs-border-color);
    transition: background-color 0.2s;
}

.annotation-item:last-child {
    border-bottom: none;
}

.annotation-item:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.annotation-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.annotation-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.annotation-type {
    font-weight: 600;
    font-size: 0.85rem;
}

.annotation-page {
    font-size: 0.8rem;
    color: var(--bs-secondary);
    background: var(--bs-light);
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
}

.annotation-text-preview {
    font-size: 0.8rem;
    color: var(--bs-secondary);
    font-style: italic;
}

.annotation-delete {
    padding: 0.25rem 0.4rem;
    opacity: 0.7;
}

.annotation-delete:hover {
    opacity: 1;
}

.no-annotations {
    padding: 1rem;
    text-align: center;
    color: var(--bs-secondary);
    font-style: italic;
}

/* PDF Preview */
.pdf-preview-wrapper {
    width: 100%;
    height: 600px;
    border: 2px solid var(--bs-border-color);
    border-radius: 0.375rem;
    overflow: hidden;
    background-color: #525659;
}

.pdf-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.viewer-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    background-color: var(--bs-body-bg);
    padding: 1rem;
    overflow-y: auto;
    margin: 0 !important;
}

.viewer-fullscreen .pdf-preview-wrapper {
    height: calc(100vh - 100px) !important;
}

.form-label {
    user-select: none;
}

/* Dark Mode */
[data-bs-theme="dark"] .annotation-toolbar {
    border-color: rgba(255, 255, 255, 0.1);
    background-color: rgba(30, 34, 42, 0.6);
}

[data-bs-theme="dark"] .tool-btn {
    border-color: rgba(255, 255, 255, 0.15);
    background-color: rgba(22, 33, 62, 0.6);
}

[data-bs-theme="dark"] .tool-btn:hover {
    border-color: var(--bs-primary);
    background-color: rgba(13, 110, 253, 0.2);
}

[data-bs-theme="dark"] .tool-btn.active {
    border-color: #28a745;
    background-color: rgba(40, 167, 69, 0.25);
}

[data-bs-theme="dark"] .toolbar-divider {
    background-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .pages-list-annotate {
    border-color: rgba(255, 255, 255, 0.1);
    background-color: rgba(30, 34, 42, 0.6);
}

[data-bs-theme="dark"] .page-thumb {
    border-color: rgba(255, 255, 255, 0.1);
    background-color: rgba(22, 33, 62, 0.6);
}

[data-bs-theme="dark"] .canvas-wrapper {
    background: #2c2c2c;
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] #textInputContainer {
    background: #1e1e1e;
    border-color: var(--bs-primary);
}

[data-bs-theme="dark"] #textInput {
    background: #2c2c2c;
    border-color: rgba(255, 255, 255, 0.15);
    color: #fff;
}

[data-bs-theme="dark"] .annotations-list {
    border-color: rgba(255, 255, 255, 0.1);
    background-color: rgba(30, 34, 42, 0.6);
}

[data-bs-theme="dark"] .annotation-item {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .annotation-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .annotation-page {
    background: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .viewer-fullscreen {
    background-color: var(--dark-bg-primary);
}

[data-bs-theme="dark"] .pdf-preview-wrapper {
    border-color: rgba(255, 255, 255, 0.1);
    background-color: #2c2c2c;
}

[data-bs-theme="dark"] .color-picker {
    border-color: rgba(255, 255, 255, 0.2);
}

/* Responsive */
@media (max-width: 992px) {
    .annotation-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .toolbar-divider {
        width: 100%;
        height: 1px;
    }
}

@media (max-width: 768px) {
    .pages-list-annotate {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        max-height: 150px;
    }

    .canvas-wrapper {
        max-height: 450px;
        padding: 0.5rem;
    }

    .pdf-preview-wrapper {
        height: 500px;
    }

    .tool-btn {
        width: 36px;
        height: 36px;
    }

    .tool-btn img {
        width: 16px;
        height: 16px;
    }

    .toolbar-option label {
        font-size: 0.8rem;
    }

    .annotations-list {
        max-height: 150px;
    }
}

@media (max-width: 576px) {
    .pages-list-annotate {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    }

    .canvas-wrapper {
        max-height: 350px;
    }

    .pdf-preview-wrapper {
        height: 400px;
    }

    .toolbar-group {
        width: 100%;
        justify-content: flex-start;
    }

    .annotation-info {
        font-size: 0.8rem;
    }

    #textInput {
        width: 160px;
    }
}
