/* ==========================================
   BENEFIQ — AUTH SCREEN
   ========================================== */

@layer pages {

  /* Auth Screen */
  .auth-screen {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
      radial-gradient(ellipse at 20% 20%, rgba(235, 68, 37, 0.08) 0%, transparent 50%),
      radial-gradient(ellipse at 80% 50%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
      radial-gradient(ellipse at 50% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 40%),
      #0A0F1A;
    padding: 1rem;
  }

  /* Back button */
  .auth-back {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    transition: all 0.2s ease;
  }

  .auth-back:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
  }

  .auth-back svg {
    flex-shrink: 0;
  }

  /* Logo link */
  .auth-logo-link {
    display: block;
    transition: opacity 0.2s ease;
  }

  .auth-logo-link:hover {
    opacity: 0.8;
  }

  .auth-container {
    width: 100%;
    max-width: 400px;
    background: var(--auth-surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 2rem;
  }

  .auth-brand {
    text-align: center;
    margin-bottom: 2rem;
  }

  .auth-logo {
    height: 64px;
    width: auto;
    margin: 0 auto 1rem;
    display: block;
  }

  .auth-brand h1 {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 800;
    color: #FFFFFF;
    margin: 0 0 0.5rem;
    letter-spacing: -0.02em;
  }

  .auth-brand p {
    color: var(--auth-text-muted);
    margin: 0;
  }

  .auth-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 0.5rem;
    padding: 0.25rem;
  }

  .auth-tab {
    flex: 1;
    padding: 0.625rem 1rem;
    border: none;
    background: transparent;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--auth-text-muted);
    cursor: pointer;
    transition: all 0.2s;
  }

  .auth-tab.active {
    background: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
    box-shadow: none;
  }

  .auth-field {
    margin-bottom: 1rem;
  }

  .auth-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--auth-text);
    margin-bottom: 0.375rem;
  }

  .auth-field input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font-body);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-input);
    font-size: 1rem;
    color: var(--auth-text);
    background: rgba(255, 255, 255, 0.04);
    transition: border-color var(--transition-base);
    box-sizing: border-box;
  }

  .auth-field input::placeholder {
    color: var(--auth-text-muted);
  }

  .auth-field input:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(235, 68, 37, 0.15);
  }

  /* Inline field validation */
  .auth-field input.invalid,
  .auth-field input.invalid:focus {
    border-color: #F87171;
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.15);
  }

  .auth-field-error {
    display: block;
    height: 0;
    overflow: hidden;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    color: #FCA5A5;
    padding-left: 0.125rem;
    transition: height 0.2s ease, margin-top 0.2s ease, opacity 0.2s ease;
    opacity: 0;
  }

  .auth-field-error.show {
    height: auto;
    margin-top: 0.375rem;
    opacity: 1;
  }

  /* Password requirements popover */
  .auth-field--password {
    position: relative;
  }

  .pw-requirements {
    display: none;
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
    background: #0F1923;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  }

  .pw-requirements.visible {
    display: block;
    animation: fieldErrorIn 0.2s ease-out;
  }

  @keyframes fieldErrorIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .pw-req {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.4);
    padding: 0.1875rem 0;
    transition: color 0.2s ease;
  }

  .pw-req.met {
    color: #6EE7B7;
  }

  .pw-req-icon {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
  }

  .pw-req-icon::after {
    content: '';
    display: block;
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    background: transparent;
    transition: background 0.2s ease;
  }

  .pw-req.met .pw-req-icon {
    border-color: #6EE7B7;
    background: rgba(110, 231, 183, 0.15);
  }

  .pw-req.met .pw-req-icon::after {
    background: #6EE7B7;
  }

  .auth-remember {
    margin-bottom: 1rem;
  }

  .auth-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--auth-text-muted);
  }

  .auth-checkbox input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--color-accent);
    cursor: pointer;
  }

  .auth-submit {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: var(--gradient-brand);
    color: white;
    border: none;
    border-radius: var(--radius-pill);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    transform: scale(1);
    margin-top: 0.5rem;
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.3);
  }

  .auth-submit:hover {
    background: var(--gradient-brand-hover);
    box-shadow: 0 8px 25px rgba(249, 115, 22, 0.4);
  }

  .auth-submit:active {
    transform: scale(0.97);
  }

  .auth-submit:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
  }

  .auth-error {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 0.5rem;
    color: #FCA5A5;
    font-size: 0.875rem;
    display: none;
  }

  .auth-error.show {
    display: block;
  }

  .auth-divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
    color: var(--auth-text-muted);
    font-size: 0.875rem;
  }

  .auth-divider::before,
  .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
  }

  .auth-divider span {
    padding: 0 1rem;
  }

  .auth-oauth-buttons {
    display: flex;
    gap: 0.5rem;
  }

  .auth-oauth {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--auth-text);
    cursor: pointer;
    transition: all 0.2s;
  }

  .auth-oauth:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
  }

  .auth-oauth.auth-facebook {
    background: #1877F2;
    border-color: #1877F2;
    color: #fff;
  }

  .auth-oauth.auth-facebook:hover {
    background: #166fe5;
  }

  .auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--auth-text-muted);
  }

  .auth-footer a {
    color: var(--brand-400);
    text-decoration: none;
  }

  .auth-footer a:hover {
    text-decoration: underline;
  }

  /* Loading state */
  .auth-submit.loading {
    position: relative;
    color: transparent;
  }

  .auth-submit.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1.25rem;
    height: 1.25rem;
    margin: -0.625rem 0 0 -0.625rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
  }

  @keyframes spin {
    to { transform: rotate(360deg); }
  }

  /* Success message */
  .auth-success {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 0.5rem;
    color: #6EE7B7;
    font-size: 0.875rem;
    display: none;
  }

  .auth-success.show {
    display: block;
  }

  /* Password input wrapper for caps lock indicator */
  .password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
  }

  .password-input-wrapper input {
    flex: 1;
    padding-right: 40px;
  }

  .caps-lock-indicator {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #F59E0B;
    display: flex;
    align-items: center;
    justify-content: center;
  }

}
