/* ── Mail Rich Editor ─────────────────────────────────────────────────────── */

.mre-wrap {
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mre-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px 6px;
    background: #f7f7f7;
    border-bottom: 1px solid #e5e5e5;
    align-items: center;
}

.mre-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 3px 6px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    transition: background 0.1s, border-color 0.1s;
}
.mre-btn:hover {
    background: #e8e8e8;
    border-color: #ccc;
}
.mre-btn.mre-active {
    background: #d0e7ff;
    border-color: #90c0f0;
    color: #1565c0;
}
.mre-btn .material-icons {
    font-size: 15px;
}

.mre-sep {
    width: 1px;
    height: 20px;
    background: #ddd;
    margin: 0 3px;
    flex-shrink: 0;
}

.mre-select {
    font-size: 11px;
    height: 26px;
    max-width: 118px;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 0 4px;
    background: #fff;
    color: #333;
    cursor: pointer;
}
.mre-select:hover { border-color: #bbb; }

.mre-color-btn {
    position: relative;
}
.mre-inline-image-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.mre-color-btn input[type=color] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    cursor: pointer;
    padding: 0;
    border: none;
}

.mre-editor {
    flex: 1;
    min-height: 120px;
    padding: 8px 10px;
    /* Thunderbird compose ≈ 13px / ~1.2–1.25 */
    font-size: 13px;
    line-height: 1.25;
    outline: none;
    overflow-y: auto;
    word-break: break-word;
}
.mre-editor:empty:before {
    content: attr(data-placeholder);
    color: #aaa;
    pointer-events: none;
}
.mre-editor a { color: #1976d2; }
.mre-editor img.mre-inline-img {
    max-width: 100%;
    height: auto;
    cursor: pointer;
    vertical-align: bottom;
    border-radius: 2px;
}
.mre-editor img.mre-inline-img.mre-inline-img-selected {
    outline: 2px solid #1976d2;
    outline-offset: 2px;
}
.mre-img-resize-handle {
    position: fixed;
    width: 12px;
    height: 12px;
    background: #1976d2;
    border: 2px solid #fff;
    border-radius: 2px;
    cursor: nwse-resize;
    z-index: 1305;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
    display: none;
}
.mre-editor blockquote {
    border-left: 3px solid #ccc;
    margin: 6px 0;
    padding-left: 10px;
    color: #555;
}

/* Mejl compose — e-postliknande styckeavstånd (Thunderbird/Gmail: synlig lucka, inte 0.85em) */
.mre-editor p {
    margin: 0 0 0.45em 0;
    padding: 0;
}
.mre-editor p:last-child {
    margin-bottom: 0;
}
/* Chrome contenteditable skapar ibland div per rad — samma avstånd som p */
.mre-editor > div:not([data-hub-compose-suffix]) {
    margin: 0 0 0.45em 0;
}
.mre-editor > div:not([data-hub-compose-suffix]):last-child {
    margin-bottom: 0;
}
/* Studentmall / importerad HTML: samma typsnitt som compose (13px) — även kvarvarande inline style */
.mre-editor div[style*="line-height"],
.mre-editor p[style],
.mre-editor span[style],
.mre-editor div[style]:not([data-hub-compose-suffix]) {
    line-height: inherit !important;
    font-size: inherit !important;
    font-family: inherit !important;
    color: inherit !important;
    max-width: none !important;
}
/* Signatur + citat under suffix — behåll ursprunglig formatering */
.mre-editor [data-hub-compose-suffix] p[style],
.mre-editor [data-hub-compose-suffix] span[style],
.mre-editor [data-hub-compose-suffix] div[style],
.mre-editor [data-hub-compose-suffix] blockquote,
.mre-editor [data-hub-compose-suffix] blockquote * {
    font-family: revert !important;
    font-size: revert !important;
    line-height: revert !important;
    color: revert !important;
}
.mre-editor h2 {
    font-size: 15px;
    line-height: 1.25;
    margin: 0.75em 0 0.35em 0;
}
.mre-editor h2[style] {
    margin-top: 0.75em !important;
    margin-bottom: 0.35em !important;
    font-size: 15px !important;
    line-height: 1.25 !important;
}
.mre-editor [data-hub-compose-suffix] {
    margin: 0;
}
.mre-editor [data-hub-compose-suffix] p {
    margin: 0 0 0.45em 0;
}

.mre-source {
    flex: 1;
    min-height: 120px;
    padding: 8px 10px;
    font-size: 12px;
    font-family: monospace;
    border: none;
    outline: none;
    resize: none;
    background: #1e1e1e;
    color: #d4d4d4;
    display: none;
}
.mre-wrap.mre-source-mode .mre-source { display: block; }
.mre-wrap.mre-source-mode .mre-editor { display: none; }

.mre-link-popover {
    display: none;
    position: absolute;
    z-index: 9999;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
    padding: 8px;
    gap: 4px;
    flex-direction: column;
    min-width: 240px;
}
.mre-link-popover.visible { display: flex; }
.mre-link-popover input {
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 4px 6px;
    font-size: 13px;
}
.mre-link-popover .mre-link-actions {
    display: flex;
    gap: 4px;
}
.mre-link-popover .mre-link-actions button {
    flex: 1;
    padding: 3px 6px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #f7f7f7;
}
.mre-link-popover .mre-link-actions button.primary {
    background: #1976d2;
    color: #fff;
    border-color: #1565c0;
}
