/* PREF Document Editor v1.3.1 - Styles */

/* ── Toggle Button ── */
.pref-editor-outer {
    margin: 20px 0;
}

.pref-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 11px 22px;
    background: #1a3a2a;
    color: #e8dfc8;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(26,58,42,0.18);
}

.pref-toggle-btn:hover {
    background: #24502e;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(26,58,42,0.28);
}

/* ── Full Screen Modal Overlay ── */
.pref-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: pref-fade-in 0.2s ease;
}

.pref-modal-overlay.is-open {
    display: flex;
    align-items: stretch;
}

@keyframes pref-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Modal Box ── */
.pref-modal {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #fff;
    animation: pref-slide-up 0.25s ease;
    overflow: hidden;
}

@keyframes pref-slide-up {
    from { transform: translateY(30px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ── Modal Header ── */
.pref-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 56px;
    min-height: 56px;
    background: #1a3a2a;
    color: #fff;
    flex-shrink: 0;
    gap: 12px;
}

.pref-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
    color: #e8dfc8;
    flex: 1;
    min-width: 0;
}

.pref-modal-title span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pref-modal-title svg {
    flex-shrink: 0;
    color: #a8c5a0;
}

.pref-modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Buttons ── */
.pref-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 7px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.18s ease;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.pref-btn-primary {
    background: #c8a84b;
    color: #1a2a1a;
}

.pref-btn-primary:hover {
    background: #d4b55a;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(200,168,75,0.35);
}

.pref-btn-secondary {
    background: rgba(255,255,255,0.12);
    color: #e8dfc8;
    border: 1px solid rgba(255,255,255,0.2);
}

.pref-btn-secondary:hover {
    background: rgba(255,255,255,0.22);
    color: #fff;
}

/* Close X button */
.pref-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: #e8dfc8;
    cursor: pointer;
    transition: all 0.18s ease;
    flex-shrink: 0;
    padding: 0;
}

.pref-modal-close:hover {
    background: rgba(220, 80, 60, 0.7);
    color: #fff;
    border-color: transparent;
}

/* ── Modal Body (editor area) ── */
.pref-modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f5f0e8;
    min-height: 0;
}

/* ── Loading ── */
.pref-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 14px;
    color: #6b7c6b;
    font-size: 14px;
    padding: 40px;
}

.pref-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid #e0d6c8;
    border-top-color: #1a3a2a;
    border-radius: 50%;
    animation: pref-spin 0.75s linear infinite;
}

@keyframes pref-spin {
    to { transform: rotate(360deg); }
}

/* ── Error ── */
.pref-error {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 12px;
    text-align: center;
    padding: 40px;
    color: #8b4a3a;
}

.pref-error svg { color: #c87a6a; }
.pref-error-msg { font-size: 15px; margin: 0; }

/* ── Quill Editor - FIXED FOR SCROLLING ── */
.pref-doc-editor-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.pref-quill-wrap {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.pref-quill-wrap.is-ready {
    display: flex;
}

.pref-quill-wrap .ql-toolbar {
    background: #f0ebe0;
    border: none;
    border-bottom: 1px solid #ddd5c0;
    padding: 8px 16px;
    flex-shrink: 0;
}

.pref-quill-wrap .ql-container {
    background: #c5c5c5;
    border: none;
    font-family: 'Georgia', serif;
    font-size: 15px;
    line-height: 1.8;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.pref-quill-wrap .ql-editor {
    padding: 48px 72px;
    max-width: 900px;
    margin: 24px auto;
    color: #1a1a1a;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    box-sizing: border-box;
    min-height: 800px;
}

/* Restore Word underlined blank spaces that Mammoth collapses. */
.pref-quill-wrap .ql-editor u {
    border-bottom: 1px solid #1a1a1a;
    text-decoration: none;
    display: inline-block;
}

/* Signature blocks rendered with monospace + non-breaking spaces.
   Quill strips table and inline-block styles, so we use a fixed-width font
   and explicit spaces to keep the signature/date columns aligned.
   The inline font-family style is converted by Quill to .ql-font-monospace. */
.pref-quill-wrap .ql-editor .pref-signature-row,
.pref-quill-wrap .ql-editor .ql-font-monospace {
    font-family: 'Courier New', 'Lucida Console', monospace;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .pref-modal-header {
        padding: 0 12px;
        height: 52px;
        min-height: 52px;
    }

    .pref-modal-title { font-size: 13px; }

    .pref-btn { padding: 7px 11px; font-size: 12px; }

    .pref-quill-wrap .ql-editor {
        padding: 24px 18px;
    }
}

/* ── Print Frame ── */
.pref-print-frame {
    display: none;
    position: absolute;
    left: -9999px;
}

/* ── Body lock when modal open ── */
body.pref-modal-open {
    overflow: hidden;
}
