/*
 * Login page styles (login-with-google.php / login.php).
 *
 * Theme resolution matches modern Tourbot + user.php:
 *   - default / data-theme="light"  -> light
 *   - data-theme="dark"             -> dark (forced)
 *   - system dark + no data-theme   -> dark via prefers-color-scheme (the
 *     no-JS fallback; with JS the toggle always sets data-theme explicitly)
 *
 * A page-local three-state toggle stores light|dark|system in localStorage
 * (login.php-theme) and mirrors the choice onto data-theme-pref, which is what
 * the button's icon keys off. data-theme always carries the *resolved* scheme.
 */

:root,
:root[data-theme="light"] {
  color-scheme: light;

  --login-bg: #ffffff;
  --login-surface: #eeeeee;
  --login-surface-border: rgba(0, 0, 0, 0.1);
  --login-text: #333333;
  --login-text-muted: #666666;
  --login-text-faint: #999999;
  --login-link: #064b87;
  --login-link-hover: #053a69;
  --login-btn-bg: #ffffff;
  --login-btn-border: #cccccc;
  --login-btn-text: #333333;
  --login-btn-hover-bg: #f5f5f5;
  --login-error: #a94442;
  --login-success: #2e7d32;
  --login-toggle-bg: #ffffff;
  --login-toggle-border: #d9e0e7;
  --login-toggle-text: #333333;
  --login-toggle-shadow: rgba(20, 30, 45, 0.12);
  --login-toggle-hover-bg: #f4f8fc;
}

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

  --login-bg: #14181d;
  --login-surface: #1e242b;
  --login-surface-border: #333b44;
  --login-text: #e6e9ec;
  --login-text-muted: #a3adb8;
  --login-text-faint: #7f8a95;
  --login-link: #6db0ea;
  --login-link-hover: #8ec2f0;
  --login-btn-bg: #262d35;
  --login-btn-border: #4a5561;
  --login-btn-text: #e6e9ec;
  --login-btn-hover-bg: #2f3842;
  --login-error: #f0a0a0;
  --login-success: #7dcea0;
  --login-toggle-bg: #1e242b;
  --login-toggle-border: #4a5561;
  --login-toggle-text: #e6e9ec;
  --login-toggle-shadow: rgba(0, 0, 0, 0.5);
  --login-toggle-hover-bg: #262d35;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --login-bg: #14181d;
    --login-surface: #1e242b;
    --login-surface-border: #333b44;
    --login-text: #e6e9ec;
    --login-text-muted: #a3adb8;
    --login-text-faint: #7f8a95;
    --login-link: #6db0ea;
    --login-link-hover: #8ec2f0;
    --login-btn-bg: #262d35;
    --login-btn-border: #4a5561;
    --login-btn-text: #e6e9ec;
    --login-btn-hover-bg: #2f3842;
    --login-error: #f0a0a0;
    --login-success: #7dcea0;
    --login-toggle-bg: #1e242b;
    --login-toggle-border: #4a5561;
    --login-toggle-text: #e6e9ec;
    --login-toggle-shadow: rgba(0, 0, 0, 0.5);
    --login-toggle-hover-bg: #262d35;
  }
}

html,
body {
  background-color: var(--login-bg);
  color: var(--login-text);
}

.wrapper {
  margin-top: 80px;
  margin-bottom: 20px;
}

.form-signin {
  max-width: 420px;
  padding: 30px 38px 66px;
  margin: 0 auto;
  background-color: var(--login-surface);
  border: 3px dotted var(--login-surface-border);
  color: var(--login-text);
}

.form-signin-heading {
  text-align: center;
  margin-bottom: 30px;
  color: var(--login-text);
}

.form-control {
  position: relative;
  font-size: 16px;
  height: auto;
  padding: 10px;
}

