/*******************************************************************************
# LemonLDAP portal identity theme
# FR: Aligne le portail SSO sur la direction theme-identity-preview avec des
#     surfaces sombres lisibles, des accents bleu petrole/cuivre et des etats
#     clavier visibles.
# EN: Aligns the SSO portal with the theme-identity-preview direction using
#     readable dark surfaces, petroleum/copper accents and visible keyboard
#     states.
# Called by: LemonLDAP::NG portalCustomCss
# Calls: Bootstrap portal classes, LemonLDAP portal templates
*******************************************************************************/

:root {
  --identity-color-scheme: dark;
  --identity-bg: #0d1117;
  --identity-surface: #151b23;
  --identity-surface-raised: #1d2630;
  --identity-surface-muted: #26313d;
  --identity-text: #f3f7fb;
  --identity-text-muted: #c6d0dc;
  --identity-line: #465464;
  --identity-accent: #8bd8d5;
  --identity-accent-strong: #b8f0ee;
  --identity-accent-dark: #005f73;
  --identity-accent-darker: #0a3f4b;
  --identity-accent-soft: #173f45;
  --identity-signal: #ffc078;
  --identity-signal-soft: #4a321e;
  --identity-focus: #7c3aed;
  --identity-danger: #d92d20;
  --identity-radius: 7px;
  --identity-shadow: 0 18px 32px rgba(0, 0, 0, 0.48);
}

:root[data-identity-theme="light"] {
  --identity-color-scheme: light;
  --identity-bg: #f5f7fa;
  --identity-surface: #ffffff;
  --identity-surface-raised: #eef3f7;
  --identity-surface-muted: #dde7ef;
  --identity-text: #18212b;
  --identity-text-muted: #4b5a68;
  --identity-line: #b9c7d3;
  --identity-accent: #006d77;
  --identity-accent-strong: #004f59;
  --identity-accent-dark: #006d77;
  --identity-accent-darker: #004f59;
  --identity-accent-soft: #d9f0ef;
  --identity-signal: #8a4f00;
  --identity-signal-soft: #fff0d8;
  --identity-focus: #6d28d9;
  --identity-danger: #b42318;
  --identity-shadow: 0 14px 28px rgba(21, 31, 43, 0.14);
}

:root[data-identity-theme="dark"] {
  --identity-color-scheme: dark;
}

html,
body {
  min-height: 100%;
  color: var(--identity-text) !important;
  background: var(--identity-bg) !important;
  color-scheme: var(--identity-color-scheme);
}

body {
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

a {
  color: var(--identity-accent);
  text-underline-offset: 3px;
}

a:hover,
a:focus {
  color: var(--identity-accent-strong);
}

#wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 0 16px 24px;
  background: var(--identity-bg) !important;
}

#header {
  width: calc(100% + 32px);
  min-height: 82px;
  margin: 0 -16px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: minmax(44px, 1fr) auto minmax(92px, 1fr);
  align-items: center;
  background: var(--identity-surface) !important;
  border-bottom: 1px solid rgba(70, 84, 100, 0.5);
}

#header img,
#header .llng-header-logo {
  grid-column: 2;
  justify-self: center;
  max-height: 60px;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border-radius: var(--identity-radius);
  box-shadow: none !important;
}

.identity-theme-toggle {
  grid-column: 3;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 92px;
  min-height: 38px;
  padding: 7px 10px;
  color: var(--identity-text) !important;
  background: var(--identity-surface-raised) !important;
  border: 1px solid var(--identity-line) !important;
  border-radius: var(--identity-radius);
  box-shadow: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
}

.identity-theme-toggle:hover,
.identity-theme-toggle:focus {
  color: var(--identity-text) !important;
  background: var(--identity-accent-soft) !important;
  border-color: var(--identity-accent) !important;
}

.identity-theme-toggle-icon {
  width: 18px;
  min-width: 18px;
  text-align: center;
  font-size: 1rem;
  line-height: 1;
}

