/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-small {
    padding: 8px 16px;
    font-size: 12px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Upload Section */
.upload-section {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.upload-area {
    border: 3px dashed #ccc;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #4CAF50;
    background: #f8fff8;
}

.upload-content i {
    font-size: 4rem;
    color: #ccc;
    margin-bottom: 20px;
}

.upload-content h3 {
    margin-bottom: 10px;
    color: #333;
}

.upload-content p {
    color: #666;
    margin-bottom: 20px;
}

.upload-progress {
    margin-top: 20px;
}

.progress-bar {
    background: #f0f0f0;
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    background: linear-gradient(90deg, #4CAF50, #45a049);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    color: #666;
    font-size: 14px;
}

/* Files Section */
.files-section {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 20px;
}

.section-header h2 {
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.batch-controls {
    display: flex;
    gap: 15px;
}

.files-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.file-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.file-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    border-color: #4CAF50;
}

.file-item.active {
    border-color: #4CAF50;
    background: #f8fff8;
}

.file-preview {
    width: 100%;
    height: 150px;
    background: #f0f0f0;
    border-radius: 8px;
    margin-bottom: 15px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.file-info h4 {
    margin-bottom: 5px;
    color: #333;
    font-size: 14px;
    font-weight: 600;
}

.file-info p {
    color: #666;
    font-size: 12px;
    margin-bottom: 10px;
}

.file-actions {
    display: flex;
    gap: 10px;
}

/* Viewer Section */
.viewer-section {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 20px;
}

.viewer-header h3 {
    color: #333;
}

.viewer-controls {
    display: flex;
    gap: 10px;
}

.viewer-content {
    display: flex;
    gap: 30px;
}

.pdf-canvas-container {
    flex: 1;
    position: relative;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    min-height: 600px;
    max-height: 80vh;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    overflow: auto;
    scroll-behavior: smooth;
}

/* Canvas wrapper to ensure proper positioning */
.canvas-wrapper {
    position: relative;
    display: inline-block;
    margin: 0 auto;
    transition: transform 0.1s ease;
}

/* Custom scrollbar styling */
.pdf-canvas-container::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.pdf-canvas-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

.pdf-canvas-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 6px;
    border: 2px solid #f1f1f1;
}

.pdf-canvas-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.pdf-canvas-container::-webkit-scrollbar-corner {
    background: #f1f1f1;
}

.pdf-canvas-container.zoomed {
    justify-content: flex-start;
    align-items: flex-start;
}

#pdfCanvas {
    display: block;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: crosshair;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#pdfCanvas:not(.drawing-mode) {
    cursor: default;
}

.whiteout-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: auto;  /* Allow mouse events */
    z-index: 5;
    background: transparent;
}

/* When in drawing mode, make overlay capture all mouse events */
.pdf-canvas-container.drawing-mode .whiteout-overlay {
    pointer-events: auto;
    z-index: 10;
}

.whiteout-area {
    position: absolute;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid #ff4444;
    border-radius: 4px;
    pointer-events: auto;
    cursor: move;
}

.whiteout-area:hover {
    border-color: #ff0000;
}

.whiteout-area .delete-btn {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 24px;
    height: 24px;
    background: #ff4444 !important;
    color: white !important;
    border: 2px solid white !important;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: auto !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
}

.whiteout-area .delete-btn:hover {
    background: #e74c3c !important;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.whiteout-area .delete-btn:active {
    transform: scale(0.95);
}

/* Resize handles for whiteout areas */
.resize-handle {
    position: absolute;
    background: #007bff;
    border: 1px solid white;
    border-radius: 2px;
    width: 8px;
    height: 8px;
    z-index: 999;
    pointer-events: auto;
    opacity: 0.8;
    transition: opacity 0.2s ease, background-color 0.2s ease;
}

.resize-handle:hover {
    opacity: 1;
    background: #0056b3;
    border-width: 2px;
}

.whiteout-area:hover .resize-handle {
    opacity: 1;
}

/* Hide resize handles when not hovering over whiteout area */
.whiteout-area .resize-handle {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.whiteout-area:hover .resize-handle {
    opacity: 0.8;
}

/* Specific cursor styles for resize handles */
.resize-nw { cursor: nw-resize; }
.resize-n { cursor: n-resize; }
.resize-ne { cursor: ne-resize; }
.resize-w { cursor: w-resize; }
.resize-e { cursor: e-resize; }
.resize-sw { cursor: sw-resize; }
.resize-s { cursor: s-resize; }
.resize-se { cursor: se-resize; }

.viewer-sidebar {
    width: 300px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
}

.page-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
}

/* Document navigation controls */
.document-navigation {
    margin-bottom: 30px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 2px solid #28a745;
}

.document-navigation h5 {
    margin: 0 0 10px 0;
    color: #28a745;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

.doc-nav-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
}

.doc-name {
    font-size: 12px;
    color: #666;
    text-align: center;
    font-weight: 500;
    background: #f8f9fa;
    padding: 6px 10px;
    border-radius: 4px;
    word-break: break-all;
}

#pageInfo {
    font-weight: 600;
    color: #333;
}