input[type="text"] {
  margin-bottom: 0px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

input[type="password"] {
  margin-bottom: 20px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.colorgraph {
  height: 7px;
  border-top: 0;
  background: #c4e17f;
  border-radius: 5px;
  background-image: -webkit-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
  background-image: -moz-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
  background-image: -o-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
  background-image: linear-gradient(to right, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
}

#customBtn:hover {
  cursor: pointer;
}

span.label {
  font-family: serif;
  font-weight: normal;
}

span.icon {
  background: url('../oauth/img/g-normal.png') transparent 5px 50% no-repeat;
  display: inline-block;
  vertical-align: middle;
  width: 42px;
  height: 42px;
}

span.buttonText {
  display: inline-block;
  vertical-align: middle;
  padding-left: 56px;
  padding-right: 56px;
}

/* Links + secondary copy */
.login-links a,
.wrapper > p a {
  color: var(--login-link);
}

.login-links a:hover,
.login-links a:focus,
.wrapper > p a:hover,
.wrapper > p a:focus {
  color: var(--login-link-hover);
}

.login-or-divider {
  color: var(--login-text-faint);
  margin: 0.6rem 0;
}

.login-frame-message {
  color: var(--login-text-muted);
  margin: 1rem 0;
}

#passkey_msg.is-error {
  color: var(--login-error);
}

#passkey_msg.is-success {
  color: var(--login-success);
}

#passkey_msg.is-muted {
  color: var(--login-text-muted);
}

/* Passkey buttons: keep Bootstrap shape, theme the fill */
#passkey_signin_btn.btn-default,
#passkey_register_btn.btn-default {
  background-color: var(--login-btn-bg);
  border-color: var(--login-btn-border);
  color: var(--login-btn-text);
}

#passkey_signin_btn.btn-default:hover,
#passkey_signin_btn.btn-default:focus,
#passkey_register_btn.btn-default:hover,
#passkey_register_btn.btn-default:focus {
  background-color: var(--login-btn-hover-bg);
  border-color: var(--login-btn-border);
  color: var(--login-btn-text);
}

/* Fixed top-center theme toggle.
   Centered so Google One Tap / account chooser (top-right) does not cover it. */
.login-theme-toggle {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  /* Below the environment banner (z-index ~2e9) but above page chrome. */
  z-index: 1100;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--login-toggle-border);
  background-color: var(--login-toggle-bg);
  color: var(--login-toggle-text);
  box-shadow: 0 2px 8px var(--login-toggle-shadow);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

/* Keep the control clear of the fixed environment banner when present. */
body:has(#eta-environment-banner) .login-theme-toggle {
  top: 40px;
}

.login-theme-toggle:hover,
.login-theme-toggle:focus {
  background-color: var(--login-toggle-hover-bg);
  outline: none;
}

.login-theme-toggle:focus-visible {
  box-shadow: 0 0 0 3px rgba(109, 176, 234, 0.35), 0 2px 8px var(--login-toggle-shadow);
}

.login-theme-toggle .theme-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
}

.login-theme-toggle .theme-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.login-theme-toggle .theme-icon-sun,
.login-theme-toggle .theme-icon-moon,
.login-theme-toggle .theme-icon-system {
  display: none;
}

/* The control has three states, so the icon shows the setting that is currently
   active rather than the one you would switch to. Keyed off data-theme-pref
   (the user's choice) not data-theme (the resolved colour scheme), because
   "system" resolves to light or dark and is otherwise indistinguishable. */
html[data-theme-pref="light"] .login-theme-toggle .theme-icon-sun {
  display: inline-flex;
}

html[data-theme-pref="dark"] .login-theme-toggle .theme-icon-moon {
  display: inline-flex;
}

html[data-theme-pref="system"] .login-theme-toggle .theme-icon-system {
  display: inline-flex;
}

/* No JS (so no data-theme-pref): the page follows the OS via
   prefers-color-scheme below, which is exactly the System state. */
html:not([data-theme-pref]) .login-theme-toggle .theme-icon-system {
  display: inline-flex;
}
