/*
 * DreamIT Host layout and type overlay for SOGo 5.12.10's signed-in app.
 *
 * Colour is not done here. The palette is branding/theme/dreamit-palette.js
 * and the stylesheet generated from it replaces SOGo's theme-default.css in
 * the pilot image, so every Material component already paints in DreamIT
 * colours before this file loads. This file only refines layout, type and the
 * few states the palette cannot express: the oversized date in the top bar,
 * the current module's button, row states in the message list, the selected
 * folder, the empty reader and keyboard focus.
 *
 * Every rule targets markup that exists only after sign-in (the main toolbar,
 * the sidebar, the message list and reader), so nothing here reaches the
 * login page, which keeps its own overlay in dreamit-sogo.css.
 *
 * Text colours below are WCAG 2.1 ratios against the surface they sit on.
 */

:root {
  --app-ink: #16233F;
  --app-ink-muted: #56637D;
  --app-blue: #1A5EE0;
  --app-tint: #EEF4FF;
  --app-hover: #F4F6FA;
  --app-hairline: #E2E8F2;
}

/* Top bar ---------------------------------------------------------------- *
 * SOGo prints the weekday, month and year in a stack beside a display-size day
 * number. One quiet line reads faster and gives the toolbar back its height. */

.sg-toolbar-group-1 .sg-date-group {
  flex-direction: row !important;
  align-items: baseline !important;
  gap: 6px;
  padding: 0 4px 0 12px;
}

.sg-toolbar-group-1 .sg-date-group p {
  margin: 0;
  font-family: var(--dreamit-font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  line-height: 1;
}

.sg-toolbar-group-1 .sg-date-group .sg-day::after { content: ","; }

.sg-toolbar-group-1 .sg-date-today {
  order: -1;
  margin: 0 0 0 8px;
  font-family: var(--dreamit-font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

/* SOGo disables the button of the module you are in, which paints it as the
 * faintest icon on the bar. Show it as the current one instead. It stays
 * disabled, so it is still skipped by Tab and never fires. White on the navy
 * bar with the 14% white fill: 10.3:1. */
.sg-toolbar-group-last .md-button.md-icon-button[disabled] {
  background-color: rgba(255, 255, 255, 0.14);
  border-radius: 12px;
}

.sg-toolbar-group-last .md-button.md-icon-button[disabled] md-icon {
  color: #FFFFFF !important;
  fill: #FFFFFF !important;
}

/* Sidebar ---------------------------------------------------------------- */

md-sidenav md-toolbar.md-tall .md-subhead,
md-sidenav md-toolbar.md-tall .sg-md-title {
  font-family: var(--dreamit-font-display);
}

/* The open folder: a tint and a blue edge rather than a grey block. Ink on the
 * tint: 14.1:1. */
md-sidenav md-list-item.sg-selected,
md-sidenav .md-bg.sg-selected {
  background-color: var(--app-tint) !important;
  box-shadow: inset 3px 0 0 var(--app-blue);
}

md-sidenav md-list-item.sg-selected .md-list-item-text,
md-sidenav md-list-item.sg-selected .sg-item-name,
md-sidenav .sg-selected .md-list-item-text p {
  color: var(--app-ink) !important;
  font-weight: 600;
}

/* Message list ----------------------------------------------------------- */

md-list-item.sg-message-list-item {
  border-bottom: 1px solid var(--app-hairline);
}

md-list-item.sg-message-list-item:not(.md-bg):hover {
  background-color: var(--app-hover);
}

/* Sender and date on one line, subject below, in the DreamIT type. */
.sg-message-list-item .sg-md-subhead {
  font-family: var(--dreamit-font-body);
  font-size: 14px;
  color: var(--app-ink);
}

.sg-message-list-item .sg-md-body {
  font-family: var(--dreamit-font-body);
  font-size: 13px;
  color: var(--app-ink-muted);
}

.sg-message-list-item .sg-tile-date,
.sg-message-list-item .sg-tile-size {
  color: var(--app-ink-muted);
  font-variant-numeric: tabular-nums;
}

/* Unread: heavier sender and subject, a blue edge, and a dot before the
 * sender, so the state does not rest on weight alone. Ink on white: 15.6:1. */
md-list-item.sg-message-list-item.unread {
  box-shadow: inset 3px 0 0 var(--app-blue);
}

md-list-item.sg-message-list-item.unread .sg-md-subhead > div:first-child > span:last-child,
md-list-item.sg-message-list-item.unread .sg-tile-subject {
  color: var(--app-ink);
  font-weight: 700;
}

md-list-item.sg-message-list-item.unread .sg-md-subhead > div:first-child::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 8px 1px 0;
  border-radius: 50%;
  background: var(--app-blue);
  vertical-align: middle;
}

/* The selected row's tint comes from the palette (accent hue-2). Its edge is
 * navy, so it still reads as selected when the row is also unread. */
md-list-item.sg-message-list-item.md-bg {
  box-shadow: inset 3px 0 0 #0A1E5A;
}

/* Avatars: a tint disc and a navy glyph instead of a grey one. */
.sg-message-list-item sg-avatar-image md-icon,
.sg-message-list-item sg-avatar-image .md-avatar-icon {
  color: #0A1E5A;
  background-color: var(--app-tint);
  border-radius: 50%;
}

/* Reader ----------------------------------------------------------------- */

/* SOGo colours the empty state with an inline style from md-colors (palette
 * background 500, 1.9:1 here), hence !important. Muted ink on the reader
 * surface #EEF2F8: 5.4:1. */
[ui-view="message"] > md-content > .sg-md-title {
  color: var(--app-ink-muted) !important;
  font-family: var(--dreamit-font-body);
  font-size: 16px;
  font-weight: 500;
}

[ui-view="message"] > md-content > .sg-md-title::before {
  content: "";
  display: block;
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--app-tint) center / 28px no-repeat url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%231A5EE0'><path d='M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4-8 5-8-5V6l8 5 8-5v2z'/></svg>");
}

/* Keyboard focus ---------------------------------------------------------- *
 * One visible ring in DreamIT blue wherever focus lands by keyboard. */
md-sidenav .md-button:focus-visible,
md-toolbar .md-button:focus-visible,
md-list-item:focus-visible,
.md-fab:focus-visible {
  outline: 2px solid #266FFF;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  md-list-item.sg-message-list-item { transition: none !important; }
}
