/* Praxis Legal Document Editor Styles */
/* Based on Courtside.law template */

/* ===============================================
   CSS Variables
   =============================================== */
:root {
    --editor-font: 'Trebuchet MS', -apple-system, BlinkMacSystemFont, sans-serif;
    --editor-size: 10.5pt;
    --editor-line-height: 1.5;
    --editor-bg: #ffffff;
    --editor-text: #000000;
    --editor-border: #e5e7eb;
    --editor-accent: #156082;
    --toolbar-bg: #f8fafc;
    --toolbar-border: #e2e8f0;
    --button-hover: #e2e8f0;
    --button-active: #cbd5e1;
}

/* ===============================================
   Editor Container
   =============================================== */
.praxis-editor-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--editor-bg);
    border: 1px solid var(--editor-border);
    border-radius: 8px;
    overflow: hidden;
}

/* ===============================================
   Toolbar
   =============================================== */
.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 12px;
    background: var(--toolbar-bg);
    border-bottom: 1px solid var(--toolbar-border);
}

.toolbar-group {
    display: flex;
    gap: 2px;
    padding-right: 8px;
    border-right: 1px solid var(--toolbar-border);
}

.toolbar-group:last-child {
    border-right: none;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #374151;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}

.toolbar-btn:hover {
    background: var(--button-hover);
}

.toolbar-btn.active {
    background: var(--button-active);
    color: var(--editor-accent);
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.toolbar-btn svg {
    width: 16px;
    height: 16px;
}

.toolbar-select {
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--toolbar-border);
    border-radius: 4px;
    background: white;
    font-size: 13px;
}

/* ===============================================
   Editor Content Area
   =============================================== */
.editor-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.yjs-editor {
    font-family: var(--editor-font);
    font-size: var(--editor-size);
    line-height: var(--editor-line-height);
    text-align: justify;
    hyphens: auto;
    min-height: 100%;
    padding: 72pt;
    max-width: 595pt;
    margin: 0 auto;
    background: var(--editor-bg);
    color: var(--editor-text);
    outline: none;
}

/* Focus styling */
.yjs-editor:focus {
    outline: none;
}

/* ===============================================
   Typography - Legal Document Style
   =============================================== */
.yjs-editor p {
    margin: 0 0 6pt 0;
    text-align: justify;
}

.yjs-editor h1,
.yjs-editor h2,
.yjs-editor h3,
.yjs-editor h4 {
    font-family: var(--editor-font);
    text-align: justify;
    margin: 12pt 0 6pt 0;
    page-break-after: avoid;
}

.yjs-editor h1 {
    font-weight: bold;
    text-transform: uppercase;
}

.yjs-editor h2 {
    font-weight: bold;
    text-decoration: underline;
}

.yjs-editor h3 {
    font-weight: bold;
    text-decoration: underline;
}

.yjs-editor h4 {
    font-style: italic;
}

/* ===============================================
   Lists
   =============================================== */
.yjs-editor ul,
.yjs-editor ol {
    margin: 6pt 0;
    padding-left: 36pt;
}

.yjs-editor li {
    margin-bottom: 3pt;
}

/* Legal numbering style */
.yjs-editor ol {
    list-style-type: decimal;
}

.yjs-editor ol ol {
    list-style-type: lower-alpha;
}

.yjs-editor ol ol ol {
    list-style-type: lower-roman;
}

/* ===============================================
   Tables
   =============================================== */
.yjs-editor table {
    border-collapse: collapse;
    width: 100%;
    margin: 12pt 0;
}

.yjs-editor th,
.yjs-editor td {
    border: 1px solid var(--editor-text);
    padding: 6pt 8pt;
    text-align: left;
    vertical-align: top;
}

.yjs-editor th {
    font-weight: bold;
    background: #f0f0f0;
}

/* Table resize handles */
.yjs-editor .tableWrapper {
    overflow-x: auto;
}

.yjs-editor .column-resize-handle {
    position: absolute;
    right: -2px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--editor-accent);
    cursor: col-resize;
    pointer-events: auto;
}

/* Selected cells */
.yjs-editor .selectedCell::after {
    background: rgba(21, 96, 130, 0.15);
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    pointer-events: none;
}

/* ===============================================
   Block Quote
   =============================================== */
.yjs-editor blockquote {
    margin: 6pt 0;
    padding-left: 36pt;
    border-left: 3pt solid var(--editor-border);
    font-style: italic;
}

/* ===============================================
   Horizontal Rule
   =============================================== */
.yjs-editor hr {
    border: none;
    border-top: 1px solid var(--editor-text);
    margin: 12pt 0;
}

/* ===============================================
   Highlight (for defined terms)
   =============================================== */
.yjs-editor mark {
    background: #FFFDE7;
    padding: 0 2pt;
}

/* ===============================================
   Links
   =============================================== */
.yjs-editor a {
    color: #467886;
    text-decoration: underline;
}

/* ===============================================
   Collaboration Cursors
   =============================================== */
.collaboration-cursor__caret {
    position: relative;
    margin-left: -1px;
    margin-right: -1px;
    border-left: 1px solid;
    border-right: 1px solid;
    word-break: normal;
    pointer-events: none;
}

.collaboration-cursor__label {
    position: absolute;
    top: -1.4em;
    left: -1px;
    font-size: 11px;
    font-weight: 600;
    line-height: normal;
    white-space: nowrap;
    color: white;
    padding: 2px 4px;
    border-radius: 3px 3px 3px 0;
}

/* ===============================================
   Placeholder
   =============================================== */
.yjs-editor p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    float: left;
    color: #9ca3af;
    pointer-events: none;
    height: 0;
}

/* ===============================================
   Print Styles
   =============================================== */
@media print {
    .editor-toolbar {
        display: none;
    }

    .yjs-editor {
        max-width: 100%;
        padding: 0;
        margin: 72pt;
    }

    .yjs-editor p {
        orphans: 3;
        widows: 3;
    }

    .yjs-editor h1,
    .yjs-editor h2,
    .yjs-editor h3 {
        page-break-after: avoid;
    }
}