/*
 * Login surface presentation. Ported from the Keycloak theme
 * (backbone-infrastructure/sso/themes/euromedical/login/resources/css/euromedical.css)
 * onto our own markup; tokens and fonts come from @euromedical/ui at build time.
 */
html, body { min-height: 100%; }

body {
  background: var(--em-color-canvas);
  color: var(--em-color-text);
  font-family: var(--em-font-sans);
  font-size: var(--em-font-size-md);
  line-height: var(--em-line-height-body);
  margin: 0;
}

*, *::before, *::after { box-sizing: border-box; }

.em-page {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100svh;
  padding: 5rem var(--em-space-6);
  position: relative;
}

.em-brand {
  align-items: center;
  color: var(--em-color-text);
  display: flex;
  font-size: var(--em-font-size-sm);
  font-weight: 550;
  gap: var(--em-space-2);
  left: var(--em-space-8);
  letter-spacing: -0.01em;
  margin: 0;
  position: absolute;
  top: var(--em-space-6);
}

.em-brand::before {
  align-items: center;
  background: var(--em-color-brand);
  border-radius: var(--em-radius-sm);
  color: var(--em-color-on-brand);
  content: "e.";
  display: inline-flex;
  font-size: var(--em-font-size-lg);
  height: 1.75rem;
  justify-content: center;
  line-height: 1;
  width: 1.75rem;
}

.em-card {
  color: var(--em-color-text);
  margin: 0;
  max-width: 23rem;
  padding: var(--em-space-8) 0;
  width: 100%;
}

.em-card-header { margin: 0 0 var(--em-space-8); padding: 0; text-align: left; }

.em-title {
  color: var(--em-color-text);
  font-size: 1.5rem;
  font-weight: 550;
  letter-spacing: -0.035em;
  line-height: var(--em-line-height-tight);
  margin: 0;
}

.em-subtitle {
  color: var(--em-color-text-muted);
  font-size: var(--em-font-size-sm);
  margin: var(--em-space-3) 0 0;
}

.em-form { margin: 0; }
.em-field { margin: 0 0 var(--em-space-5); }

.em-label {
  color: var(--em-color-text-muted);
  display: inline-block;
  font-size: var(--em-font-size-sm);
  font-weight: 500;
  line-height: var(--em-line-height-tight);
  margin-bottom: var(--em-space-2);
}

.em-input {
  background: var(--em-color-surface);
  border: 1px solid var(--em-color-border-strong);
  border-radius: var(--em-radius-sm);
  box-shadow: none;
  color: var(--em-color-text);
  display: block;
  font: inherit;
  height: 2.5rem;
  min-height: 2.5rem;
  padding: var(--em-space-2) var(--em-space-3);
  transition: border-color var(--em-duration-fast) var(--em-ease-standard), box-shadow var(--em-duration-fast) var(--em-ease-standard);
  width: 100%;
}

.em-input:hover { border-color: var(--em-color-text-muted); }

.em-input:focus, .em-theme-trigger:focus-visible, button:focus-visible, a:focus-visible {
  border-color: var(--em-color-focus);
  box-shadow: var(--em-focus-ring);
  outline: 0;
}

.em-input::placeholder { color: var(--em-color-text-subtle); opacity: 1; }
.em-input[aria-invalid="true"] { border-color: var(--em-color-danger); }

.em-button {
  background: var(--em-color-brand);
  border: 1px solid var(--em-color-brand);
  border-radius: var(--em-radius-sm);
  box-shadow: none;
  color: var(--em-color-on-brand);
  cursor: pointer;
  font-family: inherit;
  font-size: var(--em-font-size-md);
  font-weight: 600;
  min-height: 2.5rem;
  padding: var(--em-space-2) var(--em-space-4);
  transition: opacity var(--em-duration-fast) var(--em-ease-standard);
  width: 100%;
}

.em-button:hover { opacity: 0.88; }

.em-button-secondary {
  background: var(--em-color-surface);
  border-color: var(--em-color-border-strong);
  color: var(--em-color-text);
  margin-top: var(--em-space-3);
}

a { color: var(--em-color-link); text-decoration: none; }
a:hover { color: var(--em-color-link); text-decoration: underline; }

.em-alert {
  background: var(--em-color-surface);
  border: 1px solid var(--em-color-border);
  border-left: 3px solid var(--em-color-info);
  border-radius: var(--em-radius-sm);
  color: var(--em-color-text);
  font-size: var(--em-font-size-sm);
  margin: 0 0 var(--em-space-5);
  padding: var(--em-space-3);
}

.em-alert-danger { background: var(--em-color-danger-soft); border-left-color: var(--em-color-danger); }
.em-alert-warning { background: var(--em-color-warning-soft); border-left-color: var(--em-color-warning); }

.em-footer {
  align-items: center;
  border-top: 1px solid var(--em-color-border);
  color: var(--em-color-text-subtle);
  display: flex;
  font-size: var(--em-font-size-xs);
  gap: var(--em-space-3);
  justify-content: space-between;
  margin-top: var(--em-space-8);
  padding-top: var(--em-space-5);
}

.em-theme-control {
  display: none;
  position: absolute;
  right: var(--em-space-8);
  top: var(--em-space-6);
  z-index: 10;
}

/* theme-init.js sets this before paint; no non-functional picker without JS. */
html[data-theme-preference] .em-theme-control { display: block; }

.em-theme-trigger {
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--em-radius-sm);
  color: var(--em-color-text-muted);
  cursor: pointer;
  display: flex;
  height: 2rem;
  justify-content: center;
  list-style: none;
  width: 2.5rem;
}

.em-theme-trigger::-webkit-details-marker { display: none; }
.em-theme-trigger:hover, .em-theme-control[open] .em-theme-trigger { background: var(--em-color-surface-subtle); color: var(--em-color-text); }
.em-theme-trigger .em-theme-icon-dark { display: none; }
html[data-theme="dark"] .em-theme-trigger .em-theme-icon-light { display: none; }
html[data-theme="dark"] .em-theme-trigger .em-theme-icon-dark { display: block; }
.em-theme-icon { flex: none; }

.em-theme-options {
  background: var(--em-color-surface-raised);
  border: 1px solid var(--em-color-border);
  border-radius: var(--em-radius-md);
  box-shadow: var(--em-shadow-md);
  display: grid;
  gap: var(--em-space-1);
  margin-top: var(--em-space-2);
  min-width: 12rem;
  padding: var(--em-space-1);
  position: absolute;
  right: 0;
}

.em-theme-control:not([open]) .em-theme-options { display: none; }

.em-theme-option {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--em-radius-sm);
  color: var(--em-color-text);
  cursor: pointer;
  display: flex;
  font-family: inherit;
  font-size: var(--em-font-size-sm);
  gap: var(--em-space-2);
  min-height: 2rem;
  padding: var(--em-space-2);
  text-align: left;
}

.em-theme-option:hover, .em-theme-option[aria-pressed="true"] { background: var(--em-color-surface-subtle); }
.em-theme-option .em-theme-icon-check { margin-left: auto; visibility: hidden; }
.em-theme-option[aria-pressed="true"] .em-theme-icon-check { visibility: visible; }

.em-visually-hidden {
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

@media (max-width: 39rem) {
  .em-page { align-items: flex-start; padding: 5.5rem var(--em-space-4) var(--em-space-8); }
  .em-brand { left: var(--em-space-4); top: var(--em-space-4); }
  .em-theme-control { right: var(--em-space-4); top: var(--em-space-4); }
  .em-card { padding-top: var(--em-space-8); }
  .em-footer { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
