/*
 * FicekEditor - the in-house TinyMCE replacement.
 *
 * Bootstrap 4 alpha in this project has no flex utilities, so the layout helpers live here.
 * Everything is designed from ~360px up: the toolbar scrolls horizontally instead of
 * wrapping into a wall of buttons, dialogs turn into bottom sheets below 900px.
 */

.fed {
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    margin-bottom: 6px;
}

.fed-hidden-source {
    display: none !important;
}

/* ---------- toolbar ---------- */

.fed-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border-bottom: 1px solid #e2e2e2;
    background: #f7f7f7;
    position: sticky;
    top: 0;
    z-index: 5;
}

.fed-toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding-right: 6px;
    margin-right: 4px;
    border-right: 1px solid #e2e2e2;
}

.fed-toolbar-group:last-child {
    border-right: 0;
}

.fed-tool {
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    color: #444;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}

.fed-tool:hover,
.fed-tool:focus {
    background: #e9e9e9;
    outline: none;
}

.fed-tool.is-active {
    background: #dce6f2;
    border-color: #b7cbe4;
    color: #17457f;
}

.fed-select {
    height: 36px;
    max-width: 130px;
    padding: 0 4px;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    font-size: 13px;
    touch-action: manipulation;
}

.fed-colors {
    display: inline-flex;
    gap: 2px;
}

.fed-color {
    width: 22px;
    height: 36px;
    padding: 0;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    touch-action: manipulation;
}

/* ---------- content ---------- */

.fed-content {
    padding: 10px 12px;
    outline: none;
    overflow-y: auto;
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.fed-content:focus {
    outline: none;
}

.fed-content table {
    max-width: 100%;
    border-collapse: collapse;
}

.fed-content table.hasborder,
.fed-content table.hasborder td,
.fed-content table.hasborder th {
    border: 1px solid #555;
}

.fed-content td,
.fed-content th {
    padding: 2px 4px;
}

/* the page break marker is a <br style="page-break-before: always"> - invisible without this */
.fed-content br[style*="page-break"] {
    display: block;
    height: 0;
    border-top: 2px dashed #b0b0b0;
    margin: 10px 0;
}

.fed-content .btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    background-color: #396394;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
}

/* ---------- document "paper" look ---------- */

/*
 * Port of the .ieditor rules from www/front/css/main.css. The half of them that mattered
 * for typography was scoped to .ieditor.mce-content-body, so it only ever applied while
 * TinyMCE was attached - hence the copy rather than a reuse of the original class.
 */

.fed-content.fed-paper {
    padding: 40px calc((100% - 625px) / 2);
    background-color: #fff;
    box-shadow: 0 0 11px rgba(0, 0, 0, .3);
    font-family: Calibri, Arial, sans-serif;
    font-size: 15px;
    color: #000;
}

.fed-content.fed-paper p {
    margin: 0;
}

.fed-content.fed-paper h1,
.fed-content.fed-paper h2,
.fed-content.fed-paper h3,
.fed-content.fed-paper h4,
.fed-content.fed-paper h5,
.fed-content.fed-paper h6 {
    margin: 10px 0;
    color: #000;
    font-weight: 700;
    text-align: left;
}

.fed-content.fed-paper h1 { font-size: 23px; }
.fed-content.fed-paper h2 { font-size: 20px; }
.fed-content.fed-paper h3 { font-size: 17px; }
.fed-content.fed-paper h5 { font-size: 13px; }
.fed-content.fed-paper h6 { font-size: 10px; }

.fed-content.fed-paper table {
    margin-top: 0;
    border: 0;
}

.fed-content.fed-paper table td,
.fed-content.fed-paper table th,
.fed-content.fed-paper table tr {
    border: 1px dashed #bbb;
    font-size: 15px;
}

.fed-content.fed-paper table td.hasborder,
.fed-content.fed-paper table th.hasborder,
.fed-content.fed-paper table.hasborder td,
.fed-content.fed-paper table.hasborder th {
    border: 1px solid #000;
}

.fed-content.fed-paper ol,
.fed-content.fed-paper ul {
    margin-top: 15px;
    margin-bottom: 15px;
}

@media (max-width: 1000px) {
    .fed-content.fed-paper {
        padding: 20px;
        overflow: auto;
    }
}

.fed-status-spell {
    color: #c07000;
}

.fed-status {
    padding: 4px 12px;
    border-top: 1px solid #eee;
    background: #fafafa;
    color: #777;
    font-size: 12px;
    min-height: 22px;
}

/* ---------- spellcheck ---------- */

/* missing diacritics - we know the correct form */
::highlight(fed-spell) {
    text-decoration: underline wavy #e67e22;
    text-decoration-skip-ink: none;
}

/* word the dictionary does not know at all - usually a typo, sometimes a proper noun */
::highlight(fed-spell-unknown) {
    text-decoration: underline dotted #c0392b;
    text-decoration-skip-ink: none;
}

.fed-spell-note {
    padding: 6px 10px 2px;
    color: #999;
    font-size: 11px;
    text-transform: uppercase;
}

.fed-spell-popover {
    position: fixed;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    min-width: 160px;
    max-width: 260px;
    padding: 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}

.fed-spell-suggestion,
.fed-spell-action {
    padding: 8px 10px;
    border: 0;
    background: transparent;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
    touch-action: manipulation;
}

.fed-spell-suggestion {
    font-weight: 600;
    color: #17457f;
}

.fed-spell-action {
    color: #777;
    font-size: 12px;
}

.fed-spell-suggestion:hover,
.fed-spell-action:hover {
    background: #f0f0f0;
}

/* ---------- dialog ---------- */

.fed-dialog-scrim {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1070;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .4);
}

.fed-dialog {
    width: 420px;
    max-width: calc(100% - 24px);
    max-height: calc(100% - 24px);
    overflow-y: auto;
    padding: 16px;
    border-radius: 4px;
    background: #fff;
}

.fed-dialog-title {
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 600;
}

.fed-dialog-field {
    display: block;
    margin-bottom: 10px;
}

.fed-dialog-field > span {
    display: block;
    margin-bottom: 3px;
    color: #666;
    font-size: 12px;
}

.fed-dialog-field input,
.fed-dialog-field select,
.fed-dialog-field textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 14px;
}

.fed-dialog-field textarea {
    font-family: monospace;
    font-size: 12px;
}

.fed-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.fed-btn {
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    touch-action: manipulation;
}

.fed-btn-primary {
    border-color: #396394;
    background: #396394;
    color: #fff;
}

/* ---------- phones and small tablets ---------- */

@media (max-width: 900px) {
    .fed-dialog-scrim {
        align-items: flex-end;
    }

    .fed-dialog {
        width: 100%;
        max-width: 100%;
        max-height: 85%;
        border-radius: 12px 12px 0 0;
    }

    .fed-dialog-actions .fed-btn {
        flex: 1 1 auto;
    }
}

@media (max-width: 600px) {
    /* one scrollable row beats a toolbar that eats half the screen */
    .fed-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .fed-toolbar-group {
        flex: 0 0 auto;
    }

    .fed-select {
        max-width: 100px;
    }
}

@media (pointer: coarse) {
    /* iOS zooms the page in when a focused field is under 16px */
    .fed-content,
    .fed-dialog-field input,
    .fed-dialog-field select,
    .fed-dialog-field textarea {
        font-size: 16px;
    }
}
