/* brand_css base: Elastic overrides driven by --bc-* variables set per brand.
   Light selectors use "html body ..."; dark ones "html.dark-mode body ..." (beats Elastic's own dark rules). */

/* ---- typography ---- */
html body,
html body button,
html body input,
html body optgroup,
html body select,
html body textarea,
html body .popover {
  font-family: var(--bc-font);
}
html body { line-height: 1.6; }
html body * { letter-spacing: 0; }
html[lang^="ar"] body * { text-transform: none; }

/* ---- links ---- */
html body a, html body .btn-link { color: var(--bc-link); }
html body a:hover, html body .btn-link:hover { color: var(--bc-link-hover); }
html body .ui.alert a:not(.btn) { color: var(--bc-link); }

/* ---- primary buttons ---- */
html body .btn-primary,
html body .btn-primary.disabled,
html body .btn-primary:disabled,
html body .floating-action-buttons a.button {
  color: var(--bc-btn-fg);
  background: var(--bc-btn-bg);
  border-color: var(--bc-btn-bg);
}
html body .btn-primary:hover,
html body .btn-primary:focus,
html body .btn-primary:not(:disabled):not(.disabled):active,
html body .btn-primary:not(:disabled):not(.disabled).active {
  color: var(--bc-btn-fg);
  background: var(--bc-btn-hover);
  border-color: var(--bc-btn-hover);
}
html body .btn:focus,
html body .btn-primary:focus,
html body .btn-primary:not(:disabled):not(.disabled):active:focus {
  box-shadow: 0 0 0 .2rem var(--bc-ring);
}

/* ---- focus rings ---- */
html body .form-control:focus,
html body .multi-input > .content.focused,
html body .recipient-input.focus,
html body .input-group-text input:focus,
html body .custom-file-input:focus ~ .custom-file-label,
html body .custom-switch .custom-control-input:focus:not(:checked) ~ .custom-control-label::before {
  border-color: var(--bc-accent);
  box-shadow: 0 0 0 .2rem var(--bc-ring);
}

/* ---- switches, counters, menus, selection ---- */
html body .custom-switch .custom-control-input:checked ~ .custom-control-label::before {
  border-color: var(--bc-btn-bg);
  background-color: var(--bc-btn-bg);
}
html body .folderlist li.mailbox .unreadcount,
html body .folderlist li.mailbox.recent > a > .unreadcount {
  color: var(--bc-btn-fg);
  background: var(--bc-btn-bg);
}
html body .quota-widget .value { background-color: var(--bc-accent); }
html body .popupmenu .listing li.selected,
html body .popupmenu .listing li > a:not(.disabled):hover,
html body .popover .menu li a:not(.disabled):hover,
html body .popover .menu .dropbutton a.dropdown:hover,
html body .ui-menu .ui-state-active,
html body .ui-datepicker a.ui-state-active {
  color: var(--bc-btn-fg) !important;
  background-color: var(--bc-btn-bg) !important;
}
html body #messagestack .alert-info.information {
  color: var(--bc-btn-fg);
  background-color: var(--bc-btn-bg);
}
html body .listing li.selected,
html body .listing tr.selected td,
html body ul.treelist li.selected > a,
html body ul.treelist li.selected > div > a,
html body .table-widget table.options-table tr.selected td {
  color: var(--bc-sel-fg);
  background-color: var(--bc-sel-bg);
}
html body:not(.touch) .listing li > a:focus,
html body .listing.focus tbody tr.focused > td:first-child {
  border-left-color: var(--bc-accent);
}
html[dir="rtl"] body .listing li > a:focus,
html[dir="rtl"] body .listing.focus tbody tr.focused > td:first-child {
  border-left-color: transparent;
  border-right: 2px solid var(--bc-accent);
}

/* ---- left task menu ---- */
html body #layout-menu,
html body #layout-menu .popover-header,
html.layout-phone body .popover-header,
html.layout-small body .popover-header {
  background-color: var(--bc-menu-bg) !important;
}
html body #taskmenu a:hover,
html body #taskmenu a:focus,
html body #taskmenu a.selected,
html body #taskmenu a.selected:hover {
  background: var(--bc-menu-sel-bg);
}
html body #taskmenu a.selected { box-shadow: inset 3px 0 0 var(--bc-menu-accent); }
html[dir="rtl"] body #taskmenu a.selected { box-shadow: inset -3px 0 0 var(--bc-menu-accent); }
html body #taskmenu .action-buttons a,
html body #taskmenu .action-buttons a:hover { color: var(--bc-menu-accent); }
/* menu logo: real brand icon (per-brand content:url), identical 32x32 box, no silhouette filter */
html body #layout-menu .popover-header img#logo {
  width: 32px; height: 32px; max-width: 32px; max-height: 32px;
  padding: 0; object-fit: contain; filter: none; opacity: 1;
}

