.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: 2.5rem; border-radius: 1rem; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); max-width: 90%; max-height: 90%; overflow-y: auto; position: relative; }
.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; }

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;
}/* Premium Legal Tech Styles */

:root {
    --legal-primary: #0f172a;
    --legal-secondary: #1e293b;
    --legal-accent: #6366f1;
    --legal-text: #f1f5f9;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar */
.custom-scroll::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scroll::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 10px;
}
.custom-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.layout-full-notes #pdf-pane {
    width: 0% !important;
    display: none !important;
}
.layout-full-notes #notes-pane {
    width: 100% !important;
}

/* Quick Links Bar Styling & Scrollbar */
#quick-links-bar {
    scrollbar-width: thin;
    scrollbar-color: #4f46e5 #1e293b;
}

#quick-links-bar::-webkit-scrollbar {
    height: 4px;
}

#quick-links-bar::-webkit-scrollbar-track {
    background: #1e293b;
}

#quick-links-bar::-webkit-scrollbar-thumb {
    background-color: #4f46e5;
    border-radius: 20px;
}

header {
    backdrop-filter: blur(12px);
    background-color: rgba(15, 23, 42, 0.9) !important;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

#quick-links-bar button {
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(4px);
}

#quick-links-bar button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px -4px rgba(79, 70, 229, 0.4);
    background-color: #6366f1 !important;
}

/* PDF Viewer Specifics */

.pdf-page-container {
    margin-bottom: 3rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: white;
    border-radius: 4px;
}

.textLayer {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    opacity: 1;
    line-height: 1.0;
    pointer-events: auto;
}

.textLayer > span {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
    z-index: 2;
}

.pdf-highlight-item {
    background-color: #fef08a;
    border-radius: 2px;
    z-index: 10;
    mix-blend-mode: multiply;
    display: inline;
}

#flag-sidebar {
    width: 42px; /* Increased to accommodate flags + scrollbar space */
    flex-shrink: 0; /* Never squash the flags */
    background: rgba(15, 23, 42, 0.03);
    border-right: 1px solid rgba(0,0,0,0.05);
    scrollbar-width: thin;
    scrollbar-gutter: stable; /* Reserve space for scrollbar so flags don't jump */
}

.pdf-page-container:hover {
    transform: translateY(-4px);
}

/* Notes Editor Styles */
#global-notes {
    min-height: 100%;
    outline: none;
    font-size: 14px;
    line-height: 1.6;
}

/* Pagination UI */
.system-page-stamp {
    pointer-events: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
}

.page-pagination-controls {
    transition: all 0.2s ease;
}

.pdf-page-container {
    position: relative;
}

#global-notes:empty:before {
    content: attr(placeholder);
    color: #94a3b8;
    font-style: italic;
}

/* Ruled Paper Effect */
.ruled-paper #global-notes {
    background-color: #fff;
    background-image: linear-gradient(#e2e8f0 1.1px, transparent 1.1px);
    background-size: 100% 32px;
    line-height: 32px;
    padding-top: 0;
}

/* Flag Animations */
.flag-item {
    width: 26px;
    height: 32px;
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 50% 85%, 0% 100%);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 4px;
    color: #000;
    font-weight: 900;
    font-size: 10px;
}

.flag-item:hover {
    transform: translateX(2px) scale(1.1);
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2));
}

/* Linked Note Style */
.linked-text {
    background-color: rgba(99, 102, 241, 0.08);
    border-bottom: 1px dashed #6366f1;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0 2px;
    border-radius: 2px;
}

.linked-text:hover {
    background-color: rgba(99, 102, 241, 0.2);
}

.note-link-sup {
    font-size: 9px;
    font-weight: 900;
    color: #4f46e5;
    margin-left: 1px;
}

/* Glassmorphic Sidebar Index */
.glass-sidebar {
    background: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(16px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.index-item:hover {
    background: rgba(99, 102, 241, 0.1) !important;
}

/* Dark Mode for Notes */
#notes-pane.dark-mode {
    background-color: #0f172a !important;
}
#notes-pane.dark-mode .bg-white {
    background-color: #0f172a !important;
}
#notes-pane.dark-mode #global-notes {
    color: #f1f5f9 !important;
    background-color: transparent !important;
}

#notes-pane.dark-mode .border-slate-200,
#notes-pane.dark-mode .border-slate-100 {
    border-color: #1e293b !important;
}
#notes-pane.dark-mode .bg-slate-50 {
    background-color: #0f172a !important; /* Matches bg-legal-900 */
    border-color: #1e293b !important;
}
#notes-pane.dark-mode .text-slate-600 {
    color: #94a3b8 !important; /* Better contrast in dark mode */
}
#notes-pane.dark-mode select {
    color: #f1f5f9 !important;
}

/* Layout Transitions */
#pdf-pane, #notes-pane {
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.layout-wide-pdf #pdf-pane { width: 75% !important; }
.layout-wide-pdf #notes-pane { width: 25% !important; }

.layout-full-pdf #notes-pane { width: 0% !important; display: none !important; }
.layout-full-pdf #pdf-pane { width: 100% !important; }

/* AI Extraction Glow */
@keyframes extraction-glow {
    0% { box-shadow: 0 0 5px rgba(99, 102, 241, 0.2); }
    50% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.6); }
    100% { box-shadow: 0 0 5px rgba(99, 102, 241, 0.2); }
}

.ai-extracting {
    animation: extraction-glow 2s infinite;
}

/* Note Ribbons */
.note-ribbon {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none; /* Hide scrollbar Firefox */
}
.note-ribbon::-webkit-scrollbar {
    display: none; /* Hide scrollbar Chrome/Safari */
}
.note-ribbon > div {
    flex-shrink: 0;
}

/* Side-by-Side scrolling for Index */
.index-open-shift {
    padding-right: 320px !important; /* Matches sidebar width */
    transition: padding-right 0.3s ease;
}
