/*
 * system-messages.css - system messages: the sign-in popup (every page, via _Layout), the message editor
 * (SystemMessages/Create, Edit) and the admin pages (Index, Details, Delete).
 *
 * Colours follow the app theme (html[data-theme="light|dark"], set by theme-toggle.js), never the OS setting.
 * site.css gives every element font-size: 14px and makes label/span/li nowrap, so message content resets both.
 */

/* ============================================
   Theme colours
   ============================================ */
:root,
:root[data-theme="light"] {
    --sysmsg-surface: #ffffff;
    --sysmsg-surface-alt: #f8f9fa;
    --sysmsg-text: #212529;
    --sysmsg-body: #343a40;
    --sysmsg-muted: #6c757d;
    --sysmsg-border: #dee2e6;
    --sysmsg-link: #166bb7;
    --sysmsg-accent: #3d7cc9;
    --sysmsg-selected: #e7f0fb;
    --sysmsg-code: rgba(0, 0, 0, 0.045);
    --sysmsg-showing: #2e7d4f;
    --sysmsg-warning: #8a5a00;
    --sysmsg-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

:root[data-theme="dark"] {
    --sysmsg-surface: #2b2b2b;
    --sysmsg-surface-alt: #333333;
    --sysmsg-text: #e8e8e8;
    --sysmsg-body: #d6d6d6;
    --sysmsg-muted: #adb5bd;
    --sysmsg-border: #4a4a4a;
    --sysmsg-link: #7fb4ff;
    --sysmsg-accent: #6ea8fe;
    --sysmsg-selected: #2f3b4c;
    --sysmsg-code: rgba(255, 255, 255, 0.07);
    --sysmsg-showing: #7cc59a;
    --sysmsg-warning: #e3b341;
    --sysmsg-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

/* ============================================
   Message content (popup, preview, Details) and the editor's text area
   ============================================ */
.sysmsg-content,
.sysmsg-editor .ql-snow .ql-editor {
    font-family: inherit;
    font-size: 15px;
    line-height: 1.55;
    color: var(--sysmsg-body);
    overflow-wrap: anywhere;
}

.sysmsg-content {
    white-space: normal;
}

.sysmsg-content *,
.sysmsg-editor .ql-snow .ql-editor * {
    font-size: inherit;
}

.sysmsg-content span,
.sysmsg-content label,
.sysmsg-content li {
    white-space: normal;
}

.sysmsg-content p,
.sysmsg-editor .ql-snow .ql-editor p {
    margin: 0;
}

.sysmsg-content h1,
.sysmsg-content h2,
.sysmsg-content h3,
.sysmsg-editor .ql-snow .ql-editor h1,
.sysmsg-editor .ql-snow .ql-editor h2,
.sysmsg-editor .ql-snow .ql-editor h3 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--sysmsg-text);
    margin: 0.7em 0 0.3em;
}

.sysmsg-content h1,
.sysmsg-editor .ql-snow .ql-editor h1 {
    font-size: 1.25em;
}

.sysmsg-content h2,
.sysmsg-editor .ql-snow .ql-editor h2 {
    font-size: 1.12em;
}

.sysmsg-content h3,
.sysmsg-editor .ql-snow .ql-editor h3 {
    font-size: 1.05em;
}

.sysmsg-content > :first-child,
.sysmsg-editor .ql-snow .ql-editor > :first-child {
    margin-top: 0;
}

.sysmsg-content ul,
.sysmsg-content ol {
    margin: 0.3em 0 0.5em;
    padding-left: 1.5em;
}

.sysmsg-content li {
    margin: 0.15em 0;
}

.sysmsg-content li.ql-indent-1 { margin-left: 1.5em; }
.sysmsg-content li.ql-indent-2 { margin-left: 3em; }
.sysmsg-content li.ql-indent-3 { margin-left: 4.5em; }

.sysmsg-content a,
.sysmsg-editor .ql-snow .ql-editor a {
    color: var(--sysmsg-link);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.sysmsg-content pre,
.sysmsg-editor .ql-snow .ql-editor pre.ql-syntax {
    font-family: Consolas, "SFMono-Regular", Menlo, monospace;
    font-size: 13px;
    line-height: 1.5;
    color: var(--sysmsg-text);
    background: var(--sysmsg-code);
    border: 0;
    border-radius: 4px;
    padding: 8px 10px;
    margin: 0.4em 0;
    white-space: pre-wrap;
    overflow-x: auto;
}

.sysmsg-content .ql-align-center { text-align: center; }
.sysmsg-content .ql-align-right { text-align: right; }
.sysmsg-content .ql-align-justify { text-align: justify; }

/* Screenshots: never wider than the message; the width attribute (Small/Medium in the editor) can only shrink them */
.sysmsg-content img,
.sysmsg-editor .ql-snow .ql-editor img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 10px 0;
    border: 1px solid var(--sysmsg-border);
    border-radius: 4px;
    box-sizing: border-box;
}

