/**
 * Auth — Login & Register. Minimal deps: variables + this file only.
 */
*,
*::before,
*::after { box-sizing: border-box; }
body {
  margin: 0;
  padding: 0;
  font-family: var(--app-font);
  -webkit-text-size-adjust: 100%;
}
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--app-font);
  color: var(--app-text);
  background: var(--app-bg);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
.auth-wrap {
  padding: max(var(--app-safe-top), 20px) 20px max(32px, calc(var(--app-safe-bottom) + 20px));
  max-width: 440px;
  margin: 0 auto;
  width: 100%;
}
.auth-wrap > .auth-panel[hidden] {
  display: none !important;
}
.auth-panel {
  display: block;
}
#panel-register:not([hidden]) {
  display: block !important;
}
.auth-header {
  text-align: center;
  margin-bottom: 24px;
}
.auth-logo {
  display: inline-block;
  margin-bottom: 12px;
}
.auth-logo img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: var(--app-radius-md);
}
.auth-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  margin: 0 0 2px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #4f46e5 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: prepriga-shimmer 3s ease-in-out infinite;
}
@keyframes prepriga-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.auth-tagline {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--app-primary);
  letter-spacing: 0.04em;
  margin: 0 0 8px;
}
.auth-sub {
  font-size: var(--app-text-sm);
  color: var(--app-text-secondary);
  margin: 0;
}

/* Tabs: Login | Register */
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  padding: 4px;
}
.auth-panel .auth-form {
  padding-bottom: 24px;
}
.auth-tab {
  flex: 1;
  min-height: 44px;
  padding: 10px 16px;
  font-size: var(--app-text-sm);
  font-weight: 600;
  color: var(--app-text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--app-radius-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s, background 0.2s;
}
.auth-tab:hover {
  color: var(--app-text);
}
.auth-tab.active {
  background: var(--app-primary);
  color: #fff;
}
.auth-tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--app-bg), 0 0 0 4px var(--app-primary);
}

/* Forms — all inputs and selects same size */
.auth-form {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}
.auth-form .form-group {
  margin-bottom: var(--app-space-md);
}
.auth-form .form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--app-text);
  margin-bottom: 6px;
}
.auth-form .form-label .required {
  color: var(--app-primary);
}
.auth-form .form-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--app-text-muted);
  margin-top: 6px;
}
.auth-form .form-input,
.auth-form .form-select {
  display: block;
  width: 100%;
  height: 48px;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.25;
  color: var(--app-text);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}
.auth-form .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.auth-form .form-input:focus,
.auth-form .form-select:focus {
  outline: none;
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px var(--app-primary-soft);
}
.auth-form .form-input:focus-visible,
.auth-form .form-select:focus-visible {
  outline: none;
}
.auth-form .form-input::placeholder {
  color: var(--app-text-muted);
}

/* Password field with show/hide toggle */
.password-input-wrap {
  position: relative;
}
.password-input-wrap .form-input {
  padding-right: 48px;
}
.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: none;
  color: var(--app-text-muted);
  cursor: pointer;
  border-radius: var(--app-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.password-toggle:hover {
  color: var(--app-text);
}
.password-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--app-primary-soft);
}
.password-toggle .icon-eye,
.password-toggle .icon-eye-off {
  pointer-events: none;
}
.password-match-hint {
  margin-top: 6px;
  min-height: 1.2em;
}
.password-match-hint.match {
  color: #059669;
}
.password-match-hint.mismatch {
  color: #dc2626;
}

.auth-form input[type="range"] {
  height: auto;
  min-height: 32px;
  padding: 0;
}
.auth-form .btn-primary-block {
  width: 100%;
  margin-top: 12px;
  padding: 14px 20px;
  min-height: 48px;
  font-weight: 600;
  font-size: 1rem;
  border-radius: var(--app-radius-md);
  border: none;
  background: var(--app-primary);
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--app-duration-fast, 0.2s) ease;
}
.auth-form .btn-primary-block:hover {
  background: var(--app-primary-hover);
}
.auth-form .btn-primary-block:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--app-primary-soft);
}
.auth-form .btn-secondary-block {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  font-weight: 600;
  font-size: 0.9375rem;
  border-radius: var(--app-radius-md);
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  color: var(--app-text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.auth-form .btn-secondary-block:hover {
  background: var(--app-border-soft);
}

/* Register: role selection */
.auth-role-heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--app-text);
  margin: 0 0 12px;
}
.auth-role-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}
.auth-role-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 80px;
  width: 100%;
  min-width: 0;
  padding: 14px 8px;
  background: var(--app-surface, #fff);
  border: 2px solid var(--app-border, #e2e8f0);
  border-radius: var(--app-radius-md, 12px);
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s, background 0.2s;
  user-select: none;
  font: inherit;
  color: inherit;
}
.auth-role-card .role-name {
  word-break: break-word;
  line-height: 1.2;
}
.auth-role-card:focus-visible {
  outline: none;
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px var(--app-primary-soft);
}
.auth-role-card:hover {
  border-color: var(--app-primary);
  background: var(--app-primary-soft);
}
.auth-role-card.selected {
  border-color: var(--app-primary);
  background: var(--app-primary-soft);
}
.auth-role-card .role-icon {
  width: 36px;
  height: 36px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-role-card .role-icon img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.auth-role-card .role-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--app-text);
}
.auth-role-card .role-desc {
  font-size: 0.7rem;
  color: var(--app-text-muted);
  margin-top: 2px;
}

/* Role-specific sections (show/hide via JS) */
.auth-register-section[data-role-section] {
  display: none;
}
.auth-register-section[data-role-section].visible {
  display: block;
}

/* Institution type */
.auth-inline-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.auth-inline-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  cursor: pointer;
  font-size: var(--app-text-sm);
}
.auth-inline-options input:checked + span {
  font-weight: 600;
  color: var(--app-primary);
}
.auth-inline-options input {
  accent-color: var(--app-primary);
}

/* Footer links */
.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: var(--app-text-sm);
  color: var(--app-text-secondary);
}
.auth-footer a {
  color: var(--app-primary);
  text-decoration: none;
}
.auth-footer a:hover {
  text-decoration: underline;
}
.auth-divider {
  margin: 20px 0;
  border: none;
  border-top: 1px solid var(--app-border);
}
.auth-go-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  color: var(--app-primary);
  font-size: var(--app-text-sm);
  text-decoration: none;
}
.auth-go-back:hover {
  text-decoration: underline;
}
.auth-footer-bottom {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--app-border-soft);
  flex-shrink: 0;
}
.auth-footer-bottom .auth-footer {
  margin-top: 0;
}
.auth-form .signup-range-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.auth-form input[type="range"] {
  flex: 1;
  min-width: 120px;
  accent-color: var(--app-primary);
}
