.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(15, 23, 42, 0.75); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background-color: white; padding: 1.25rem; border-radius: 1rem; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); max-width: 95%; max-height: 92%; overflow-y: auto; position: relative; }
@media (min-width: 640px) {
  .modal-content { padding: 2.5rem; max-width: 90%; max-height: 90%; }
}
.modal-close { position: absolute; top: 1.25rem; right: 1.25rem; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #64748b; transition: color 0.2s; }
.modal-close:hover { color: #0f172a; }
summary::-webkit-details-marker { display: none; }
.scrollbar-hide::-webkit-scrollbar { display: none; }

/* Custom Scrollbar for Workspaces */
.custom-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.custom-scroll::-webkit-scrollbar-track { background: transparent; }
.custom-scroll::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 20px; }
.custom-scroll-dark::-webkit-scrollbar { width: 6px; }
.custom-scroll-dark::-webkit-scrollbar-track { background: transparent; }
.custom-scroll-dark::-webkit-scrollbar-thumb { background-color: #475569; border-radius: 20px; }

/* Mobile Menu Drawer Transition & Toggle */
#mobile-drawer.open { transform: translateX(0); }
#mobile-drawer-backdrop.show { display: block; opacity: 1; pointer-events: auto; }

/* Document Reader padding correction when collapsed on mobile */
.doc-container.collapsed-mode .doc-reader-content {
    padding-left: 3.5rem !important;
}

html { scroll-behavior: smooth; }

/* Drag and Drop Styling */
.border-dashed-hover { border-color: #059669 !important; background-color: #ecfdf5 !important; }

/* Index Letter Grid styling */
.az-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.25rem; }

/* CaseLines Highlight */
.caselines-badge { background-color: #fef3c7; color: #9f1239; border: 1px solid #fda4af; padding: 0.1rem 0.4rem; border-radius: 0.25rem; font-family: monospace; font-weight: bold; font-size: 0.85rem; }
.caselines-inline-badge { background-color: #f8fafc; color: #64748b; border: 1px solid #e2e8f0; padding: 0.1rem 0.4rem; border-radius: 0.25rem; font-family: monospace; font-weight: bold; font-size: 0.75rem; }

/* Collapsible Panel Styles */
.panel-collapsed { width: 3rem !important; min-width: 3rem !important; cursor: pointer; }
.panel-collapsed > div:not(.toggle-btn-container) { display: none !important; }
.panel-collapsed:hover { background-color: #f1f5f9; }
.toggle-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 1.5rem; height: 3rem; background-color: white; border: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 50; color: #64748b; transition: all 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.toggle-btn:hover { background-color: #f8fafc; color: #0f172a; }
.toggle-left { right: -0.75rem; border-radius: 0 0.5rem 0.5rem 0; border-left: none; }
.toggle-right { left: -0.75rem; border-radius: 0.5rem 0 0 0.5rem; border-right: none; }

/* Fullscreen Workspace Styles */
.workspace-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    margin: 0 !important;
    z-index: 50 !important; /* Above header */
    background-color: #f8fafc;
    padding: 1rem !important;
    border-radius: 0 !important;
}

/* PDF.js Custom Viewer Styles - Multi-page Continuous Scroll */
.pdf-viewer-container {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    background-color: #64748b; /* Darkened from #cbd5e1 so the scrollbar is visible! */
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 0;
    overflow-y: auto !important; 
    overflow-x: auto !important; 
    gap: 20px; 
}

.pdf-page-wrapper {
    position: relative;
    background-color: white;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* The text layer must sit exactly on top of its specific canvas */
.textLayer {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    opacity: 0.2; /* Set to 0 in prod, slightly visible for debugging */
    line-height: 1.0;
}
.textLayer > span {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
}
::selection { background: rgba(190, 18, 58, 0.3); } /* Rose color selection */

/* Loading overlay for PDF */
.pdf-loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}