/*
 * Login pages of the Rocsys Connected API Documentation (views/access/docs/index.hbs) and of the cloud-core admin
 * area (views/access/admin/index.hbs).
 * Mirrors the first step of the Auth0 login used by the portals (login.rocsys.com): the values and
 * variable names below are Auth0's own (its Universal Login stylesheet and the Rocsys branding).
 */
:root {
  --page-background-color: #000000;
  --widget-background-color: #ffffff;
  --primary-color: #0059d6;
  --button-font-color: #ffffff;
  --button-hover-shadow: inset 0 0 0 150px rgba(0, 0, 0, 0.1);
  --base-focus-color: #3f59e4;
  --error-color: #d00e17;
  --gray-darkest: #2d333a;
  --gray-dark: #6f7780;
  --gray-mid-dark: #686868;
  --font-family: -apple-system, BlinkMacSystemFont, Roboto, Helvetica, sans-serif;
  --prompt-width: 400px;
  --prompt-min-height: 540px;
  --form-element-height: 52px;
  --border-radius-outer: 5px;
  --border-radius-form-elements: 3px;
}

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

body {
  margin: 0;
  background: var(--page-background-color);
  color: var(--gray-darkest);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.1;
}

.page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 80px;
}

.login-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: var(--prompt-width);
  min-height: var(--prompt-min-height);
  background: var(--widget-background-color);
  border-radius: var(--border-radius-outer);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.login-header {
  padding: 40px 40px 24px;
  text-align: center;
  line-height: 1.5;
}

.login-logo {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

.login-title {
  margin: 24px 0 16px;
  font-size: 24px;
  font-weight: 400;
  line-height: 1.5;
}

.login-subtitle {
  margin: 0;
  font-size: 14px;
}

.login-form {
  padding: 0 40px 40px;
}

/* text field with a floating label, like Auth0's */
.field {
  position: relative;
}

/* stacked fields (the admin login's username and password), spaced like Auth0's form elements */
.field + .field {
  margin-top: 16px;
}

.field-input {
  display: block;
  width: 100%;
  height: var(--form-element-height);
  margin: 0;
  padding: 0 16px;
  border: 1px solid var(--gray-mid-dark);
  border-radius: var(--border-radius-form-elements);
  background: var(--widget-background-color);
  color: var(--gray-darkest);
  font-family: inherit;
  font-size: 16px;
  transition:
    box-shadow 0.15s ease-in-out,
    border-color 0.15s ease-in-out;
}

.field-input:focus {
  outline: none;
  border-color: var(--base-focus-color);
  box-shadow: 0 0 0 1px var(--base-focus-color);
}

.field-label {
  position: absolute;
  top: 26px;
  left: 16px;
  padding: 1px 6px;
  background: var(--widget-background-color);
  color: var(--gray-dark);
  font-size: 16px;
  line-height: 16px;
  pointer-events: none;
  transform: translateY(-50%);
  transform-origin: 0 9px;
  transition:
    transform 0.15s ease-in-out,
    top 0.15s ease-in-out,
    padding 0.15s ease-in-out;
}

/* focused or filled: the label moves onto the top border */
.field-input:focus + .field-label,
.field-input:not(:placeholder-shown) + .field-label {
  top: -2px;
  transform: translate(-7px, -9.2px) scale(0.88);
}

.field-input:focus + .field-label {
  color: var(--base-focus-color);
}

.field-required {
  margin-left: 2px;
}

.field-error .field-input,
.field-error .field-input:focus {
  border-color: var(--error-color);
  box-shadow: 0 0 0 1px var(--error-color);
}

.field-error .field-label,
.field-error .field-input:focus + .field-label {
  color: var(--error-color);
}

/*
 * Browser autofill: float the label (the field can still match :placeholder-shown before the user interacts) and
 * paint over the browser's autofill background, like Auth0. Separate rules, so a browser that doesn't know
 * :-webkit-autofill only drops these.
 */
.field-input:-webkit-autofill + .field-label {
  top: -2px;
  transform: translate(-7px, -9.2px) scale(0.88);
}

.field-input:-webkit-autofill {
  -webkit-text-fill-color: var(--gray-darkest);
  box-shadow: inset 0 0 0 30px var(--widget-background-color);
}

.field-input:-webkit-autofill:focus {
  box-shadow:
    inset 0 0 0 30px var(--widget-background-color),
    0 0 0 1px var(--base-focus-color);
}

.field-error .field-input:-webkit-autofill,
.field-error .field-input:-webkit-autofill:focus {
  box-shadow:
    inset 0 0 0 30px var(--widget-background-color),
    0 0 0 1px var(--error-color);
}

.error {
  display: flex;
  align-items: flex-start;
  margin: 8px 0 0;
  color: var(--error-color);
  font-size: 12px;
  line-height: 1.4;
}

/* Auth0's error icon: a red circle with an exclamation mark */
.error::before {
  content: '';
  flex: none;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='16' height='16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M8 14.667A6.667 6.667 0 1 0 8 1.333a6.667 6.667 0 0 0 0 13.334z' fill='%23D00E17' stroke='%23D00E17' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M8 4.583a.75.75 0 0 1 .75.75V8a.75.75 0 0 1-1.5 0V5.333a.75.75 0 0 1 .75-.75z' fill='%23fff'/%3E%3Cpath d='M8.667 10.667a.667.667 0 1 1-1.334 0 .667.667 0 0 1 1.334 0z' fill='%23fff'/%3E%3C/svg%3E");
}

.button {
  display: block;
  width: 100%;
  height: var(--form-element-height);
  margin: 24px 0 0;
  padding: 4px 16px;
  border: 0;
  border-radius: var(--border-radius-form-elements);
  background-color: var(--primary-color);
  color: var(--button-font-color);
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
  transition: box-shadow 0.25s ease-in-out;
}

.button:hover,
.button:focus-visible {
  box-shadow: var(--button-hover-shadow);
}

.button:focus-visible {
  outline: 2px solid var(--base-focus-color);
  outline-offset: 2px;
}

/*
 * on a phone Auth0 fills the screen with the white box; from 560px down, since below that the 80px page padding
 * would squeeze the 400px box
 */
@media (max-width: 560px) {
  .page {
    padding: 0;
  }

  .login-box {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .field-input,
  .field-label,
  .button {
    transition: none;
  }
}
