/* SOGo interface only. Virtual-list row heights and message/editor bodies are untouched. */
/* Preferences uses a separate page and Angular view from mailboxes. */
main[ui-view="preferences"] {
    background: #ffffff;
    color: #334155;
    font-family: Arial, system-ui, sans-serif;
    font-size: 14px;
}
main[ui-view="preferences"] :is(md-sidenav, md-sidenav md-content, md-subheader) {
    background: #f8fafc !important;
    color: #334155 !important;
}
main[ui-view="preferences"] md-toolbar {
    background: #ffffff !important;
    color: #334155 !important;
    border-bottom: 1px solid #e2e8f0;
}
main[ui-view="preferences"] md-toolbar md-icon { color: #64748b !important; }
main[ui-view="preferences"] :is(.md-button.md-fab, md-checkbox.md-checked .md-icon, md-radio-button.md-checked .md-on, md-ink-bar) {
    background: #2563eb !important;
}
main[ui-view="preferences"] .md-button.md-fab md-icon { color: #ffffff !important; }
main[ui-view="preferences"] :is(md-tab-item.md-active, md-input-container.md-input-focused label) {
    color: #2563eb !important;
}
main[ui-view="preferences"] :is(md-radio-button.md-checked .md-off, md-checkbox.md-checked .md-icon, md-input-container.md-input-focused .md-input) {
    border-color: #2563eb !important;
}
main[ui-view="preferences"] md-tabs { background: #ffffff !important; }
@media (min-width: 1200px) {
    main[ui-view="preferences"] md-sidenav.md-sidenav-left:not(.sg-close) {
        width: clamp(220px, 14vw, 280px) !important;
        min-width: 220px !important;
        max-width: 280px !important;
        flex: 0 0 clamp(220px, 14vw, 280px) !important;
    }
}

/* Public login: CSS is injected by the dedicated SOGo HTTPS proxy. */
main:has(#loginContent), main:has(#loginContent) > md-content {
    background: #f8fafc !important;
    color: #334155 !important;
    font-family: Arial, system-ui, sans-serif;
}
#loginContent {
    max-width: 960px;
    margin: 32px auto;
    background: #ffffff !important;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}
#loginContent :is(.sg-logo, .sg-login) {
    background: #ffffff !important;
    color: #334155 !important;
}
#loginContent .sg-logo { background: #eff6ff !important; }
#loginContent .sg-logo img { filter: hue-rotate(90deg); }
#loginContent .sg-login-content { padding: 32px; }
#loginContent :is(label, md-icon, .password-lost-link) { color: #475569 !important; }
#loginContent md-input-container.md-input-focused :is(.md-input, .md-select-value) { border-color: #2563eb !important; }
#loginContent md-input-container.md-input-focused label { color: #2563eb !important; }
#loginContent .md-button.md-fab { background: #2563eb !important; }
#loginContent .md-button.md-fab md-icon { color: #ffffff !important; }
#loginContent md-switch.md-checked .md-thumb { background: #2563eb !important; }
#loginContent md-switch.md-checked .md-bar { background: #93c5fd !important; }
#loginContent sg-ripple:not(.md-warn) { background: #2563eb !important; }
#loginContent sg-ripple-content :is(.md-fg, md-icon) { color: #ffffff !important; }

main[ui-view="mailboxes"] md-sidenav.md-sidenav-left,
main[ui-view="mailboxes"] .sg-account-section,
main[ui-view="mailboxes"] .sg-account-section > md-content {
    background: #f8fafc !important;
    color: #334155 !important;
}

/* Angular Material mounts compose dialogs outside the mailbox main element. */
:is(md-dialog.sg-mail-editor, md-dialog:has(.sg-mail-editor), [ui-view="maileditor"]) md-toolbar {
    background: #ffffff !important;
    color: #334155 !important;
    border-bottom: 1px solid #e2e8f0;
}

:is(md-dialog.sg-mail-editor, md-dialog:has(.sg-mail-editor), [ui-view="maileditor"]) md-toolbar md-icon {
    color: #64748b !important;
}

:is(md-dialog.sg-mail-editor, md-dialog:has(.sg-mail-editor), [ui-view="maileditor"]) md-toolbar :is(input, md-select, .md-select-value) {
    background: #f8fafc !important;
    color: #334155 !important;
    font-family: Arial, system-ui, sans-serif;
    font-size: 14px;
}

.sg-mail-editor md-input-container.md-input-focused :is(.md-input, md-select .md-select-value),
.sg-mail-editor .pseudo-input-container:focus-within {
    border-color: #2563eb !important;
}

.sg-mail-editor md-input-container.md-input-focused label {
    color: #2563eb !important;
}

/* Composer progress/success ripple is a sibling of its form, outside main. */
md-dialog:has([ng-switch="editor.sendState"]) sg-ripple:not(.md-warn) {
    background: #2563eb !important;
    background-color: #2563eb !important;
}

md-dialog:has([ng-switch="editor.sendState"]) sg-ripple-content,
md-dialog:has([ng-switch="editor.sendState"]) sg-ripple-content .md-fg,
md-dialog:has([ng-switch="editor.sendState"]) sg-ripple-content md-icon {
    color: #ffffff !important;
}

md-dialog:has([ng-switch="editor.sendState"]) sg-ripple-content md-progress-circular .md-path {
    stroke: #ffffff !important;
}

:is(md-dialog.sg-mail-editor, md-dialog:has(.sg-mail-editor), [ui-view="maileditor"]) md-toolbar :is(.md-button, .md-autocomplete-clear-button, button) {
    background: transparent !important;
    color: #64748b !important;
}

@media (min-width: 1200px) {
    .asdig-resizable-pane { position: relative; overflow: visible; }
    .asdig-pane-divider {
        position: absolute;
        top: 0;
        right: -3px;
        bottom: 0;
        width: 6px;
        z-index: 50;
        cursor: col-resize;
        touch-action: none;
        user-select: none;
    }
    .asdig-pane-divider:hover,
    .asdig-pane-divider:focus-visible,
    .asdig-pane-divider.asdig-dragging { background: #2563eb; opacity: .45; }
}

@media (max-width: 1199px) {
    .asdig-pane-divider { display: none; }
}

main[ui-view="mailboxes"] md-toolbar,
main[ui-view="mailboxes"] md-sidenav .sg-toolbar,
main[ui-view="mailboxes"] .toolbar-main {
    background: #ffffff !important;
    color: #334155 !important;
    border-bottom: 1px solid #e2e8f0;
}

main[ui-view="mailboxes"] md-toolbar md-icon,
main[ui-view="mailboxes"] md-sidenav md-icon {
    color: #64748b !important;
}

main[ui-view="mailboxes"] .sg-account-section,
main[ui-view="mailboxes"] .sg-message-list-item-main,
main[ui-view="mailboxes"] .md-toolbar-tools,
main[ui-view="mailboxes"] .msg-from {
    font-family: Arial, system-ui, sans-serif;
    font-size: 14px;
}

main[ui-view="mailboxes"] .sg-mailbox-list-item {
    background: transparent !important;
    color: #334155 !important;
}

main[ui-view="mailboxes"] .sg-mailbox-list-item.sg-selected,
main[ui-view="mailboxes"] .sg-message-list-item.md-accent.md-bg {
    background: #e8f0ff !important;
    color: #15345b !important;
}

main[ui-view="mailboxes"] .sg-mailbox-list-item.sg-selected md-icon {
    color: #2563eb !important;
}

main[ui-view="mailboxes"] .sg-message-list-item-main h3,
main[ui-view="mailboxes"] .sg-message-list-item-main h4,
main[ui-view="mailboxes"] .sg-message-list-item-main p {
    font-family: Arial, system-ui, sans-serif !important;
    font-size: 14px !important;
    color: inherit !important;
}

main[ui-view="mailboxes"] .sg-message-list-item-main time,
main[ui-view="mailboxes"] .msg-date,
main[ui-view="mailboxes"] .sg-quota {
    font-family: Arial, system-ui, sans-serif;
    font-size: 12px !important;
    color: #64748b !important;
}

main[ui-view="mailboxes"] [ng-bind="viewer.message.subject"] {
    font-family: Arial, system-ui, sans-serif !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: #1e293b !important;
}

main[ui-view="mailboxes"] .md-button.md-fab {
    background: #2563eb !important;
    color: #ffffff !important;
}

main[ui-view="mailboxes"] .md-button.md-fab md-icon {
    color: #ffffff !important;
}

@media (min-width: 1200px) {
    main[ui-view="mailboxes"] md-sidenav.md-sidenav-left:not(.sg-close) {
        width: clamp(220px, 14vw, 280px) !important;
        min-width: 220px !important;
        max-width: 280px !important;
        flex: 0 0 clamp(220px, 14vw, 280px) !important;
    }

    main[ui-view="mailboxes"] .view-list:not(.view-list--close) {
        width: clamp(320px, 32vw, 540px) !important;
        flex: 0 0 clamp(320px, 32vw, 540px) !important;
    }
}