.sysmsg-content img {
    cursor: zoom-in;
}

.sysmsg-content .ql-align-center img { margin-left: auto; margin-right: auto; }
.sysmsg-content .ql-align-right img { margin-left: auto; }

/* ============================================
   Sign-in popup (jQuery UI dialog; markup in _Layout, rendering in app-shell.js)
   ============================================ */
.ui-dialog.sysmsg-dialog {
    max-width: calc(100vw - 24px);
    box-shadow: var(--sysmsg-shadow);
    /* the page font (Bootstrap's), not jQuery UI's Arial, so the popup matches the Details page */
    font-family: var(--font-family-sans-serif, inherit);
}

#SystemMessagesDialog {
    padding: 0 !important;
    background: var(--sysmsg-surface) !important;
    color: var(--sysmsg-text) !important;
}

#SystemMessages {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px 22px 20px;
}

.sysmsg-item + .sysmsg-item {
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--sysmsg-border);
}

.sysmsg-item-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.sysmsg-item-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--sysmsg-text);
    overflow-wrap: anywhere;
}

.sysmsg-item-date {
    flex: none;
    font-size: 13px;
    color: var(--sysmsg-muted);
    white-space: nowrap;
}

.sysmsg-dialog .ui-dialog-buttonpane {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 0;
    padding: 8px 12px 8px 22px;
}

.sysmsg-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
    float: none;
    margin-left: auto;
}

.sysmsg-dialog-note {
    font-size: 13px;
    color: var(--sysmsg-muted);
}

/* Full-size view of a screenshot (click an image in a message) */
.sysmsg-zoom {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.78);
    cursor: zoom-out;
}

.sysmsg-zoom-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 4px;
    background: #ffffff;
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
}

/* ============================================
   Admin pages: list, Details, Delete
   ============================================ */
.sysmsg-page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin-bottom: 18px;
}

.sysmsg-page-head h2 {
    margin: 0;
}

.sysmsg-lead {
    margin: 4px 0 0;
    color: var(--sysmsg-muted);
    white-space: normal;
}

.sysmsg-back {
    display: inline-block;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--sysmsg-muted) !important;
}

.sysmsg-back:hover {
    color: var(--sysmsg-text) !important;
}

.sysmsg-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sysmsg-table {
    margin-bottom: 0;
}

.sysmsg-table th {
    font-size: 13px;
    font-weight: 600;
    color: var(--sysmsg-muted);
    border-top: 0 !important;
    white-space: nowrap;
}

.sysmsg-table td {
    vertical-align: middle;
}

.sysmsg-table tbody tr[data-href] {
    cursor: pointer;
}

.sysmsg-col-message {
    width: 100%;
    max-width: 0;
}

.sysmsg-row-title {
    display: block;
    font-weight: 600;
    color: var(--sysmsg-text) !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sysmsg-row-excerpt {
    margin-top: 2px;
    font-size: 13px;
    color: var(--sysmsg-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sysmsg-row-images {
    margin-right: 6px;
}

.sysmsg-row-date {
    font-size: 13px;
    color: var(--sysmsg-muted);
    white-space: nowrap;
}

.sysmsg-state {
    font-size: 13px;
    color: var(--sysmsg-muted);
    white-space: nowrap;
}

.sysmsg-state::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.7;
    vertical-align: 1px;
}

.sysmsg-state.is-showing {
    color: var(--sysmsg-showing);
}

.sysmsg-state.is-hidden::before {
    background: transparent;
    box-shadow: inset 0 0 0 1px currentColor;
}

.sysmsg-row-actions {
    white-space: nowrap;
    text-align: right;
}

.sysmsg-row-actions a {
    display: inline-block;
    padding: 4px 6px;
    color: var(--sysmsg-muted) !important;
    border-radius: 4px;
}

.sysmsg-row-actions a:hover {
    color: var(--sysmsg-text) !important;
    background: var(--sysmsg-surface-alt);
}

.sysmsg-empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--sysmsg-muted);
}

.sysmsg-empty p {
    margin-bottom: 12px;
    white-space: normal;
}

/* A message shown as users see it (Details, Delete) */
.sysmsg-sheet {
    max-width: 640px;
    padding: 18px 22px 20px;
    background: var(--sysmsg-surface);
    border: 1px solid var(--sysmsg-border);
    border-radius: 6px;
}