.zoom-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

#zoomInfo {
    font-weight: 600;
    color: #333;
    min-width: 45px;
    text-align: center;
}

.zoom-controls .btn {
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

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

/* Draw Controls */
.draw-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 2px solid #007bff;
}

.draw-controls .btn {
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.draw-controls .btn.btn-warning {
    background: #ff9800;
    border-color: #ff9800;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pdf-canvas-container.drawing-mode {
    border: 3px solid #ff9800;
    background: #fff9e6;
}

.pdf-canvas-container.drawing-mode::before {
    content: "DRAWING MODE - Click and Drag to Create Whiteout Areas";
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(255, 152, 0, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 20;
}

.whiteout-areas {
    margin-bottom: 30px;
}

.whiteout-areas h4 {
    margin-bottom: 15px;
    color: #333;
}

#whiteoutAreasList {
    margin-bottom: 10px;
}

.whiteout-item {
    background: white;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 10px;
    border-left: 4px solid #4CAF50;
}

.whiteout-item small {
    color: #666;
    display: block;
    margin-top: 5px;
}

/* Mode indicator */
.mode-indicator {
    background: #e3f2fd;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-indicator.document-specific {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.help-text {
    color: #666;
    font-style: italic;
}

.apply-options {
    background: white;
    padding: 15px;
    border-radius: 8px;
}

.apply-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    cursor: pointer;
}

/* Highlight the edit current only checkbox label */
.apply-options label[style*="margin-top"] {
    background-color: #fff3cd;
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #ffeaa7;
    font-weight: 500;
}

.file-selection h5 {
    margin-bottom: 10px;
    color: #333;
}

#fileCheckboxes {
    max-height: 200px;
    overflow-y: auto;
}

#fileCheckboxes label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 14px;
}

/* Status Messages */
.status-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.status-message {
    background: white;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-left: 4px solid #4CAF50;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

.status-message.error {
    border-left-color: #dc3545;
}

.status-message.warning {
    border-left-color: #ffc107;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    color: #333;
}

.loading-content i {
    font-size: 3rem;
    color: #4CAF50;
    margin-bottom: 20px;
}

.loading-content p {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .viewer-content {
        flex-direction: column;
    }
    
    .viewer-sidebar {
        width: 100%;
    }
    
    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .batch-controls {
        justify-content: center;
    }
    
    .files-list {
        grid-template-columns: 1fr;
    }
}

/* Remove button styles */
.file-preview {
    position: relative;
}

.btn-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    opacity: 0;
    transform: scale(0.8);
    z-index: 10;
}

.file-item:hover .btn-remove {
    opacity: 1;
    transform: scale(1);
}

.btn-remove:hover {
    background: rgba(220, 53, 69, 1);
    transform: scale(1.1);
}

.btn-remove:active {
    transform: scale(0.95);
}