#logincontent,
#menucontent {
  width: 100%;
  max-width: 1120px;
  margin-top: 0;
  padding-right: 0;
  padding-left: 0;
}

#logincontent {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#logincontent > .card {
  width: 100%;
}

.card,
.navbar,
.navbar-light,
.dropdown-menu,
.modal-content,
.toast,
.list-group-item,
.popover,
.collapse.show,
.table,
.alert {
  color: var(--identity-text) !important;
  background: var(--identity-surface) !important;
  border: 1px solid var(--identity-line) !important;
  border-radius: var(--identity-radius) !important;
  box-shadow: var(--identity-shadow);
}

.navbar.bg-light,
.navbar-light.bg-light,
.bg-light {
  background-color: var(--identity-surface-raised) !important;
}

.navbar {
  min-height: 56px;
  padding: 8px 12px;
}

#menu .navbar-nav {
  gap: 4px;
}

.navbar-light .navbar-brand,
.navbar-light .navbar-nav .nav-link,
.navbar-light .navbar-nav .active > .nav-link,
.navbar-light .navbar-nav .nav-link.show,
.navbar-light .navbar-nav .nav-link:focus,
.navbar .navbar-brand,
.navbar .nav-link {
  color: var(--identity-text-muted) !important;
}

#menu li.ui-state-active,
#menu li.ui-tabs-active,
#authMenu li.ui-state-active,
#authMenu li.ui-tabs-active,
.navbar li.ui-state-active,
.navbar li.ui-tabs-active {
  background: transparent !important;
  border: 0 !important;
}

#menu li.ui-state-active > .nav-link,
#menu li.ui-tabs-active > .nav-link,
#authMenu li.ui-state-active > .nav-link,
#authMenu li.ui-tabs-active > .nav-link,
.navbar li.ui-state-active > .nav-link,
.navbar li.ui-tabs-active > .nav-link,
.navbar-light .navbar-nav .nav-link.active,
.navbar-light .navbar-nav .active > .nav-link {
  color: var(--identity-text) !important;
  background: var(--identity-accent-soft) !important;
  border: 1px solid var(--identity-accent) !important;
  border-radius: var(--identity-radius) !important;
  box-shadow: inset 0 -2px 0 var(--identity-accent) !important;
}

#menu li.ui-state-active > .nav-link span,
#menu li.ui-tabs-active > .nav-link span,
#authMenu li.ui-state-active > .nav-link span,
#authMenu li.ui-tabs-active > .nav-link span,
.navbar li.ui-state-active > .nav-link span,
.navbar li.ui-tabs-active > .nav-link span {
  color: var(--identity-text) !important;
}

.navbar-light .navbar-nav .nav-link:hover,
.navbar .nav-link:hover,
.navbar .nav-link:focus {
  color: var(--identity-text) !important;
  background: var(--identity-accent-soft);
  border-radius: var(--identity-radius);
}

.navbar .text-muted,
.text-muted,
.form-text,
.small {
  color: var(--identity-text-muted) !important;
  opacity: 1 !important;
}

.card-header,
.card-header.bg-secondary,
.bg-secondary,
.llng-category-header {
  color: var(--identity-text) !important;
  background: var(--identity-surface-muted) !important;
  border-bottom: 1px solid var(--identity-line) !important;
}

.card-title,
.catname,
.modal-title,
.dropdown-item,
.list-group-item,
.table th,
.table td {
  color: var(--identity-text) !important;
}

.card-title,
.catname {
  margin-bottom: 0;
  font-size: 1.2rem;
  line-height: 1.25;
  font-weight: 600;
}

#appslist,
#password,
#loginHistory,
#logout,
#oidcConsents {
  margin-top: 18px;
}

div.category {
  margin: 10px 0 18px;
  overflow: hidden;
  cursor: grab;
  background: var(--identity-surface) !important;
  border: 1px solid var(--identity-line) !important;
  border-radius: var(--identity-radius) !important;
  box-shadow: none;
}

div.category > .card-body,
.llng-category-body {
  background: var(--identity-surface) !important;
}

