/**
 * Advanced PDF Preview Styles
 * Modern, responsive layout for side-by-side PDF viewing and bookmark editing
 */

/* Estilos específicos de preset removidos - agora em preset-common.css */

/* Highlight animation for new bookmarks */
.highlight-new {
    animation: highlightNew 2s ease-in-out;
    border: 2px solid #28a745 !important;
    background: linear-gradient(90deg, rgba(40, 167, 69, 0.1), transparent) !important;
}

@keyframes highlightNew {
    0% {
        background-color: rgba(40, 167, 69, 0.3);
        transform: scale(1.02);
    }
    50% {
        background-color: rgba(40, 167, 69, 0.2);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

/* Reordering animation for bookmarks list */
.reordering {
    animation: reorderList 0.8s ease-in-out;
    transform-origin: center;
}

@keyframes reorderList {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    25% {
        opacity: 0.7;
        transform: translateX(-10px);
    }
    50% {
        opacity: 0.8;
        transform: translateX(5px);
    }
    75% {
        opacity: 0.9;
        transform: translateX(-2px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Visual feedback for items being reordered */
.reordering .bookmark-item {
    transition: all 0.3s ease-in-out;
}

.advanced-preview-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #f8f9fa;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Header Styles */
.preview-header {
    background: white;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    z-index: 100;
}

.preview-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.preview-title h3 {
    margin: 0;
    color: #2c3e50;
    font-weight: 600;
    font-size: 1.25rem;
}

.unsaved-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #f39c12;
    font-size: 0.875rem;
    animation: pulse 2s infinite;
}

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

.preview-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.zoom-level {
    min-width: 50px;
    text-align: center;
    font-weight: 500;
    color: #495057;
}

/* Main Content Area */
.preview-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* PDF Viewer Panel */
.pdf-viewer-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border-right: 1px solid #e9ecef;
    overflow: hidden;
}

.pdf-viewer-header {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: center;
}

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

.page-info {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: #495057;
}

.pdf-canvas-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
    padding: 1rem;
    position: relative;
    background: #f8f9fa;
}

#pdf-canvas {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 4px;
    background: white;
}

.bookmark-highlights {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    pointer-events: none;
    z-index: 10;
}

.bookmark-highlight {
    background: linear-gradient(90deg, var(--bs-primary) 0%, transparent 100%);
    border-radius: 2px;
    animation: highlightFade 0.3s ease-out;
}

@keyframes highlightFade {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 0.7; transform: translateX(0); }
}

/* Bookmarks Panel */
.bookmarks-panel {
    width: 550px;
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bookmarks-header {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem;
}

.bookmarks-header h5 {
    margin: 0 0 1rem 0;
    color: #2c3e50;
    font-weight: 600;
}

.bookmark-filters .btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 0.25rem !important;
}

.validation-summary {
    margin-top: 1rem;
}

.validation-summary .alert {
    margin: 0;
    padding: 0.5rem 0.75rem;
}

.bookmarks-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

/* Bookmark Item Styles */
.bookmark-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    position: relative;
}

.bookmark-item:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0,123,255,0.15);
}

.bookmark-item.enabled {
    border-left: 4px solid #28a745;
}

.bookmark-item.disabled {
    border-left: 4px solid #dc3545;
    opacity: 0.7;
}