/* ---- dark mode: beat Elastic's html.dark-mode rules ---- */
html.dark-mode body .btn-primary,
html.dark-mode body .floating-action-buttons a.button,
html.dark-mode body .tox .tox-dialog__footer .tox-button {
  color: var(--bc-btn-fg);
  background: var(--bc-btn-bg);
  border-color: var(--bc-btn-bg);
}
html.dark-mode body .btn-primary:hover:not(:disabled),
html.dark-mode body .btn-primary:focus {
  color: var(--bc-btn-fg);
  background: var(--bc-btn-hover);
  border-color: var(--bc-btn-hover);
}
html.dark-mode body .form-control:focus:not(.is-invalid),
html.dark-mode body .custom-file-label:focus:not(.is-invalid),
html.dark-mode body .multi-input:not(.is-invalid) > .content.focused,
html.dark-mode body .recipient-input.focus,
html.dark-mode body .input-group a:focus,
html.dark-mode body .formcontent.raweditor .CodeMirror-focused {
  border-color: var(--bc-accent);
}
html.dark-mode body .custom-switch .custom-control-input:checked ~ .custom-control-label::before {
  border-color: var(--bc-btn-bg);
  background-color: var(--bc-btn-bg);
}
html.dark-mode body .listing li.selected,
html.dark-mode body .listing li.selected > a,
html.dark-mode body .listing li.selected > div > a,
html.dark-mode body .listing tr.selected td,
html.dark-mode body .messagelist tr:not(.flagged):not(.deleted).selected td.subject a,
html.dark-mode body .messagelist tr:not(.flagged):not(.deleted).selected td.subject {
  color: var(--bc-sel-fg);
  background-color: var(--bc-sel-bg);
}
html.dark-mode body #taskmenu .action-buttons a { color: var(--bc-menu-accent); }
html.dark-mode body .folderlist li.mailbox .unreadcount,
html.dark-mode body .folderlist li.mailbox.recent > a > .unreadcount {
  color: var(--bc-btn-fg);
  background-color: var(--bc-btn-bg);
}
html.dark-mode:not(.touch) ::-webkit-scrollbar-thumb { background-color: var(--bc-accent); }

/* ---- login logo: identical 240x96 box and spacing on every brand ---- */
html body.task-login #logo {
  display: block; position: relative; z-index: 2; top: 18vh; margin: 0 auto;
  transform: scale(var(--bc-logo-scale, 1));
  width: 240px; height: 96px; max-width: calc(100% - 32px); max-height: 96px;
  padding: 0; object-fit: contain; filter: none; opacity: 1;
}
html body.task-login #login-form { top: 18vh; }

/* ---- dark mode surfaces from per-brand --bc-dk-* vars ---- */
html.dark-mode body,
html.dark-mode body #layout,
html.dark-mode body #layout-content,
html.dark-mode body.task-login #layout-content { background-color: var(--bc-dk-bg); }
html.dark-mode body #layout-sidebar,
html.dark-mode body #layout-list,
html.dark-mode body #layout-list .header,
html.dark-mode body #layout-content .header,
html.dark-mode body #layout-sidebar .header,
html.dark-mode body .footer,
html.dark-mode body #layout-list .pagenav,
html.dark-mode body .searchbar,
html.dark-mode body .listing li,
html.dark-mode body .listing thead td { background-color: var(--bc-dk-surface); }
html.dark-mode body #layout-sidebar,
html.dark-mode body #layout-list,
html.dark-mode body #layout-list .header,
html.dark-mode body #layout-content .header,
html.dark-mode body .footer { border-color: var(--bc-dk-border); }
html.dark-mode body .form-control,
html.dark-mode body .input-group-text { background-color: var(--bc-dk-surface); border-color: var(--bc-dk-border); }
html.dark-mode body .listing li.selected,
html.dark-mode body .listing li.selected > a { background-color: var(--bc-sel-bg); }
html.dark-mode body .form-control:focus { background-color: var(--bc-dk-surface); }

/* ---- shared login card (same layout on every brand; colours/radius from vars) ---- */
html body.task-login,
html body.task-login #layout-content { background-color: var(--bc-page-bg, #f4f4f4); }
html body.task-login #login-form {
  display: flex; flex-direction: column; width: calc(100% - 32px); max-width: 360px;
  margin-top: -120px; padding: 140px 28px 28px; box-sizing: border-box;
  background: #fff; border: 1px solid var(--bc-card-border, #e5e5e5);
  border-top: 3px solid var(--bc-card-top, var(--bc-accent)); border-radius: var(--bc-card-radius, 12px);
  box-shadow: 0 10px 30px rgba(10, 22, 40, .10);
}
html body.task-login #login-form #login-footer {
  order: -1; margin: 0 0 20px; text-align: center; color: var(--bc-link);
  font-size: .8rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
}
html body.task-login #login-form .formbuttons { margin: 8px 0 0; }
html body.task-login #login-form .form-control,
html body.task-login #login-form .input-group-text { border-radius: var(--bc-card-radius, 12px); }
html body.task-login #login-form .formbuttons button {
  display: block; width: 100%; border-radius: var(--bc-card-radius, 12px); min-height: 44px; font-weight: 600;
}
html body.task-login #login-form .formbuttons button:hover,
html body.task-login #login-form .formbuttons button:focus {
  outline: 2px solid var(--bc-outline, var(--bc-accent)); outline-offset: 2px;
}
html.dark-mode body.task-login,
html.dark-mode body.task-login #layout-content { background-color: var(--bc-dk-bg); }
html.dark-mode body.task-login #login-form {
  background: var(--bc-dk-surface); border-color: var(--bc-dk-border);
  border-top-color: var(--bc-card-top, var(--bc-accent)); box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
html.dark-mode body.task-login #login-form .form-control,
html.dark-mode body.task-login #login-form .input-group-text,
html.dark-mode body.task-login #login-form .form-control:focus { background-color: var(--bc-dk-bg); border-color: var(--bc-dk-border); }
html.dark-mode body.task-login #login-form .form-control:focus { border-color: var(--bc-accent); }
