/* Viewer-specific CSS for Historical Document Viewer */

/* Tool Panel */
.tool-panel {
    width: var(--tool-panel-width);
    background-color: var(--tool-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    align-items: center;
    z-index: 20; /* Ensure it's above other elements but below modals */
}

.tool-button {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    padding: 0;
    font-size: 1.25rem;
    background-color: var(--secondary-bg);
    color: var(--primary-text);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.tool-button:hover {
    background-color: var(--accent-color);
    color: white;
    transform: translateY(-2px);
}

.tool-button.active {
    background-color: var(--accent-color);
    color: white;
}

/* Document Panel */
.document-panel {
    flex: 3;
    overflow: hidden;
    position: relative;
    background-color: var(--document-bg);
}

.document-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center; /* Changed to center for better positioning */
    padding: 1rem;
}

#document-image {
    max-width: 96%; /* Reduced slightly to avoid edge hugging */
    max-height: 90vh; /* Set max height to ensure visibility */
    height: auto;
    cursor: move;
    transition: transform 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); /* Add subtle shadow for depth */
}

.transform-container {
    position: relative;
    transform-origin: top left;
}

.highlight-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.text-region-highlight {
    position: absolute;
    background-color: var(--highlight-color);
    border: 1px dashed rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.text-region-highlight.active {
    background-color: rgba(255, 200, 0, 0.4); /* Brighter highlight for active regions */
    border: 1px solid rgba(0, 0, 0, 0.5);
}

.text-region-highlight.pulsate {
    animation: pulsate 1.5s ease-in-out infinite;
}

@keyframes pulsate {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* Transcription Panel */
.transcription-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-color);
    background-color: var(--secondary-bg);
}

.panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--header-bg);
}

.page-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-nav-button {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.transcription-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    line-height: 1.8; /* Increased line height for better readability */
}

.transcription-line {
    margin-bottom: 0.5rem;
    padding: 0.25rem 0.5rem; /* Added horizontal padding */
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.15s ease;
}

.transcription-line:hover {
    background-color: var(--highlight-color);
}

.transcription-line.active {
    background-color: var(--highlight-color);
    font-weight: bold;
}

/* Document collection item */
.collection-item {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    background-color: var(--secondary-bg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.collection-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px var(--shadow-color);
}

.collection-thumbnail {
    width: 100%;
    height: 200px; /* Increased height */
    object-fit: contain; /* Changed to contain to avoid cropping */
    border-bottom: 1px solid var(--border-color);
    background-color: var(--document-bg);
    padding: 0.5rem;
}

.collection-item-info {
    padding: 0.75rem;
}

.collection-item-title {
    font-size: 0.95rem; /* Larger font size */
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.collection-item-meta {
    font-size: 0.8rem;
    color: var(--secondary-text);
}

/* Zoom controls */
.zoom-level {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    box-shadow: 0 2px 4px var(--shadow-color);
    z-index: 10;
}

/* View mode styles */
.content-container.document-only .transcription-panel {
    display: none;
}

.content-container.document-only .document-panel {
    flex: 1;
}

.content-container.transcription-only .document-panel {
    display: none;
}

.content-container.transcription-only .transcription-panel {
    flex: 1;
}

/* Media queries for responsive layout */
@media (max-width: 900px) {
    .document-panel {
        flex: 2;
    }

    .transcription-panel {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .document-panel, .transcription-panel {
        flex: none;
        height: 50%;
    }

    .transcription-panel {
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .tool-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        justify-content: center;
        padding: 0.5rem 0;
        z-index: 40;
        border-top: 1px solid var(--border-color);
        border-right: none;
    }

    .tool-button {
        margin: 0 0.5rem;
    }
    
    #document-image {
        max-height: 45vh; /* Adjust for mobile view */
    }
}