div.application,
.llng-application {
  min-height: 78px;
  margin: 8px 0 12px;
  overflow: hidden;
  background: var(--identity-surface-raised) !important;
  border: 1px solid var(--identity-line) !important;
  border-radius: var(--identity-radius) !important;
  box-shadow: none;
  transition: border-color 0.16s ease, background-color 0.16s ease, transform 0.16s ease;
}

div.application:hover,
div.application:focus-within,
.llng-application:hover,
.llng-application:focus-within {
  background: var(--identity-surface-muted) !important;
  border-color: var(--identity-accent) !important;
  transform: translateY(-1px);
}

div.application a,
div.application a:hover,
div.application a:focus {
  display: block;
  min-height: 100%;
  color: var(--identity-text) !important;
  text-decoration: none;
}

div.application .card-body,
.llng-app-card-body {
  padding: 15px 18px;
  background: transparent !important;
}

.appname {
  margin-bottom: 4px;
  color: var(--identity-text) !important;
  font-size: 1rem;
  line-height: 1.25;
  white-space: normal;
}

.appdesc {
  margin-bottom: 0 !important;
  color: var(--identity-text-muted) !important;
  font-size: 0.9rem;
  line-height: 1.35;
  white-space: normal;
}

.applogo {
  max-width: 34px;
  max-height: 34px;
}

span.applogo.fa {
  color: var(--identity-accent);
  font-size: 1.65rem;
}

.form-control,
.custom-select,
.custom-file-label,
.input-group-text,
textarea,
select {
  min-height: 38px;
  color: var(--identity-text) !important;
  background-color: var(--identity-surface-raised) !important;
  border: 1px solid var(--identity-line) !important;
}

.form-control::placeholder,
textarea::placeholder {
  color: var(--identity-text-muted);
  opacity: 1;
}

.input-group-text {
  color: var(--identity-text) !important;
  background-color: var(--identity-surface-muted) !important;
}

.input-group-text .fa {
  color: var(--identity-text-muted);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--identity-accent-dark);
}

.form-control:focus,
.custom-select:focus,
.custom-file-input:focus + .custom-file-label,
textarea:focus,
select:focus {
  color: var(--identity-text) !important;
  background-color: var(--identity-surface-muted) !important;
  border-color: var(--identity-focus) !important;
  box-shadow: 0 0 0 0.2rem rgba(124, 58, 237, 0.32) !important;
}

.btn {
  border-radius: var(--identity-radius);
  font-weight: 600;
  white-space: normal;
}

.btn-primary,
.btn-success,
.btn-primary:active,
.btn-success:active,
.btn-primary:focus,
.btn-success:focus {
  color: #ffffff !important;
  background: var(--identity-accent-dark) !important;
  border-color: var(--identity-accent) !important;
  box-shadow: none !important;
}

.btn-primary:hover,
.btn-success:hover {
  color: #ffffff !important;
  background: var(--identity-accent-darker) !important;
  border-color: var(--identity-accent-strong) !important;
}

.btn-secondary,
.btn-secondary:active,
.btn-secondary:focus {
  color: var(--identity-text) !important;
  background: var(--identity-surface-raised) !important;
  border-color: var(--identity-line) !important;
  box-shadow: none !important;
}

.btn-secondary:hover {
  color: var(--identity-text) !important;
  background: var(--identity-surface-muted) !important;
  border-color: var(--identity-accent) !important;
}

.btn-danger,
.btn-danger:active,
.btn-danger:focus {
  color: #ffffff !important;
  background: var(--identity-danger) !important;
  border-color: #ffb4ab !important;
}

.btn-danger:hover {
  color: #ffffff !important;
  background: #b42318 !important;
  border-color: #ffd8d3 !important;
}

#btn-back-to-top,
#btn-back-to-top.btn-danger,
#btn-back-to-top:active,
#btn-back-to-top:focus {
  color: #082025 !important;
  background: var(--identity-accent) !important;
  border-color: var(--identity-accent-strong) !important;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.38) !important;
}