.bookmark-item.modified {
    background: linear-gradient(135deg, white 0%, #fff3cd 100%);
    border-color: #f39c12;
}

.bookmark-content {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    gap: 0.5rem;
}

.bookmark-handle {
    color: #6c757d;
    cursor: grab;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.bookmark-handle:hover {
    background: #f8f9fa;
    color: #495057;
}

.bookmark-handle:active {
    cursor: grabbing;
}

.bookmark-level {
    min-width: 65px;
}

.level-selector {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-color: #ced4da;
}

.bookmark-title-container {
    flex: 1;
    position: relative;
}

.bookmark-title-input {
    font-size: 0.875rem;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    background: transparent;
}

.bookmark-title-input:focus {
    background: white;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,0.25);
}

.bookmark-title-input.is-invalid {
    border-color: #dc3545;
    background: #fff5f5;
}

.bookmark-page {
    min-width: 50px;
}

.go-to-page {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.bookmark-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 60px;
}

.bookmark-status {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Level-specific styling with enhanced hierarchy */
.bookmark-item.level-0 {
    border-left-width: 5px;
    font-weight: 600;
    border-left-color: #007bff !important;
    background: linear-gradient(135deg, white 0%, #f8f9ff 100%);
}

/* Hierarchy symbols styling */
.hierarchy-symbol {
    transition: transform 0.2s ease;
    cursor: pointer;
}

.hierarchy-parent {
    font-weight: bold;
    color: #495057 !important;
}

.hierarchy-symbol:hover {
    transform: scale(1.2);
    color: #007bff !important;
}

.bookmark-item.level-0 .bookmark-title-input {
    font-weight: 600;
    font-size: 0.95rem;
}

.bookmark-item.level-1 {
    margin-left: 1rem;
    border-left-color: #28a745 !important;
    position: relative;
}

.bookmark-item.level-1::before {
    content: "├─";
    position: absolute;
    left: -1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-family: monospace;
    font-size: 0.8rem;
}

.bookmark-item.level-2 {
    margin-left: 2rem;
    border-left-color: #ffc107 !important;
    position: relative;
}

.bookmark-item.level-2::before {
    content: "│├─";
    position: absolute;
    left: -2rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-family: monospace;
    font-size: 0.8rem;
}

.bookmark-item.level-3 {
    margin-left: 3rem;
    border-left-color: #17a2b8 !important;
    position: relative;
}

.bookmark-item.level-3::before {
    content: "││├─";
    position: absolute;
    left: -3rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-family: monospace;
    font-size: 0.8rem;
}

.bookmark-item.level-4 {
    margin-left: 4rem;
    border-left-color: #dc3545 !important;
    position: relative;
}

.bookmark-item.level-4::before {
    content: "│││├─";
    position: absolute;
    left: -4rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-family: monospace;
    font-size: 0.8rem;
}

/* Sortable states */
.bookmark-ghost {
    opacity: 0.5;
    background: #f8f9fa;
    transform: rotate(2deg);
}

.bookmark-chosen {
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transform: scale(1.02);
}

.bookmark-drag {
    transform: rotate(5deg);
    opacity: 0.9;
}

/* Footer Styles */
.preview-footer {
    background: white;
    border-top: 1px solid #e9ecef;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bookmark-stats {
    display: flex;
    gap: 0.5rem;
}

.bookmark-stats .badge {
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .bookmarks-panel {
        width: 450px;
    }
}

@media (max-width: 1200px) {
    .bookmarks-panel {
        width: 400px;
    }
}

@media (max-width: 992px) {
    .preview-content {
        flex-direction: column;
    }
    
    .bookmarks-panel {
        width: 100%;
        height: 400px;
    }
    
    .pdf-viewer-panel {
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .preview-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .preview-controls {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .bookmark-item.level-1,
    .bookmark-item.level-2,
    .bookmark-item.level-3,
    .bookmark-item.level-4 {
        margin-left: 0.5rem;
    }
    
    .bookmark-content {
        padding: 0.5rem;
        gap: 0.25rem;
    }
    
    .bookmark-level {
        min-width: 50px;
    }
    
    .preview-header {
        padding: 0.75rem 1rem;
    }
}

/* Force light mode - override dark mode */
.advanced-preview-container {
    background: #ffffff !important;
    color: #212529 !important;
}

.preview-header,
.pdf-viewer-panel,
.bookmarks-panel,
.preview-footer {
    background: #ffffff !important;
    border-color: #e9ecef !important;
    color: #212529 !important;
}

.pdf-viewer-header,
.bookmarks-header {
    background: #f8f9fa !important;
    border-color: #e9ecef !important;
    color: #212529 !important;
}

.bookmark-item {
    background: #ffffff !important;
    border-color: #e9ecef !important;
    color: #212529 !important;
}

.bookmark-item:hover {
    border-color: #007bff !important;
    background: #ffffff !important;
}

.bookmark-title-input {
    background: transparent !important;
    color: #212529 !important;
    border-color: transparent !important;
}

.bookmark-title-input:focus {
    background: #ffffff !important;
    border-color: #007bff !important;
    color: #212529 !important;
}

.pdf-canvas-container {
    background: #f8f9fa !important;
}

#pdf-canvas {
    background: #ffffff !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
}

/* Override any dark text elements */
.preview-title h3,
.bookmarks-header h5,
.page-info,
.zoom-level {
    color: #212529 !important;
}

/* Dark mode support - now disabled */
@media (prefers-color-scheme: dark) {
    /* All dark mode styles are now overridden above */
}

/* Loading animations */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Action buttons in header */
.preview-controls .btn-group .btn {
    transition: all 0.2s ease;
}

.preview-controls .btn-group .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.preview-controls .btn-group .btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

#save-with-errors {
    background: linear-gradient(135deg, #ffc107, #ff8c00);
    border: none;
    color: white;
    font-weight: 500;
}

#save-with-errors:hover:not(:disabled) {
    background: linear-gradient(135deg, #e0a800, #e07600);
    box-shadow: 0 2px 6px rgba(255, 193, 7, 0.4) !important;
}

/* Animation for save with errors button */
@keyframes pulse-warning {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7); 
    }
    50% { 
        box-shadow: 0 0 0 10px rgba(255, 193, 7, 0); 
    }
}

#save-with-errors:not([style*="none"]) {
    animation: pulse-warning 2s infinite;
}

/* Accessibility improvements */
.bookmark-item:focus-within {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.form-check-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(0,123,255,0.25);
}

/* Print styles */
@media print {
    .advanced-preview-container {
        height: auto;
    }
    
    .preview-header,
    .preview-footer,
    .bookmark-controls {
        display: none;
    }
    
    .preview-content {
        flex-direction: row;
    }
}