.sysmsg-sheet.is-wide {
    max-width: 920px;
}

.sysmsg-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--sysmsg-muted);
}

.sysmsg-meta > div {
    white-space: nowrap;
}

.sysmsg-excerpt {
    margin: 6px 0 0;
    color: var(--sysmsg-muted);
    white-space: normal;
}

/* ============================================
   Create / Edit
   ============================================ */
.sysmsg-form .sysmsg-label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--sysmsg-muted);
}

.sysmsg-form .sysmsg-title-input {
    height: auto;
    padding: 8px 12px;
    font-size: 17px;
    font-weight: 500;
}

.sysmsg-form .field-validation-error {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    white-space: normal;
}

.sysmsg-note {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--sysmsg-muted);
    white-space: normal;
}

.sysmsg-note + .sysmsg-note {
    margin-top: 8px;
}

.sysmsg-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.sysmsg-quick button {
    padding: 2px 10px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--sysmsg-muted);
    background: transparent;
    border: 1px solid var(--sysmsg-border);
    border-radius: 12px;
    cursor: pointer;
}

.sysmsg-quick button:hover {
    color: var(--sysmsg-text);
    background: var(--sysmsg-surface-alt);
}

.sysmsg-form .form-check-label {
    white-space: normal;
}

/* The editor (system-message-edit.js) */
.sysmsg-editor {
    position: relative;
}

.sysmsg-editor .ql-toolbar.ql-snow {
    padding: 6px 8px;
    border-radius: 6px 6px 0 0;
}

.sysmsg-editor .ql-toolbar.ql-snow .ql-source {
    width: auto;
    padding: 0 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: Consolas, monospace;
}

.sysmsg-editor .ql-toolbar.is-source .ql-formats > :not(.ql-source) {
    opacity: 0.35;
    pointer-events: none;
}

.sysmsg-editor .ql-container.ql-snow {
    height: auto;
    min-height: 340px;
    max-height: 65vh;
    overflow-y: auto;
    border-radius: 0 0 6px 6px;
    font-family: inherit;
}

.sysmsg-editor .ql-snow .ql-editor {
    height: auto;
    min-height: 338px;
    overflow: visible;
    padding: 14px 16px 18px;
}

.sysmsg-editor .ql-snow .ql-editor img {
    cursor: pointer;
}

/* a selected image keeps its look; the outline (.sysmsg-image-frame) shows the selection instead of a blue wash */
.sysmsg-editor .ql-snow .ql-editor img::selection {
    background: transparent;
}

.sysmsg-editor .ql-snow .ql-editor.ql-blank::before {
    left: 16px;
    right: 16px;
    font-style: normal;
    color: var(--sysmsg-muted);
}

.sysmsg-editor.is-dropping .ql-container.ql-snow {
    outline: 2px dashed var(--sysmsg-accent);
    outline-offset: -6px;
}

.sysmsg-source {
    min-height: 340px;
    height: 55vh;
    padding: 10px 12px;
    font-family: Consolas, "SFMono-Regular", Menlo, monospace;
    font-size: 13px;
    line-height: 1.5;
    border-radius: 0 0 6px 6px;
    resize: vertical;
}

.sysmsg-editor-status {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    min-height: 20px;
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--sysmsg-muted);
}

.sysmsg-editor-hint {
    white-space: normal;
}

.sysmsg-editor-summary {
    flex: none;
    white-space: nowrap;
}

.sysmsg-editor-summary.is-warning {
    flex: 0 1 auto;
    color: var(--sysmsg-warning);
    white-space: normal;
    text-align: right;
}

/* Selected screenshot: outline plus the size / remove bar */
.sysmsg-image-frame {
    position: absolute;
    z-index: 3;
    box-sizing: border-box;
    border: 2px solid var(--sysmsg-accent);
    border-radius: 5px;
    pointer-events: none;
}

.sysmsg-image-bar {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--sysmsg-surface);
    border: 1px solid var(--sysmsg-border);
    border-radius: 6px;
    box-shadow: var(--sysmsg-shadow);
    pointer-events: auto;
}

.sysmsg-image-btn {
    padding: 3px 10px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--sysmsg-text);
    background: transparent;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.sysmsg-image-btn:hover:not(:disabled) {
    background: var(--sysmsg-surface-alt);
}

.sysmsg-image-btn.is-active {
    background: var(--sysmsg-selected);
    font-weight: 600;
}

.sysmsg-image-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.sysmsg-image-btn i {
    font-size: 12px;
    color: var(--sysmsg-muted);
}

.sysmsg-image-sep {
    align-self: stretch;
    width: 1px;
    margin: 2px 3px;
    background: var(--sysmsg-border);
}