#btn-back-to-top:hover {
  color: #06181c !important;
  background: var(--identity-accent-strong) !important;
  border-color: var(--identity-accent-strong) !important;
}

#finduserForm .form {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#finduserForm .input-group {
  width: min(100%, 420px);
  margin-right: auto;
  margin-left: auto;
  justify-content: center;
}

#finduserForm .input-group-prepend {
  width: 100%;
  display: flex;
  justify-content: center;
}

#finduserForm .input-group-prepend .form-control {
  flex: 1 1 auto;
  max-width: 360px;
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}

#finduserForm .clear-finduser-field {
  flex: 0 0 42px;
  justify-content: center;
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
}

#finduserForm br {
  display: none;
}

#finduserForm .modal-footer {
  flex-direction: column;
  align-items: center;
  justify-content: center !important;
  gap: 10px;
  padding-top: 4px;
}

#finduserbutton {
  order: 1;
  min-width: min(100%, 260px);
}

#closefinduserform {
  order: 2;
  min-width: min(100%, 180px);
  margin-right: 0 !important;
}

.alert-info {
  color: var(--identity-text) !important;
  background: var(--identity-accent-soft) !important;
  border-color: var(--identity-accent) !important;
}

.alert-warning {
  color: var(--identity-text) !important;
  background: var(--identity-signal-soft) !important;
  border-color: var(--identity-signal) !important;
}

.alert-danger {
  color: #ffd8d3 !important;
  background: #4a1713 !important;
  border-color: #ffb4ab !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
  color: var(--identity-text) !important;
  background: var(--identity-accent-soft) !important;
}

.table {
  color: var(--identity-text) !important;
  background: var(--identity-surface) !important;
}

.table thead th,
.llng-history-table thead th {
  color: var(--identity-text) !important;
  background: var(--identity-surface-muted) !important;
  border-bottom: 1px solid var(--identity-line) !important;
}

.table-bordered,
.table-bordered td,
.table-bordered th,
.llng-history-table {
  border-color: var(--identity-line) !important;
}

#loginHistory .card-body {
  overflow-x: auto;
}

#footer {
  width: calc(100% + 32px);
  height: auto !important;
  min-height: 58px;
  margin: auto -16px -24px;
  padding: 10px 16px;
  flex-shrink: 0;
  color: var(--identity-text-muted) !important;
  background: var(--identity-surface) !important;
  border-top: 1px solid var(--identity-line) !important;
  overflow: visible !important;
}

#footer *,
#footer a {
  color: var(--identity-text-muted) !important;
}

#footer a:hover,
#footer a:focus {
  color: var(--identity-accent-strong) !important;
}

#languages {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  max-height: none;
  overflow: visible;
}

img.langicon {
  width: 18px;
  height: 12px;
  object-fit: cover;
}

:focus-visible,
.btn:focus-visible,
a:focus-visible,
.nav-link:focus-visible,
.form-control:focus-visible,
.custom-select:focus-visible,
.dropdown-item:focus-visible {
  outline: 2px solid var(--identity-focus) !important;
  outline-offset: 2px;
}

@media (max-width: 768px) {
  #wrap {
    gap: 16px;
    padding: 0 12px 20px;
  }

  #header {
    width: calc(100% + 24px);
    min-height: 76px;
    margin-right: -12px;
    margin-left: -12px;
    grid-template-columns: 1fr auto 1fr;
  }

  .identity-theme-toggle {
    min-width: 42px;
    padding-right: 9px;
    padding-left: 9px;
  }

  .identity-theme-toggle-text {
    display: none;
  }

  #footer {
    width: calc(100% + 24px);
    margin-right: -12px;
    margin-bottom: -20px;
    margin-left: -12px;
  }

  .navbar {
    align-items: flex-start;
  }

  div.application .card-body,
  .llng-app-card-body {
    padding: 14px;
  }

  #languages {
    justify-content: center;
  }

  #finduserForm .input-group,
  #finduserbutton,
  #closefinduserform {
    width: 100%;
  }
}
